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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
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 > argumentsLooks 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
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,
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;
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;
Apparently Analagous Threads
- Patches for VGA-Passthrough XEN 4.2 unstable
- Patches for VGA-Passthrough XEN 4.2 unstable
- [PATCH 0 of 3] Support for VM generation ID save/restore and migrate
- [PATCH 0 of 4] Support for VM generation ID save/restore and migrate
- [PATCH v2 02/03] HVM firmware passthrough libxl support