diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2015-12-22 07:55:19 -0800 |
---|---|---|
committer | Jeff Vander Stoep <jeffv@google.com> | 2016-01-04 11:24:45 -0800 |
commit | c38a20bcc7d985aeb0613fa09ffb1983afd6f92e (patch) | |
tree | 3070321b4dd3a26ea8d876101e0f221fd31bbecd | |
parent | 08fd9ea25302047316f5d4398a869c3d551a1561 (diff) | |
download | minijail-c38a20bcc7d985aeb0613fa09ffb1983afd6f92e.tar.gz |
Make genearation of libconstants.c more robust
Changes to the clang build flags passed into gen_constants.sh
can cause compile errors for the generated libconstants.c. Make
this process more robust by:
1. Typecasting values to unsigned long to address compiler failures
when other integer types are added to libconstants.c.
2. Making the grep statement filter out constants defined
without a value but with trailing whitespace e.g.
"#define ANDROID_API_H ".
Change-Id: I91d65db70b9e267882a8f381a836bbd7caded22e
-rwxr-xr-x | gen_constants.sh | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gen_constants.sh b/gen_constants.sh index 7b39156..9f217ee 100755 --- a/gen_constants.sh +++ b/gen_constants.sh @@ -40,7 +40,7 @@ INCLUDES=' # { "AT_FDWCD", AT_FDCWD }, # endif SED_MULTILINE='s@#define ([[:upper:]][[:upper:]0-9_]*).*@#ifdef \1\ - { "\1", \1 },\ + { "\1", (unsigned long) \1 },\ #endif // \1@' # Passes the previous list of #includes to the C preprocessor and prints out @@ -54,7 +54,7 @@ $INCLUDES const struct constant_entry constant_table[] = { $(echo "$INCLUDES" | \ ${CC} -dD - -E | \ - grep '^#define [[:upper:]][[:upper:]0-9_]* ' | \ + grep -E '^#define [[:upper:]][[:upper:]0-9_]*(\s)+[[:alnum:]]' | \ grep -Ev '(SIGRTMAX|SIGRTMIN|SIG_|NULL)' | \ sort -u | \ sed -Ee "${SED_MULTILINE}") |