Patchwork Fix compiler warning on parsing the -usbdevice parameter

login
register
mail settings
Submitter Niels de Vos
Date March 7, 2010, 8:27 p.m.
Message ID <1b51b6f81003071227h2c29dd44y143eb81c7f42b3c4@mail.gmail.com>
Download mbox | patch
Permalink /patch/47094/
State New
Headers show

Comments

Niels de Vos - March 7, 2010, 8:27 p.m.
With the added checks on the parameter for -usbdevice, the following
warning got introduced:

hw/usb-bus.c: In function ‘usbdevice_create’:
hw/usb-bus.c:278: error: assignment discards qualifiers from pointer target type

It is okay to drop the qualifier (const) from the empty string here.

Signed-off-by: Niels de Vos <nixpanic@users.sourceforge.net>
Niels de Vos - March 7, 2010, 8:42 p.m.
Ah, just noticed this warning is only in Jans git... For those who
were wondering :)

Cheers,
Niels

On 3/7/10, Niels de Vos <nixpanic@users.sourceforge.net> wrote:
> With the added checks on the parameter for -usbdevice, the following
> warning got introduced:
>
> hw/usb-bus.c: In function ‘usbdevice_create’:
> hw/usb-bus.c:278: error: assignment discards qualifiers from pointer target
> type
>
> It is okay to drop the qualifier (const) from the empty string here.
>
> Signed-off-by: Niels de Vos <nixpanic@users.sourceforge.net>
>
> diff --git a/hw/usb-bus.c b/hw/usb-bus.c
> index 89e2ea6..d058e14 100644
> --- a/hw/usb-bus.c
> +++ b/hw/usb-bus.c
> @@ -275,7 +275,7 @@ USBDevice *usbdevice_create(const char *cmdline)
>              len = sizeof(driver);
>          pstrcpy(driver, len, cmdline);
>      } else {
> -        params = "";
> +        params = (char*) "";
>          pstrcpy(driver, sizeof(driver), cmdline);
>      }
>
Jan Kiszka - March 8, 2010, 7:58 a.m.
Niels de Vos wrote:
> Ah, just noticed this warning is only in Jans git... For those who
> were wondering :)

Yes, and I forgot to push my fixup. Thanks nevertheless.

Jan

> 
> Cheers,
> Niels
> 
> On 3/7/10, Niels de Vos <nixpanic@users.sourceforge.net> wrote:
>> With the added checks on the parameter for -usbdevice, the following
>> warning got introduced:
>>
>> hw/usb-bus.c: In function ‘usbdevice_create’:
>> hw/usb-bus.c:278: error: assignment discards qualifiers from pointer target
>> type
>>
>> It is okay to drop the qualifier (const) from the empty string here.
>>
>> Signed-off-by: Niels de Vos <nixpanic@users.sourceforge.net>
>>
>> diff --git a/hw/usb-bus.c b/hw/usb-bus.c
>> index 89e2ea6..d058e14 100644
>> --- a/hw/usb-bus.c
>> +++ b/hw/usb-bus.c
>> @@ -275,7 +275,7 @@ USBDevice *usbdevice_create(const char *cmdline)
>>              len = sizeof(driver);
>>          pstrcpy(driver, len, cmdline);
>>      } else {
>> -        params = "";
>> +        params = (char*) "";
>>          pstrcpy(driver, sizeof(driver), cmdline);
>>      }
>>

Patch

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 89e2ea6..d058e14 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -275,7 +275,7 @@  USBDevice *usbdevice_create(const char *cmdline)
             len = sizeof(driver);
         pstrcpy(driver, len, cmdline);
     } else {
-        params = "";
+        params = (char*) "";
         pstrcpy(driver, sizeof(driver), cmdline);
     }