Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Issue 1591001: Explicitly use the ULL suffix to specify a large constant. (Closed)

Created:
10 years, 8 months ago by gauravsh
Modified:
9 years, 6 months ago
Reviewers:
Will Drewry
CC:
chromium-os-reviews_chromium.org, gauravsh
Visibility:
Public.

Description

Explicitly use the ULL suffix to specify a large constant. This hopefully fixes the ARM build error. TBR = wad@chromium.org

Patch Set 1 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+2 lines, -2 lines) Patch
M src/platform/vboot_reference/tests/big_firmware_tests.c View 1 chunk +1 line, -1 line 1 comment Download
M src/platform/vboot_reference/tests/big_kernel_tests.c View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 2 (0 generated)
gauravsh
10 years, 8 months ago (2010-03-30 07:37:21 UTC) #1
Will Drewry
10 years, 8 months ago (2010-03-30 14:40:13 UTC) #2
LGTM

http://codereview.chromium.org/1591001/diff/1/2
File src/platform/vboot_reference/tests/big_firmware_tests.c (right):

http://codereview.chromium.org/1591001/diff/1/2#newcode19
src/platform/vboot_reference/tests/big_firmware_tests.c:19: #define
BIG_FIRMWARE_SIZE ((uint64_t) 0x100000000ULL)
Have you run into any weirdness else where in the firmware code (not just
tests)?

If so, you may want to add some compile-time checking to ensure that
constants/max/etc aren't being truncated in unexpected ways.  E.g., this could
be done as: 
#define BIG_FIRMWARE_SIZE U64(0x100000000)

and have it include a platform.h (or in utility.h) that contains some basic
sanity checking:
#if __WORDSIZE == 64                                                            
#  define U64(x) ((uint64_t)(x ## UL))                                          
#elif __WORDSIZE == 32                                                          
#  define U64(x) ((uint64_t)(x ## ULL))                                         
#else                                                                           
#  error "Unsupported compilation target platform"                              
#endif                                                                          

If it seemed practical, you could also expand it to support U32, U16, etc to
ensure that all values are as declared.   However that may be overkill. (Of
course, we could also expand coverage to do any other type and math checking
throughout the code)

Powered by Google App Engine
This is Rietveld 408576698