Skip to contentSkip to conversation

v2: resolve format string warnings

PATCH In review Ilya Shipitsin 2 participants 2 messages Mar 25, 2017 – Mar 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v2: resolve format string warnings

[src/openvpn/options.c:1163]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'. [src/openvpn/route.c:3187]: (warning) %d in format string (no. 5) requires 'int *' but the argument type is 'unsigned int *'.

v2: use "uint8_t" in options.c, thanks to Gert Doering

---
 src/openvpn/options.c | 4 ++--
 src/openvpn/route.c   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
src/openvpn/options.c +2 -2
index dcb6ecf..6aa72dc 100644
@@ -1147,7 +1147,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren
     const char *cp = str;
     uint8_t *ret = (uint8_t *) gc_malloc(nbytes, true, gc);
     char term = 1;
-    int byte;
+    uint8_t byte;
     char bs[3];
 
     for (i = 0; i < nbytes; ++i)
@@ -1164,7 +1164,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren
         {
             msg(msglevel, "format error in hash fingerprint hex byte: %s", str);
         }
-        ret[i] = (uint8_t)byte;
+        ret[i] = byte;
         term = *cp++;
         if (term != ':' && term != 0)
         {
src/openvpn/route.c +1 -1
index 08998d5..ecfa60f 100644
@@ -3184,7 +3184,7 @@ get_default_gateway(struct route_gateway_info *rgi)
                     unsigned int flags = 0;
                     char name[16];
                     name[0] = 0;
-                    const int np = sscanf(line, "%15s\t%x\t%x\t%x\t%*s\t%*s\t%d\t%x",
+                    const int np = sscanf(line, "%15s\t%x\t%x\t%x\t%*s\t%*s\t%u\t%x",
                                           name,
                                           &net_x,
                                           &gw_x,
Signature · 1 line
2.5.5
#1 lore raw
Quoted 4 lines · Ilya Shipitsin

[src/openvpn/options.c:1163]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'. [src/openvpn/route.c:3187]: (warning) %d in format string (no. 5) requires 'int *' but the argument type is 'unsigned int *'.

v2: use "uint8_t" in options.c, thanks to Gert Doering

just my 2 cents here, but comments like the one above ("v2: ......") should go after the "---" marker, because this way it does not get included in the git message when committed in the repository.

version comments are useful during review to explain what was changed, but not useful to the git history per se.

Quoted 2 lines

---

vX: change X, Y and Z.

Again, this is nothing important, but I thought it could be useful to share.

Cheers,

Signature · 1 line
Antonio Quartulli