Message ID | 20220722163417.1119334-1-prestwoj@gmail.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [1/7] wiphy: fix runtime error from bit shift | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
prestwoj/iwd-alpine-ci-fetch | success | Fetch PR |
prestwoj/iwd-ci-fetch | success | Fetch PR |
prestwoj/iwd-ci-gitlint | fail | [7/7] station: do full passive scan if 6GHz is supported but disabled. 1: T3 Title has trailing punctuation (.): "[7/7] station: do full passive scan if 6GHz is supported but disabled." |
prestwoj/iwd-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-alpine-ci-makedistcheck | success | Make Distcheck |
prestwoj/iwd-ci-build | success | Build - Configure |
prestwoj/iwd-alpine-ci-build | success | Build - Configure |
prestwoj/iwd-ci-clang | success | clang PASS |
prestwoj/iwd-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-ci-makecheck | success | Make Check |
prestwoj/iwd-alpine-ci-makecheckvalgrind | success | Make Check w/Valgrind |
prestwoj/iwd-alpine-ci-makecheck | success | Make Check |
prestwoj/iwd-ci-incremental_build | success | Incremental Build with patches |
prestwoj/iwd-alpine-ci-incremental_build | success | Incremental Build with patches |
prestwoj/iwd-ci-testrunner | success | test-runner PASS |
Hi James, On 7/22/22 11:34, James Prestwood wrote: > The compiler treated the '1' as an int type which was not big enough > to hold a bit shift of 31. Change this to 1ULL to fix the error: > > runtime error: left shift of 1 by 31 places cannot be represented in type 'int' > --- > src/wiphy.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/wiphy.c b/src/wiphy.c > index 09b99fb2..4b9e130a 100644 > --- a/src/wiphy.c > +++ b/src/wiphy.c > @@ -957,7 +957,7 @@ static void wiphy_print_he_capabilities(struct band *band, > uint8_t width_set = bit_field(he_cap->he_phy_capa[0], 1, 7); > > for (i = 0; i < 32; i++) { > - if (!(he_cap->iftypes & (1 << i))) > + if (!(he_cap->iftypes & (1ULL << i))) That seems overkill, wouldn't 1U be enough? Or just make 'i' unsigned? Have you looked into using wiphy_get_supported_iftypes() here instead? > continue; > > if (L_WARN_ON(s >= type_buf + sizeof(type_buf))) Regards, -Denis
On Fri, 2022-07-22 at 12:04 -0500, Denis Kenzior wrote: > Hi James, > > On 7/22/22 11:34, James Prestwood wrote: > > The compiler treated the '1' as an int type which was not big > > enough > > to hold a bit shift of 31. Change this to 1ULL to fix the error: > > > > runtime error: left shift of 1 by 31 places cannot be represented > > in type 'int' > > --- > > src/wiphy.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/wiphy.c b/src/wiphy.c > > index 09b99fb2..4b9e130a 100644 > > --- a/src/wiphy.c > > +++ b/src/wiphy.c > > @@ -957,7 +957,7 @@ static void wiphy_print_he_capabilities(struct > > band *band, > > uint8_t width_set = bit_field(he_cap->he_phy_capa[0], 1, > > 7); > > > > for (i = 0; i < 32; i++) { > > - if (!(he_cap->iftypes & (1 << i))) > > + if (!(he_cap->iftypes & (1ULL << i))) > > That seems overkill, wouldn't 1U be enough? Or just make 'i' > unsigned? > > Have you looked into using wiphy_get_supported_iftypes() here > instead? Wasn't aware of that. Thats exactly what I need :) > > > continue; > > > > if (L_WARN_ON(s >= type_buf + sizeof(type_buf))) > > Regards, > -Denis
diff --git a/src/wiphy.c b/src/wiphy.c index 09b99fb2..4b9e130a 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -957,7 +957,7 @@ static void wiphy_print_he_capabilities(struct band *band, uint8_t width_set = bit_field(he_cap->he_phy_capa[0], 1, 7); for (i = 0; i < 32; i++) { - if (!(he_cap->iftypes & (1 << i))) + if (!(he_cap->iftypes & (1ULL << i))) continue; if (L_WARN_ON(s >= type_buf + sizeof(type_buf)))