diff options
author | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-12-10 14:03:28 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2014-12-10 14:03:28 +1100 |
commit | 378495dcc88b4d5c4ae1210f3c72c037a42187d8 (patch) | |
tree | ad01800a6bbeb09b2f0bb7e231988ba1425709b3 | |
parent | 360499c4fd62d05ef6902cc98a92c177e6b468c8 (diff) | |
download | skiboot-378495dcc88b4d5c4ae1210f3c72c037a42187d8.zip skiboot-378495dcc88b4d5c4ae1210f3c72c037a42187d8.tar.gz skiboot-378495dcc88b4d5c4ae1210f3c72c037a42187d8.tar.bz2 |
Fix bug/warning in hdata/memory.c I introduced in f1a3a19
Passing the wrong parameter to snprintf (sizeof(char*)) rather
than actual length of the string. GCC 4.9 told us about it (and broke
make check when I enabled -Werror)
hdata/test/../memory.c: In function ‘add_address_range’:
hdata/test/../memory.c:144:23: error: argument to ‘sizeof’ in ‘snprintf’ call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r-- | hdata/memory.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/hdata/memory.c b/hdata/memory.c index cf336a0..18beb3b 100644 --- a/hdata/memory.c +++ b/hdata/memory.c @@ -118,8 +118,9 @@ static bool add_address_range(struct dt_node *root, u64 reg[2]; char *name; u32 chip_id; + size_t namesz = sizeof("memory@") + STR_MAX_CHARS(reg[0]); - name = (char*)malloc(sizeof("memory@") + STR_MAX_CHARS(reg[0])); + name = (char*)malloc(namesz); prlog(PR_DEBUG, " Range: 0x%016llx..0x%016llx " "on Chip 0x%x mattr: 0x%x\n", @@ -141,7 +142,7 @@ static bool add_address_range(struct dt_node *root, return true; } } - snprintf(name, sizeof(name), "memory@%llx", (long long)reg[0]); + snprintf(name, namesz, "memory@%llx", (long long)reg[0]); mem = dt_new(root, name); dt_add_property_string(mem, "device_type", "memory"); |