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 <[email protected]>
Reviewed-by: Stefano Stabellini <[email protected]> > --- > CC: Stefano Stabellini <[email protected]> > CC: Julien Grall <[email protected]> > CC: Volodymyr Babchuk <[email protected]> > CC: Bertrand Marquis <[email protected]> > CC: Michal Orzel <[email protected]> > CC: Roberto Bagnara <[email protected]> > CC: Nicola Vetrini <[email protected]> > --- > 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 > >
