summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-07-19 10:48:30 -0700
committerChromeBot <chrome-bot@google.com>2013-07-19 18:01:55 -0700
commitfe76b51da007bf51347ad3c3af549562a6d9979a (patch)
treee77abe8e897b96156ea0584bd2d9ad312138fb00
parentdb347953e1a463abcb50669988b3f45bd7fbb826 (diff)
downloadchrome-ec-fe76b51da007bf51347ad3c3af549562a6d9979a.tar.gz
Truncate version string to 32 characters
The version struct and EC_CMD_GET_VERSION assume 32-character version strings. But if the git tree is dirty and the board name is long, the version string overflows that limit. This change truncates what's stored in the version string to fit. The build info still contains the full version string, as it did before. BUG=chrome-os-partner:21156 BRANCH=none TEST=build BOARD=mccroskey with a dirty tree; it should build. Then cat build/mccroskey/ec_version.h to see CROS_EC_VERSION32 has truncated the version string. Then build a platform of your choice and type 'version' to see that the version string and build info is still reported correctly. Change-Id: Ie71b8efd99a83315f8b4d5ad10c51e48781b12f4 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/62649 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--common/version.c4
-rw-r--r--include/version.h6
-rwxr-xr-xutil/getversion.sh21
3 files changed, 19 insertions, 12 deletions
diff --git a/common/version.c b/common/version.c
index 36567095ff..a2f554e58d 100644
--- a/common/version.c
+++ b/common/version.c
@@ -12,9 +12,9 @@
const struct version_struct version_data
__attribute__((section(".rodata.ver"))) = {
CROS_EC_VERSION_COOKIE1,
- CROS_EC_VERSION,
+ CROS_EC_VERSION32,
CROS_EC_VERSION_COOKIE2
};
const char build_info[] __attribute__((section(".rodata.buildinfo"))) =
- CROS_EC_BUILD_INFO;
+ CROS_EC_VERSION " " DATE " " BUILDER;
diff --git a/include/version.h b/include/version.h
index aca6b87a73..18968ce072 100644
--- a/include/version.h
+++ b/include/version.h
@@ -8,15 +8,9 @@
#ifndef __CROS_EC_VERSION_H
#define __CROS_EC_VERSION_H
-#define STRINGIFY0(name) #name
-#define STRINGIFY(name) STRINGIFY0(name)
-
#define CROS_EC_VERSION_COOKIE1 0xce112233
#define CROS_EC_VERSION_COOKIE2 0xce445566
-#define CROS_EC_VERSION STRINGIFY(BOARD) "_" VERSION
-#define CROS_EC_BUILD_INFO CROS_EC_VERSION " " DATE " " BUILDER
-
struct version_struct {
uint32_t cookie1;
char version[32];
diff --git a/util/getversion.sh b/util/getversion.sh
index 06061ada93..4d1931d4a2 100755
--- a/util/getversion.sh
+++ b/util/getversion.sh
@@ -24,14 +24,27 @@ if ghash=`git rev-parse --short --verify HEAD 2>/dev/null`; then
git status > /dev/null 2>&1
dirty=`sh -c "[ '$(git diff-index --name-only HEAD)' ] && echo '-dirty'"`
- ver="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
+ vbase="${ver_major}.${ver_branch}.${numcommits}-${ghash}${dirty}"
else
- ver="no_version"
+ vbase="no_version"
fi
+
+ver="${BOARD}_${vbase}"
+
+echo "/* This file is generated by util/getversion.sh */"
+
+echo "/* Version string for use by common/version.c */"
echo "#ifdef SHIFT_CODE_FOR_TEST"
-echo "#define VERSION \"${ver}_shift\""
+echo "#define CROS_EC_VERSION \"${ver}_shift\""
echo "#else"
-echo "#define VERSION \"${ver}\""
+echo "#define CROS_EC_VERSION \"${ver}\""
echo "#endif"
+
+echo "/* Version string, truncated to 31 chars (+ terminating null = 32) */"
+echo "#define CROS_EC_VERSION32 \"${ver:0:31}\""
+
+echo "/* Sub-fields for use in Makefile.rules and to form build info string"
+echo " * in common/version.c. */"
+echo "#define VERSION \"${ver}\""
echo "#define DATE \"`date '+%F %T'`\""
echo "#define BUILDER \"${USER}@`hostname`\""