Message ID | 20231120224912.1421916-5-andrew.cooper3@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | xen: Enable -Wwrite-strings | expand |
On 20/11/2023 10:49 pm, Andrew Cooper wrote: > GCC complains: > > drivers/char/arm-uart.c: In function 'dt_uart_init': > drivers/char/arm-uart.c:81:17: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] > 81 | options = ""; > | ^ > > The problem is using the options string for both splitting opt_duart, and to > hold a token "" for no options. > > Use two variables; one mutable one one const. This should say "and one const". Fixed up locally. ~Andrew
On Mon, 20 Nov 2023, Andrew Cooper wrote: > GCC complains: > > drivers/char/arm-uart.c: In function 'dt_uart_init': > drivers/char/arm-uart.c:81:17: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] > 81 | options = ""; > | ^ > > The problem is using the options string for both splitting opt_duart, and to > hold a token "" for no options. > > Use two variables; one mutable one one const. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org> > --- > CC: Stefano Stabellini <sstabellini@kernel.org> > CC: Julien Grall <julien@xen.org> > CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> > CC: Bertrand Marquis <bertrand.marquis@arm.com> > CC: Michal Orzel <michal.orzel@amd.com> > CC: Roberto Bagnara <roberto.bagnara@bugseng.com> > CC: Nicola Vetrini <nicola.vetrini@bugseng.com> > --- > xen/drivers/char/arm-uart.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c > index 8098a968c285..91f13a41368d 100644 > --- a/xen/drivers/char/arm-uart.c > +++ b/xen/drivers/char/arm-uart.c > @@ -42,7 +42,8 @@ static void __init dt_uart_init(void) > struct dt_device_node *dev; > int ret; > const char *devpath = opt_dtuart; > - char *options; > + const char *options; > + char *split; > > if ( !console_has("dtuart") ) > return; /* Not for us */ > @@ -74,9 +75,12 @@ static void __init dt_uart_init(void) > return; > } > > - options = strchr(opt_dtuart, ':'); > - if ( options != NULL ) > - *(options++) = '\0'; > + split = strchr(opt_dtuart, ':'); > + if ( split ) > + { > + split[0] = '\0'; > + options = split + 1; > + } > else > options = ""; > > -- > 2.30.2 > >
diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c index 8098a968c285..91f13a41368d 100644 --- a/xen/drivers/char/arm-uart.c +++ b/xen/drivers/char/arm-uart.c @@ -42,7 +42,8 @@ static void __init dt_uart_init(void) struct dt_device_node *dev; int ret; const char *devpath = opt_dtuart; - char *options; + const char *options; + char *split; if ( !console_has("dtuart") ) return; /* Not for us */ @@ -74,9 +75,12 @@ static void __init dt_uart_init(void) return; } - options = strchr(opt_dtuart, ':'); - if ( options != NULL ) - *(options++) = '\0'; + split = strchr(opt_dtuart, ':'); + if ( split ) + { + split[0] = '\0'; + options = split + 1; + } else options = "";
GCC complains: drivers/char/arm-uart.c: In function 'dt_uart_init': drivers/char/arm-uart.c:81:17: error: assignment discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers] 81 | options = ""; | ^ The problem is using the options string for both splitting opt_duart, and to hold a token "" for no options. Use two variables; one mutable one one const. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Stefano Stabellini <sstabellini@kernel.org> CC: Julien Grall <julien@xen.org> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com> CC: Bertrand Marquis <bertrand.marquis@arm.com> CC: Michal Orzel <michal.orzel@amd.com> CC: Roberto Bagnara <roberto.bagnara@bugseng.com> CC: Nicola Vetrini <nicola.vetrini@bugseng.com> --- xen/drivers/char/arm-uart.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)