[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 21/23] x86/boot: implement early command line parser in C



> +static void vga_parse(const char *cmdline, early_boot_opts_t *ebo)
> +{
> +    const char *c;
> +    int tmp;
> +    size_t la;
> +    static const char empty_chars_comma[] __text = " \n\r\t,";
> +    static const char x[] __text = "x";
> +    static const char vga[] __text = "vga=";
> +    static const char vga_current[] __text = "current";
> +    static const char vga_gfx[] __text = "gfx-";
> +    static const char vga_mode[] __text = "mode-";
> +    static const char vga_text_80x[] __text = "text-80x";
> +
> +    c = find_opt(cmdline, vga, 1);
> +
> +    if ( !c )
> +        return;
> +
> +    ebo->boot_vid_mode = ASK_VGA;
> +
> +    c += strlen_static(vga);
> +    la = strcspn(c, empty_chars_comma);
> +
> +    if ( !strncmp(c, vga_current, max(la, strlen_static(vga_current))) )
> +        ebo->boot_vid_mode = VIDEO_CURRENT_MODE;
> +    else if ( !strncmp(c, vga_text_80x, strlen_static(vga_text_80x)) )
> +    {
> +        c += strlen_static(vga_text_80x);
> +        ebo->boot_vid_mode = rows2vmode(strtoi(c, empty_chars_comma, NULL));
> +    }
> +    else if ( !strncmp(c, vga_gfx, strlen_static(vga_gfx)) )
> +    {
> +        tmp = strtoi(c + strlen_static(vga_gfx), x, &c);
> +
> +        if ( tmp < 0 || tmp > U16_MAX )
> +            return;
> +
> +        ebo->vesa_size[VESA_WIDTH] = tmp;
> +
> +        tmp = strtoi(++c, x, &c);

My ancient OL5 installation:



Choked on that with:
gcc -O1 -fno-omit-frame-pointer -m32 -march=i686 -g -fno-strict-aliasing 
-std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-fno-stack-protector -fno-exceptions -Werror -fno-builtin -msoft-float  -c 
-fpic cmdline.c -o cmdline.o
cc1: warnings being treated as errors
cmdline.c: In function âvga_parseâ:
cmdline.c:363: warning: operation on âcâ may be undefined

Moving the ++c before the tmp assigment make the compiler happy.

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.