Skip to contentSkip to conversation

lscpu: fix compiler warnings

PATCH In review Davidlohr Bueso 2 participants 2 messages Jan 4, 2012 – Jan 5, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lscpu: fix compiler warnings

From: Davidlohr Bueso <[email protected]>

The string format is not being passed triggering:

lscpu.c: In function ‘read_hypervisor’:
lscpu.c:545:4: warning: format not a string literal and no format arguments lscpu.c: In function ‘get_cell_header’:
lscpu.c:904:2: warning: format not a string literal and no format arguments lscpu.c:904:2: warning: format not a string literal and no format arguments

---
 sys-utils/lscpu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sys-utils/lscpu.c +2 -2
index 0a7841d..5214a12 100644
@@ -542,7 +542,7 @@ read_hypervisor(struct lscpu_desc *desc)
 			str = strchr(buf, ':');
 			if (!str)
 				continue;
-			if (asprintf(&str, str + 1) == -1)
+			if (asprintf(&str, "%s", str + 1) == -1)
 				errx(EXIT_FAILURE, _("failed to allocate memory"));
 			/* remove leading, trailing and repeating whitespace */
 			while (*str == ' ')
@@ -901,7 +901,7 @@ get_cell_header(struct lscpu_desc *desc, int col,
 		if (desc->ncaches)
 			return buf;
 	}
-	snprintf(buf, bufsz, coldescs[col].name);
+	snprintf(buf, bufsz, "%s", coldescs[col].name);
 	return buf;
 }
 
Signature · 1 line
1.7.4.1
maintainer
#1 lore raw
Quoted 2 lines · Davidlohr Bueso
 sys-utils/lscpu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Good catch. Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com