Skip to contentSkip to conversation

Fix sign of sscanf format specifiers

PATCH Applied Stefan Weil 2 participants 2 messages Feb 25, 2012 – Mar 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix sign of sscanf format specifiers

All values read by sscanf are unsigned, so replace %d by %u.

This signed / unsigned mismatch was detected by splint.

---
 cursor.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
cursor.c +2 -1
index efc5917..76e262c 100644
@@ -15,7 +15,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
     uint8_t idx;
 
     /* parse header line: width, height, #colors, #chars */
-    if (sscanf(xpm[line], "%d %d %d %d", &width, &height, &colors, &chars) != 4) {
+    if (sscanf(xpm[line], "%u %u %u %u",
+               &width, &height, &colors, &chars) != 4) {
         fprintf(stderr, "%s: header parse error: \"%s\"\n",
                 __FUNCTION__, xpm[line]);
         return NULL;
Signature · 1 line
1.7.9