Skip to contentSkip to conversation

Fix various format string mismatches.

PATCH In review Alex Sharp 3 participants 6 messages Oct 31, 2013 – Nov 19, 2013

lore
Share & tools
lore

Alex Sharp

author
#0 lore raw

PATCH 1/1 Fix various format string mismatches.

---
 extras/mini-os/fbfront.c       | 4 ++--
 extras/mini-os/pcifront.c      | 2 +-
 extras/mini-os/xenbus/xenbus.c | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
extras/mini-os/fbfront.c +2 -2
index a276193..3c618b0 100644
@@ -105,7 +105,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
@@ -468,7 +468,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
extras/mini-os/pcifront.c +1 -1
index 7838021..c3d833e 100644
@@ -424,7 +424,7 @@ int pcifront_physical_to_virtual (struct pcifront_dev *dev,
                 continue;
             }
 
-            if (sscanf(s, "%x:%x:%x.%x", dom, bus, slot, fun) != 4) {
+            if (sscanf(s, "%x:%x:%x.%lx", dom, bus, slot, fun) != 4) {
                 printk("\"%s\" does not look like a PCI device address\n", s);
                 free(s);
                 continue;
extras/mini-os/xenbus/xenbus.c +3 -2
index ee1691b..717bba9 100644
@@ -27,6 +27,7 @@
 #include <xen/io/xs_wire.h>
 #include <mini-os/spinlock.h>
 #include <mini-os/xmalloc.h>
+#include <inttypes.h>
 
 #define min(x,y) ({                       \
         typeof(x) tmpx = (x);                 \
@@ -672,7 +673,7 @@ char *xenbus_transaction_start(xenbus_transaction_t *xbt)
     err = errmsg(rep);
     if (err)
 	return err;
-    sscanf((char *)(rep + 1), "%u", xbt);
+    sscanf((char *)(rep + 1), "%lu", xbt);
     free(rep);
     return NULL;
 }
@@ -769,7 +770,7 @@ domid_t xenbus_get_self_id(void)
     domid_t ret;
 
     BUG_ON(xenbus_read(XBT_NIL, "domid", &dom_id));
-    sscanf(dom_id, "%d", &ret);
+    sscanf(dom_id, "%"SCNd16, &ret);
 
     return ret;
 }
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 1 line · Alex Sharp

Are you sure this patch is against the staging branch of xen.git?

Your changes to pcifront would appear to conflict.

~Andrew

Quoted 71 lines
---
 extras/mini-os/fbfront.c       | 4 ++--
 extras/mini-os/pcifront.c      | 2 +-
 extras/mini-os/xenbus/xenbus.c | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
extras/mini-os/fbfront.c +2 -2
index a276193..3c618b0 100644
@@ -105,7 +105,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
@@ -468,7 +468,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
extras/mini-os/pcifront.c +1 -1
index 7838021..c3d833e 100644
@@ -424,7 +424,7 @@ int pcifront_physical_to_virtual (struct pcifront_dev *dev,
                 continue;
             }
 
-            if (sscanf(s, "%x:%x:%x.%x", dom, bus, slot, fun) != 4) {
+            if (sscanf(s, "%x:%x:%x.%lx", dom, bus, slot, fun) != 4) {
                 printk("\"%s\" does not look like a PCI device address\n", s);
                 free(s);
                 continue;
extras/mini-os/xenbus/xenbus.c +3 -2
index ee1691b..717bba9 100644
@@ -27,6 +27,7 @@
 #include <xen/io/xs_wire.h>
 #include <mini-os/spinlock.h>
 #include <mini-os/xmalloc.h>
+#include <inttypes.h>
 
 #define min(x,y) ({                       \
         typeof(x) tmpx = (x);                 \
@@ -672,7 +673,7 @@ char *xenbus_transaction_start(xenbus_transaction_t *xbt)
     err = errmsg(rep);
     if (err)
 	return err;
-    sscanf((char *)(rep + 1), "%u", xbt);
+    sscanf((char *)(rep + 1), "%lu", xbt);
     free(rep);
     return NULL;
 }
@@ -769,7 +770,7 @@ domid_t xenbus_get_self_id(void)
     domid_t ret;
 
     BUG_ON(xenbus_read(XBT_NIL, "domid", &dom_id));
-    sscanf(dom_id, "%d", &ret);
+    sscanf(dom_id, "%"SCNd16, &ret);
 
     return ret;
 }
#2 lore raw
Quoted 7 lines · Andrew Cooper
Quoted 1 line · Alex Sharp

Are you sure this patch is against the staging branch of xen.git?

Your changes to pcifront would appear to conflict.

~Andrew

Wait sorry - I was looking at the wrong bit. My mistake

I would however agree with Samuel that the correct fix would be to change unsigned long *fun to unsigned int *fun.

~Andrew

Quoted 77 lines
Quoted 64 lines
---
 extras/mini-os/fbfront.c       | 4 ++--
 extras/mini-os/pcifront.c      | 2 +-
 extras/mini-os/xenbus/xenbus.c | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
extras/mini-os/fbfront.c +2 -2
index a276193..3c618b0 100644
@@ -105,7 +105,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
@@ -468,7 +468,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
extras/mini-os/pcifront.c +1 -1
index 7838021..c3d833e 100644
@@ -424,7 +424,7 @@ int pcifront_physical_to_virtual (struct pcifront_dev *dev,
                 continue;
             }
 
-            if (sscanf(s, "%x:%x:%x.%x", dom, bus, slot, fun) != 4) {
+            if (sscanf(s, "%x:%x:%x.%lx", dom, bus, slot, fun) != 4) {
                 printk("\"%s\" does not look like a PCI device address\n", s);
                 free(s);
                 continue;
extras/mini-os/xenbus/xenbus.c +2 -1
index ee1691b..717bba9 100644
@@ -27,6 +27,7 @@
 #include <xen/io/xs_wire.h>
 #include <mini-os/spinlock.h>
 #include <mini-os/xmalloc.h>
+#include <inttypes.h>
 
 #define min(x,y) ({                       \
         typeof(x) tmpx = (x);                 \
@@ -672,7 +673,7 @@ char *xenbus_transaction_start(xenbus_transaction_t *xbt)
     err = errmsg(rep);
     if (err)
 	return err;
-    sscanf((char *)(rep + 1), "%u", xbt);
+    sscanf((char *)(rep + 1), "%lu", xbt);
     free(rep);
     return NULL;
 }

extras/mini-os/xenbus/xenbus.c domid_t xenbus_get_self_id(void) · line 776

Quoted 8 lines
extras/mini-os/xenbus/xenbus.c +1 -1
@@ -769,7 +770,7 @@ domid_t xenbus_get_self_id(void)
     domid_t ret;
 
     BUG_ON(xenbus_read(XBT_NIL, "domid", &dom_id));
-    sscanf(dom_id, "%d", &ret);
+    sscanf(dom_id, "%"SCNd16, &ret);
 
     return ret;
 }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#3 lore raw
In reply to Andrew Cooper

Just to double check, am I basing this patch off branch staging on git://xenbits.xen.org/xen.git ? (Last commit 1e2bf05ec37cf04b0e01585eae524509179f165e) or branch staging-4.3?

________________________________________
From: Andrew Cooper [[email protected]]
Sent: Thursday, October 31, 2013 11:01 AM
To: Alex Sharp
Cc: [email protected]
Subject: Re: [Xen-devel] [PATCH] Fix various format string mismatches.

Quoted 1 line · Alex Sharp

Are you sure this patch is against the staging branch of xen.git?

Your changes to pcifront would appear to conflict.

~Andrew

Quoted 71 lines
---
 extras/mini-os/fbfront.c       | 4 ++--
 extras/mini-os/pcifront.c      | 2 +-
 extras/mini-os/xenbus/xenbus.c | 5 +++--
 3 files changed, 6 insertions(+), 5 deletions(-)
extras/mini-os/fbfront.c +2 -2
index a276193..3c618b0 100644
@@ -105,7 +105,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
@@ -468,7 +468,7 @@ again:
         free(err);
     }
 
-    err = xenbus_printf(xbt, nodename, "page-ref","%u", virt_to_mfn(s));
+    err = xenbus_printf(xbt, nodename, "page-ref","%lu", virt_to_mfn(s));
     if (err) {
         message = "writing page-ref";
         goto abort_transaction;
extras/mini-os/pcifront.c +1 -1
index 7838021..c3d833e 100644
@@ -424,7 +424,7 @@ int pcifront_physical_to_virtual (struct pcifront_dev *dev,
                 continue;
             }
 
-            if (sscanf(s, "%x:%x:%x.%x", dom, bus, slot, fun) != 4) {
+            if (sscanf(s, "%x:%x:%x.%lx", dom, bus, slot, fun) != 4) {
                 printk("\"%s\" does not look like a PCI device address\n", s);
                 free(s);
                 continue;
extras/mini-os/xenbus/xenbus.c +3 -2
index ee1691b..717bba9 100644
@@ -27,6 +27,7 @@
 #include <xen/io/xs_wire.h>
 #include <mini-os/spinlock.h>
 #include <mini-os/xmalloc.h>
+#include <inttypes.h>
 
 #define min(x,y) ({                       \
         typeof(x) tmpx = (x);                 \
@@ -672,7 +673,7 @@ char *xenbus_transaction_start(xenbus_transaction_t *xbt)
     err = errmsg(rep);
     if (err)
      return err;
-    sscanf((char *)(rep + 1), "%u", xbt);
+    sscanf((char *)(rep + 1), "%lu", xbt);
     free(rep);
     return NULL;
 }
@@ -769,7 +770,7 @@ domid_t xenbus_get_self_id(void)
     domid_t ret;
 
     BUG_ON(xenbus_read(XBT_NIL, "domid", &dom_id));
-    sscanf(dom_id, "%d", &ret);
+    sscanf(dom_id, "%"SCNd16, &ret);
 
     return ret;
 }
#4 lore raw
Quoted 1 line · Alex Sharp

Just to double check, am I basing this patch off branch staging on git://xenbits.xen.org/xen.git ? (Last commit 1e2bf05ec37cf04b0e01585eae524509179f165e) or branch staging-4.3?

All development happens against staging, even work like this.

It will then be backported by a stable tree maintainer. Strictly speaking the maintainer gets final say on whether something justifies backporting (subject to persuasive arguments one way or another), but this hopefully uncontentious and obviously a GoodThing.

~Andrew

#5 lore raw
Quoted 4 lines · Andrew Cooper
Quoted 1 line · Alex Sharp

Just to double check, am I basing this patch off branch staging on git://xenbits.xen.org/xen.git ? (Last commit 1e2bf05ec37cf04b0e01585eae524509179f165e) or branch staging-4.3?

All development happens against staging, even work like this.

Alex, was there ever an update to this patch? If so then I'm afraid I must have missed it. Sorry.

Ian.