WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] Re: c/s 23253:a3db6b91f32d causes build failure with gcc

To: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] Re: c/s 23253:a3db6b91f32d causes build failure with gcc 4.4.3-4ubuntu5
From: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Date: Fri, 6 May 2011 13:50:45 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 06 May 2011 05:51:18 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=Kb5xDNog4PdiihVvEI3TlBKjU9V4BvWVhR0GSsXMgfE=; b=T9aD+eV3MlICWfRABmOwtHRBmZUAMiEWvIA6ACfaaXNrdr7xtePN0gPIojrQ/ORwvD I+poX6e5JmQYCBWPCC9WZLIrQw/kdfB7mu69eUjCKlOvPLrUkKKcToyQASebieZZEOpP 2h8DuNqC0hRG0RydpfOLT5H8WXMiLvfyLqayM=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=FrVIt8m5mvnxeJNZqX+VRjEpRA8zdcGJaX+l9k1IcEGaz12qC3ycfUKNaF86jDDcyI /u8lRhqPKeBHULOPvB4iyHAUsL7hCt5pjcbYYMAdUURRzV3iLXMf+rr3D1NrflTQyj0L gOo3OtJggwY2kKZ4IfIrQIiMNuEP1Ib79F+nA=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1304685218.26692.154.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <BANLkTikTSv+Ab--C5AQi_ub1SFaG2HfBEg@xxxxxxxxxxxxxx> <1304685218.26692.154.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Unfortunately not.

Looks like we could either make libxl__domain_bios() a #define (not
tested), or make the argument "%s" (which seems to work, patch
attached).

Adding a format string of just a string seems kind of dumb, but I
don't think this is a really hot path...

 -George


On Fri, May 6, 2011 at 1:33 PM, Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx> wrote:
> On Fri, 2011-05-06 at 12:14 +0100, George Dunlap wrote:
>
>> The line in question is:
>>     libxl__xs_write(gc, XBT_NULL, libxl__sprintf(gc, "%s/bios", path),
>>                     libxl__domain_bios(gc, info));
>>
>> Looks like libxl__xs_write() is expecting the 4th argument to be a
>> format string...?
>
> Yes, and hence it needs to be a const char * not a char *, so we should
> change both libxl__domain_bios and libxl__xs_write I think.
>
> Does this help? It works for me, but my compiler doesn't appear to
> complain in this way...
>
> Ian.
>
> 8<-------------------------------------------
>
> # HG changeset patch
> # User Ian Campbell <ian.campbell@xxxxxxxxxx>
> # Date 1304685175 -3600
> # Node ID 4e5487962178e7affd7d7d0341a90dde8c60915e
> # Parent  faca1c90188e536eb0f02992c766d06759be376f
> libxl: libxl__xs_write format string should be const.
>
> George Dunlap reports that gcc 4.4.3 complains:
>        libxl_dm.c: In function libxl__create_device_mode:
>        libxl_dm.c:776: error: format not a string literal and no format 
> arguments
> And indeed the format argument here is a char * from libxl__domain_bios().
>
> Make the argument to libxl__xs_write a const char * and change
> libxl__domain_bios to return a const char too.
>
> Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
>
> diff -r faca1c90188e -r 4e5487962178 tools/libxl/libxl_dm.c
> --- a/tools/libxl/libxl_dm.c    Fri May 06 13:14:24 2011 +0100
> +++ b/tools/libxl/libxl_dm.c    Fri May 06 13:32:55 2011 +0100
> @@ -68,12 +68,12 @@ const char *libxl__domain_device_model(l
>     return dm;
>  }
>
> -static char *libxl__domain_bios(libxl__gc *gc,
> +static const char *libxl__domain_bios(libxl__gc *gc,
>                                 libxl_device_model_info *info)
>  {
>     switch (info->device_model_version) {
> -    case 1: return libxl__strdup(gc, "rombios");
> -    case 2: return libxl__strdup(gc, "seabios");
> +    case 1: return "rombios";
> +    case 2: return "seabios";
>     default:return NULL;
>     }
>  }
> diff -r faca1c90188e -r 4e5487962178 tools/libxl/libxl_internal.h
> --- a/tools/libxl/libxl_internal.h      Fri May 06 13:14:24 2011 +0100
> +++ b/tools/libxl/libxl_internal.h      Fri May 06 13:32:55 2011 +0100
> @@ -153,7 +153,7 @@ _hidden char **libxl__xs_kvs_of_flexarra
>  _hidden int libxl__xs_writev(libxl__gc *gc, xs_transaction_t t,
>                     char *dir, char **kvs);
>  _hidden int libxl__xs_write(libxl__gc *gc, xs_transaction_t t,
> -                   char *path, char *fmt, ...) PRINTF_ATTRIBUTE(4, 5);
> +                   char *path, const char *fmt, ...) PRINTF_ATTRIBUTE(4, 5);
>    /* Each fn returns 0 on success.
>     * On error: returns -1, sets errno (no logging) */
>
> diff -r faca1c90188e -r 4e5487962178 tools/libxl/libxl_xshelp.c
> --- a/tools/libxl/libxl_xshelp.c        Fri May 06 13:14:24 2011 +0100
> +++ b/tools/libxl/libxl_xshelp.c        Fri May 06 13:32:55 2011 +0100
> @@ -69,7 +69,7 @@ int libxl__xs_writev(libxl__gc *gc, xs_t
>  }
>
>  int libxl__xs_write(libxl__gc *gc, xs_transaction_t t,
> -                   char *path, char *fmt, ...)
> +                   char *path, const char *fmt, ...)
>  {
>     libxl_ctx *ctx = libxl__gc_owner(gc);
>     char *s;
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
>

Attachment: build-fix.diff
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel