All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mini-os: Fix stubdom build failures on gcc 4.8
@ 2014-01-22 17:12 xenmail43267
  2014-01-22 17:19 ` Samuel Thibault
  0 siblings, 1 reply; 3+ messages in thread
From: xenmail43267 @ 2014-01-22 17:12 UTC (permalink / raw)
  To: xen-devel
  Cc: Ian.Campbell, andrew.cooper3, Mike Neilsen, stefano.stabellini,
	samuel.thibault, alex.sharp

From: Mike Neilsen <mneilsen@acm.org>

This is a fix for bug 35:
http://bugs.xenproject.org/xen/bug/35

This bug report describes several format string mismatches which prevent
building the stubdom target in Xen 4.3 and Xen 4.4-rc2 on gcc 4.8.  This is a
copy of Alex Sharp's original patch with Andrew Cooper's recommendation applied
to extras/mini-os/xenbus/xenbus.c to avoid stack corruption.

Tested on x86_64 gcc Ubuntu/Linaro 4.8.1-10ubuntu9.

Signed-off-by: Mike Neilsen <mneilsen@acm.org>
---
 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(-)

diff --git a/extras/mini-os/fbfront.c b/extras/mini-os/fbfront.c
index 1e01513..9cc07b4 100644
--- a/extras/mini-os/fbfront.c
+++ b/extras/mini-os/fbfront.c
@@ -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;
diff --git a/extras/mini-os/pcifront.c b/extras/mini-os/pcifront.c
index 16a4b49..ce5180c 100644
--- a/extras/mini-os/pcifront.c
+++ b/extras/mini-os/pcifront.c
@@ -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;
diff --git a/extras/mini-os/xenbus/xenbus.c b/extras/mini-os/xenbus/xenbus.c
index ee1691b..c5d9b02 100644
--- a/extras/mini-os/xenbus/xenbus.c
+++ b/extras/mini-os/xenbus/xenbus.c
@@ -15,6 +15,7 @@
  *
  ****************************************************************************
  **/
+#include <inttypes.h>
 #include <mini-os/os.h>
 #include <mini-os/mm.h>
 #include <mini-os/traps.h>
@@ -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;
 }
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mini-os: Fix stubdom build failures on gcc 4.8
  2014-01-22 17:12 [PATCH] mini-os: Fix stubdom build failures on gcc 4.8 xenmail43267
@ 2014-01-22 17:19 ` Samuel Thibault
  2014-01-23 10:32   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Thibault @ 2014-01-22 17:19 UTC (permalink / raw)
  To: xenmail43267
  Cc: Ian.Campbell, andrew.cooper3, xen-devel, Mike Neilsen,
	stefano.stabellini, alex.sharp

xenmail43267@gmail.com, le Wed 22 Jan 2014 11:12:49 -0600, a écrit :
> index 16a4b49..ce5180c 100644
> --- a/extras/mini-os/pcifront.c
> +++ b/extras/mini-os/pcifront.c
> @@ -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;

Rather make fun an unsigned int, there is no reason why it should be an
unsigned long, I'm still wondering where that comes from.

There rest seems OK to me.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mini-os: Fix stubdom build failures on gcc 4.8
  2014-01-22 17:19 ` Samuel Thibault
@ 2014-01-23 10:32   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2014-01-23 10:32 UTC (permalink / raw)
  To: Samuel Thibault
  Cc: andrew.cooper3, xen-devel, Mike Neilsen, stefano.stabellini,
	alex.sharp, xenmail43267

On Wed, 2014-01-22 at 18:19 +0100, Samuel Thibault wrote:
> xenmail43267@gmail.com, le Wed 22 Jan 2014 11:12:49 -0600, a écrit :
> > index 16a4b49..ce5180c 100644
> > --- a/extras/mini-os/pcifront.c
> > +++ b/extras/mini-os/pcifront.c
> > @@ -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;
> 
> Rather make fun an unsigned int, there is no reason why it should be an
> unsigned long, I'm still wondering where that comes from.

This whole file has an interesting mix of unsigned long vs unsigned int
fun (it seems pretty consistent about dom, bus & slot). The use of
unsigned long seem to leak into the external interface to this file as
well.

For 4.4 this change is probably more appropriate at this juncture,
rather than shaving the yakk.

> 
> There rest seems OK to me.



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-23 10:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 17:12 [PATCH] mini-os: Fix stubdom build failures on gcc 4.8 xenmail43267
2014-01-22 17:19 ` Samuel Thibault
2014-01-23 10:32   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.