* [PATCH net-next 03/11] rsxx: remove extraneous 'const' qualifier [not found] <20201026213040.3889546-1-arnd@kernel.org> @ 2020-10-26 21:29 ` Arnd Bergmann 2020-10-29 19:34 ` Nick Desaulniers 0 siblings, 1 reply; 3+ messages in thread From: Arnd Bergmann @ 2020-10-26 21:29 UTC (permalink / raw) To: Joshua Morris, Philip Kelleher Cc: Arnd Bergmann, Jens Axboe, Nathan Chancellor, Nick Desaulniers, Gustavo A. R. Silva, Bjorn Helgaas, linux-block, linux-kernel, clang-built-linux From: Arnd Bergmann <arnd@arndb.de> The returned string from rsxx_card_state_to_str is 'const', but the other qualifier doesn't change anything here except causing a warning with 'clang -Wextra': drivers/block/rsxx/core.c:393:21: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] static const char * const rsxx_card_state_to_str(unsigned int state) Fixes: f37912039eb0 ("block: IBM RamSan 70/80 trivial changes.") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/block/rsxx/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index 63f549889f87..d0af46d7b681 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c @@ -390,7 +390,7 @@ static irqreturn_t rsxx_isr(int irq, void *pdata) } /*----------------- Card Event Handler -------------------*/ -static const char * const rsxx_card_state_to_str(unsigned int state) +static const char *rsxx_card_state_to_str(unsigned int state) { static const char * const state_strings[] = { "Unknown", "Shutdown", "Starting", "Formatting", -- 2.27.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 03/11] rsxx: remove extraneous 'const' qualifier 2020-10-26 21:29 ` [PATCH net-next 03/11] rsxx: remove extraneous 'const' qualifier Arnd Bergmann @ 2020-10-29 19:34 ` Nick Desaulniers 2020-10-29 21:35 ` Joe Perches 0 siblings, 1 reply; 3+ messages in thread From: Nick Desaulniers @ 2020-10-29 19:34 UTC (permalink / raw) To: Arnd Bergmann Cc: Joshua Morris, Philip Kelleher, Arnd Bergmann, Jens Axboe, Nathan Chancellor, Gustavo A. R. Silva, Bjorn Helgaas, linux-block, LKML, clang-built-linux On Mon, Oct 26, 2020 at 2:31 PM Arnd Bergmann <arnd@kernel.org> wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > The returned string from rsxx_card_state_to_str is 'const', > but the other qualifier doesn't change anything here except > causing a warning with 'clang -Wextra': > > drivers/block/rsxx/core.c:393:21: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] > static const char * const rsxx_card_state_to_str(unsigned int state) > > Fixes: f37912039eb0 ("block: IBM RamSan 70/80 trivial changes.") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > --- > drivers/block/rsxx/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c > index 63f549889f87..d0af46d7b681 100644 > --- a/drivers/block/rsxx/core.c > +++ b/drivers/block/rsxx/core.c > @@ -390,7 +390,7 @@ static irqreturn_t rsxx_isr(int irq, void *pdata) > } > > /*----------------- Card Event Handler -------------------*/ > -static const char * const rsxx_card_state_to_str(unsigned int state) > +static const char *rsxx_card_state_to_str(unsigned int state) > { > static const char * const state_strings[] = { > "Unknown", "Shutdown", "Starting", "Formatting", > -- > 2.27.0 > -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next 03/11] rsxx: remove extraneous 'const' qualifier 2020-10-29 19:34 ` Nick Desaulniers @ 2020-10-29 21:35 ` Joe Perches 0 siblings, 0 replies; 3+ messages in thread From: Joe Perches @ 2020-10-29 21:35 UTC (permalink / raw) To: Nick Desaulniers, Arnd Bergmann Cc: Joshua Morris, Philip Kelleher, Arnd Bergmann, Jens Axboe, Nathan Chancellor, Gustavo A. R. Silva, Bjorn Helgaas, linux-block, LKML, clang-built-linux On Thu, 2020-10-29 at 12:34 -0700, Nick Desaulniers wrote: > On Mon, Oct 26, 2020 at 2:31 PM Arnd Bergmann <arnd@kernel.org> wrote: > > > > From: Arnd Bergmann <arnd@arndb.de> > > > > The returned string from rsxx_card_state_to_str is 'const', > > but the other qualifier doesn't change anything here except > > causing a warning with 'clang -Wextra': > > > > drivers/block/rsxx/core.c:393:21: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] > > static const char * const rsxx_card_state_to_str(unsigned int state) > > > > Fixes: f37912039eb0 ("block: IBM RamSan 70/80 trivial changes.") > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Perhaps this should also be converted to avoid any possible dereference of strings with an invalid state. --- drivers/block/rsxx/core.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index 8799e3bab067..f50b00b4887f 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c @@ -390,15 +390,27 @@ static irqreturn_t rsxx_isr(int irq, void *pdata) } /*----------------- Card Event Handler -------------------*/ -static const char * const rsxx_card_state_to_str(unsigned int state) +static const char *rsxx_card_state_to_str(unsigned int state) { static const char * const state_strings[] = { - "Unknown", "Shutdown", "Starting", "Formatting", - "Uninitialized", "Good", "Shutting Down", - "Fault", "Read Only Fault", "dStroying" + "Unknown", /* no bit set - all zeros */ + "Shutdown", /* BIT(0) */ + "Starting", /* BIT(1) */ + "Formatting", /* BIT(2) */ + "Uninitialized", /* BIT(3) */ + "Good", /* BIT(4) */ + "Shutting Down", /* BIT(5) */ + "Fault", /* BIT(6) */ + "Read Only Fault", /* BIT(7) */ + "Destroying" /* BIT(8) */ }; - return state_strings[ffs(state)]; + int i = ffs(state); + + if (i >= ARRAY_SIZE(state_strings)) + return "Invalid state"; + + return state_strings[i]; } static void card_state_change(struct rsxx_cardinfo *card, ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-29 21:35 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20201026213040.3889546-1-arnd@kernel.org> 2020-10-26 21:29 ` [PATCH net-next 03/11] rsxx: remove extraneous 'const' qualifier Arnd Bergmann 2020-10-29 19:34 ` Nick Desaulniers 2020-10-29 21:35 ` Joe Perches
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).