Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wshift-overflow in drivers/net/wireless/realtek/rtw88/main.c #467

Closed
nathanchance opened this issue May 1, 2019 · 4 comments
Closed

-Wshift-overflow in drivers/net/wireless/realtek/rtw88/main.c #467

nathanchance opened this issue May 1, 2019 · 4 comments
Assignees
Labels
-Wshift-overflow [BUG] linux-next This is an issue only seen in linux-next [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle

Comments

@nathanchance
Copy link
Member

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift result (0x3FF00000000) requires 43 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:476:6: note: expanded from macro 'RA_MASK_VHT_RATES'
                                 RA_MASK_VHT_RATES_3SS)
                                 ^~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:473:41: note: expanded from macro 'RA_MASK_VHT_RATES_3SS'
#define RA_MASK_VHT_RATES_3SS   (0x3ff000 << 20)
                                 ~~~~~~~~ ^  ~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift result (0xFF0000000) requires 37 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:470:6: note: expanded from macro 'RA_MASK_HT_RATES'
                                 RA_MASK_HT_RATES_3SS)
                                 ^~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:467:39: note: expanded from macro 'RA_MASK_HT_RATES_3SS'
#define RA_MASK_HT_RATES_3SS    (0xff000 << 16)
                                 ~~~~~~~ ^  ~~
drivers/net/wireless/realtek/rtw88/main.c:535:15: warning: signed shift result (0x3FF00000000) requires 43 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_CCK_IN_VHT |
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:476:6: note: expanded from macro 'RA_MASK_VHT_RATES'
                                 RA_MASK_VHT_RATES_3SS)
                                 ^~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:473:41: note: expanded from macro 'RA_MASK_VHT_RATES_3SS'
#define RA_MASK_VHT_RATES_3SS   (0x3ff000 << 20)
                                 ~~~~~~~~ ^  ~~
drivers/net/wireless/realtek/rtw88/main.c:540:15: warning: signed shift result (0xFF0000000) requires 37 bits to represent, but 'int' only has 32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_CCK_IN_HT |
                                   ^~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:470:6: note: expanded from macro 'RA_MASK_HT_RATES'
                                 RA_MASK_HT_RATES_3SS)
                                 ^~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:467:39: note: expanded from macro 'RA_MASK_HT_RATES_3SS'
#define RA_MASK_HT_RATES_3SS    (0xff000 << 16)
                                 ~~~~~~~ ^  ~~
4 warnings generated.
@nathanchance nathanchance added -Wshift-overflow [BUG] linux-next This is an issue only seen in linux-next labels May 1, 2019
@nathanchance
Copy link
Member Author

This should be the proper fix I think: https://gist.github.com/51de646110177fb0f13233955231751b

@nathanchance
Copy link
Member Author

@nathanchance nathanchance self-assigned this May 2, 2019
@nathanchance nathanchance added the [PATCH] Submitted A patch has been submitted for review label May 2, 2019
@nathanchance nathanchance added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels May 2, 2019
fengguang pushed a commit to 0day-ci/linux that referenced this issue May 3, 2019
Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e303748 ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
@nathanchance
Copy link
Member Author

@nathanchance nathanchance added [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle and removed [PATCH] Accepted A submitted patch has been accepted upstream labels May 3, 2019
jason77-wang pushed a commit to jason77-wang/oem that referenced this issue Jun 18, 2019
BugLink: https://bugs.launchpad.net/bugs/1831828

Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 237b47efcdbc019ccd094ad8b87847dc6fc7fda7)
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Signed-off-by: Timo Aaltonen <timo.aaltonen@canonical.com>
jason77-wang pushed a commit to jason77-wang/oem that referenced this issue Jun 24, 2019
BugLink: https://bugs.launchpad.net/bugs/1831828

Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 237b47efcdbc019ccd094ad8b87847dc6fc7fda7)
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Signed-off-by: Timo Aaltonen <timo.aaltonen@canonical.com>
jason77-wang pushed a commit to jason77-wang/oem that referenced this issue Jul 5, 2019
BugLink: https://bugs.launchpad.net/bugs/1831828

Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 237b47efcdbc019ccd094ad8b87847dc6fc7fda7)
Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Acked-by: AceLan Kao <acelan.kao@canonical.com>
Acked-by: Hui Wang <hui.wang@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fcicq pushed a commit to fcicq/chromiumos-third_party-kernel that referenced this issue Jul 17, 2019
Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                  ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                  ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e303748 ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 237b47e)

BUG=b:124400293
TEST=compile with -Wshift-overflow

Change-Id: I3c7f2fdee9d394850e9983fefaa541c1b2a5898d
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1679950
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
starnight pushed a commit to endlessm/linux that referenced this issue Jul 17, 2019
Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e303748 ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
pkshih pushed a commit to rtlwifi-linux/rtw88_8723de that referenced this issue Aug 28, 2019
Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                        ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
fcicq pushed a commit to fcicq/chromiumos-third_party-kernel that referenced this issue Aug 30, 2019
Clang warns about the definitions of these macros (full warnings trimmed
for brevity):

drivers/net/wireless/realtek/rtw88/main.c:524:15: warning: signed shift
result (0x3FF00000000) requires 43 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                  ra_mask &= RA_MASK_VHT_RATES | RA_MASK_OFDM_IN_VHT;
                                   ^~~~~~~~~~~~~~~~~
drivers/net/wireless/realtek/rtw88/main.c:527:15: warning: signed shift
result (0xFF0000000) requires 37 bits to represent, but 'int' only has
32 bits [-Wshift-overflow]
                  ra_mask &= RA_MASK_HT_RATES | RA_MASK_OFDM_IN_HT_5G;
                                   ^~~~~~~~~~~~~~~~

Given that these are all used with ra_mask, which is of type u64, we can
just declare the macros to be ULL as well.

Fixes: e303748 ("rtw88: new Realtek 802.11ac driver")
Link: ClangBuiltLinux/linux#467
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit 237b47e)

BUG=b:124400293
TEST=compile with -Wshift-overflow

Change-Id: I3c7f2fdee9d394850e9983fefaa541c1b2a5898d
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1679950
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/1777150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wshift-overflow [BUG] linux-next This is an issue only seen in linux-next [FIXED][LINUX] development cycle This bug was only present and fixed in a -next or -rc cycle
Projects
None yet
Development

No branches or pull requests

1 participant