* Compile error with Ubuntu 11.10
@ 2011-11-30 21:19 Adda Rathbone
2011-12-01 10:47 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Adda Rathbone @ 2011-11-30 21:19 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 674 bytes --]
Hi,
compilation of xen-unstable with a fresh Ubuntu 11.10 x86_64 fails with
following error:
cc1: warnings being treated as errors
libxl_create.c: In function ‘store_libxl_entry’:
libxl_create.c:465: error: format not a string literal and no format
arguments
Steps to reproduce:
- Install Ubuntu 11.10 (
http://www.ubuntu.com/start-download?distro=desktop&bits=64&release=latest)
- sudo apt-get install mercurial libsdl-dev pciutils-dev ncurses-dev
uuid-dev gettext libyajl-dev flex zlib1g-dev libssl-dev xorg-dev bcc bin86
iasl libc6-dev-i386 patch git
- hg clone http://xenbits.xensource.com/xen-unstable.hg
- cd xen-unstable.hg/tools
- make
Adda
[-- Attachment #1.2: Type: text/html, Size: 910 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile error with Ubuntu 11.10
2011-11-30 21:19 Compile error with Ubuntu 11.10 Adda Rathbone
@ 2011-12-01 10:47 ` Ian Campbell
2011-12-01 17:14 ` Ian Jackson
0 siblings, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2011-12-01 10:47 UTC (permalink / raw)
To: Adda Rathbone; +Cc: xen-devel@lists.xensource.com
On Wed, 2011-11-30 at 21:19 +0000, Adda Rathbone wrote:
> Hi,
> compilation of xen-unstable with a fresh Ubuntu 11.10 x86_64 fails
> with following error:
>
> cc1: warnings being treated as errors
> libxl_create.c: In function ‘store_libxl_entry’:
> libxl_create.c:465: error: format not a string literal and no format
> arguments
Looks like Ubuntu has enabled -Wformat-nonliteral by default
I expect that this needs to change to be
return libxl__xs_write(gc, XBT_NULL, path, "%s", libxl__strdup(gc,
libxl_device_model_version_to_string(dm_info->device_model_version)));
(note the additional "%s",)
Can you try that?
The other alternative would be to add -Wnoformat-nonliteral I guess.
It's also not obvious what the strdup is for there.
Ian.
>
> Steps to reproduce:
>
> - Install Ubuntu 11.10
> (http://www.ubuntu.com/start-download?distro=desktop&bits=64&release=latest)
> - sudo apt-get install mercurial libsdl-dev pciutils-dev ncurses-dev
> uuid-dev gettext libyajl-dev flex zlib1g-dev libssl-dev xorg-dev bcc
> bin86 iasl libc6-dev-i386 patch git
> - hg clone http://xenbits.xensource.com/xen-unstable.hg
> - cd xen-unstable.hg/tools
> - make
>
> Adda
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile error with Ubuntu 11.10
2011-12-01 10:47 ` Ian Campbell
@ 2011-12-01 17:14 ` Ian Jackson
2011-12-01 18:01 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Ian Jackson @ 2011-12-01 17:14 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Adda Rathbone
Ian Campbell writes ("Re: [Xen-devel] Compile error with Ubuntu 11.10"):
> I expect that this needs to change to be
> return libxl__xs_write(gc, XBT_NULL, path, "%s", libxl__strdup(gc,
> libxl_device_model_version_to_string(dm_info->device_model_version)));
> (note the additional "%s",)
>
> Can you try that?
Here's a patch which I think should fix this. Adda, can you try it
please ?
libxl: Fix format string problem resulting in compile warning
Fixes:
libxl_create.c:465: error: format not a string literal and no format
arguments
(The warning does not relate to security problem in this case,
because the string erroneously used as a format came from our enum
conversion and is safe.)
Also remove a redundant strdup.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff -r 617b56ea3291 tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Thu Dec 01 16:28:51 2011 +0000
+++ b/tools/libxl/libxl_create.c Thu Dec 01 16:52:30 2011 +0000
@@ -461,8 +461,8 @@ static int store_libxl_entry(libxl__gc *
path = libxl__xs_libxl_path(gc, domid);
path = libxl__sprintf(gc, "%s/dm-version", path);
- return libxl__xs_write(gc, XBT_NULL, path, libxl__strdup(gc,
- libxl_device_model_version_to_string(dm_info->device_model_version)));
+ return libxl__xs_write(gc, XBT_NULL, path, "%s",
+ libxl_device_model_version_to_string(dm_info->device_model_version));
}
static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile error with Ubuntu 11.10
2011-12-01 17:14 ` Ian Jackson
@ 2011-12-01 18:01 ` Ian Campbell
2011-12-02 18:01 ` Andrew Pounce
0 siblings, 1 reply; 5+ messages in thread
From: Ian Campbell @ 2011-12-01 18:01 UTC (permalink / raw)
To: Ian Jackson; +Cc: xen-devel@lists.xensource.com, Adda Rathbone
On Thu, 2011-12-01 at 17:14 +0000, Ian Jackson wrote:
> Ian Campbell writes ("Re: [Xen-devel] Compile error with Ubuntu 11.10"):
> > I expect that this needs to change to be
> > return libxl__xs_write(gc, XBT_NULL, path, "%s", libxl__strdup(gc,
> > libxl_device_model_version_to_string(dm_info->device_model_version)));
> > (note the additional "%s",)
> >
> > Can you try that?
>
> Here's a patch which I think should fix this. Adda, can you try it
> please ?
>
> libxl: Fix format string problem resulting in compile warning
>
> Fixes:
> libxl_create.c:465: error: format not a string literal and no format
> arguments
> (The warning does not relate to security problem in this case,
> because the string erroneously used as a format came from our enum
> conversion and is safe.)
If distros (or gcc) are starting to enable -Wformat-nonliteral (assuming
that is what this is) by default perhaps we should preemptively set it
ourselves?
Setting it found one other instance of a weird strdup (actually a
sprintf of a string we just sprintf'd). but otherwise it seems to work.
8<-------------------------------
libxl: build with -Wformat-nonliteral
Fix the remaining issue that this shows up.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r 20c1c0ff9677 tools/libxl/Makefile
--- a/tools/libxl/Makefile Thu Dec 01 12:24:06 2011 +0100
+++ b/tools/libxl/Makefile Thu Dec 01 17:59:25 2011 +0000
@@ -11,7 +11,7 @@ MINOR = 0
XLUMAJOR = 1.0
XLUMINOR = 0
-CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
+CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations -Wformat-nonliteral
CFLAGS += -I. -fPIC
ifeq ($(CONFIG_Linux),y)
static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
diff -r 20c1c0ff9677 tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Thu Dec 01 12:24:06 2011 +0100
+++ b/tools/libxl/libxl_device.c Thu Dec 01 17:59:25 2011 +0000
@@ -516,7 +516,7 @@ int libxl__devices_destroy(libxl__gc *gc
for (j = 0; j < num_devs; j++) {
path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s/backend",
domid, kinds[i], devs[j]);
- path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, path));
+ path = libxl__xs_read(gc, XBT_NULL, path);
if (path && libxl__parse_backend_path(gc, path, &dev) == 0) {
dev.domid = domid;
dev.kind = kind;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Compile error with Ubuntu 11.10
2011-12-01 18:01 ` Ian Campbell
@ 2011-12-02 18:01 ` Andrew Pounce
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Pounce @ 2011-12-02 18:01 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Ian Jackson
IanC - I have tried the two patches that you provided and this appears to fix this problem in that I can now compile on my ubuntu 11.10 desktop.
libxl: Fix format string problem resulting in compile warning
libxl: build with -Wformat-nonliteral
-Andrew
The combined patch is (against http://xenbits.xen.org/xen-unstable.hg ):-
diff -r 62ff6a318c5d tools/libxl/Makefile
--- a/tools/libxl/Makefile Wed Nov 30 16:59:58 2011 -0800
+++ b/tools/libxl/Makefile Fri Dec 02 17:49:57 2011 +0000
@@ -11,7 +11,7 @@
XLUMAJOR = 1.0
XLUMINOR = 0
-CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations
+CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations -Wformat-nonliteral
CFLAGS += -I. -fPIC
ifeq ($(CONFIG_Linux),y)
diff -r 62ff6a318c5d tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Wed Nov 30 16:59:58 2011 -0800
+++ b/tools/libxl/libxl_create.c Fri Dec 02 17:49:57 2011 +0000
@@ -461,8 +461,8 @@
path = libxl__xs_libxl_path(gc, domid);
path = libxl__sprintf(gc, "%s/dm-version", path);
- return libxl__xs_write(gc, XBT_NULL, path, libxl__strdup(gc,
- libxl_device_model_version_to_string(dm_info->device_model_version)));
+ return libxl__xs_write(gc, XBT_NULL, path, "%s",
+ libxl_device_model_version_to_string(dm_info->device_model_version));
}
static int do_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
diff -r 62ff6a318c5d tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Wed Nov 30 16:59:58 2011 -0800
+++ b/tools/libxl/libxl_device.c Fri Dec 02 17:49:57 2011 +0000
@@ -516,7 +516,7 @@
for (j = 0; j < num_devs; j++) {
path = libxl__sprintf(gc, "/local/domain/%d/device/%s/%s/backend",
domid, kinds[i], devs[j]);
- path = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, path));
+ path = libxl__xs_read(gc, XBT_NULL, path);
if (path && libxl__parse_backend_path(gc, path, &dev) == 0) {
dev.domid = domid;
dev.kind = kind;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-12-02 18:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-30 21:19 Compile error with Ubuntu 11.10 Adda Rathbone
2011-12-01 10:47 ` Ian Campbell
2011-12-01 17:14 ` Ian Jackson
2011-12-01 18:01 ` Ian Campbell
2011-12-02 18:01 ` Andrew Pounce
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.