diff mbox series

hdata/vpd: fix printing (char*)0x00

Message ID 20190618060644.4435-1-stewart@linux.ibm.com
State Accepted
Headers show
Series hdata/vpd: fix printing (char*)0x00 | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (dbf27b6c4af84addb36bd3be34f96580aba9c873)
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present

Commit Message

Stewart Smith June 18, 2019, 6:06 a.m. UTC
GCC9 now catches this bug:

In file included from hdata/vpd.c:17:
In function ‘vpd_vini_parse’,
    inlined from ‘vpd_data_parse’ at hdata/vpd.c:416:3:
/home/stewart/skiboot/include/skiboot.h:93:31: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
   93 | #define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0)
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hdata/vpd.c:390:5: note: in expansion of macro ‘prlog’
  390 |     prlog(PR_WARNING,
      |     ^~~~~
hdata/vpd.c: In function ‘vpd_data_parse’:
hdata/vpd.c:391:46: note: format string is defined here
  391 |           "VPD: CCIN desc not available for: %s\n",
      |                                              ^~
cc1: all warnings being treated as errors

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 hdata/vpd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Stewart Smith June 19, 2019, 4:51 a.m. UTC | #1
Stewart Smith <stewart@linux.ibm.com> writes:
> GCC9 now catches this bug:
>
> In file included from hdata/vpd.c:17:
> In function ‘vpd_vini_parse’,
>     inlined from ‘vpd_data_parse’ at hdata/vpd.c:416:3:
> /home/stewart/skiboot/include/skiboot.h:93:31: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
>    93 | #define prlog(l, f, ...) do { _prlog(l, pr_fmt(f), ##__VA_ARGS__); } while(0)
>       |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hdata/vpd.c:390:5: note: in expansion of macro ‘prlog’
>   390 |     prlog(PR_WARNING,
>       |     ^~~~~
> hdata/vpd.c: In function ‘vpd_data_parse’:
> hdata/vpd.c:391:46: note: format string is defined here
>   391 |           "VPD: CCIN desc not available for: %s\n",
>       |                                              ^~
> cc1: all warnings being treated as errors
>
> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
> ---
>  hdata/vpd.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Merged to master as of ba977f2e4406f9de318afcdf5d666e77585ef269
diff mbox series

Patch

diff --git a/hdata/vpd.c b/hdata/vpd.c
index 129b5062356a..5a01bcc9f6fa 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -328,6 +328,7 @@  static void vpd_vini_parse(struct dt_node *node,
 			   const void *fruvpd, unsigned int fruvpd_sz)
 {
 	const void *kw;
+	const char *desc;
 	uint8_t sz;
 	const struct card_info *cinfo;
 
@@ -381,15 +382,15 @@  static void vpd_vini_parse(struct dt_node *node,
 			dt_add_property_string(node,
 				       "description", cinfo->description);
 		} else {
-			kw = vpd_find(fruvpd, fruvpd_sz, "VINI", "DR", &sz);
-			if (kw) {
+			desc = vpd_find(fruvpd, fruvpd_sz, "VINI", "DR", &sz);
+			if (desc) {
 				dt_add_prop_sanitize_val(node,
-						     "description", kw, sz);
+						     "description", desc, sz);
 			} else {
 				dt_add_property_string(node, "description", "Unknown");
 				prlog(PR_WARNING,
 				      "VPD: CCIN desc not available for: %s\n",
-				      (char *)kw);
+				      (char*)kw);
 			}
 		}
 	}