* [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo @ 2022-01-30 22:37 Colin Ian King 2022-01-31 2:53 ` Pkshih 2022-02-01 12:26 ` Kalle Valo 0 siblings, 2 replies; 9+ messages in thread From: Colin Ian King @ 2022-01-30 22:37 UTC (permalink / raw) To: Ping-Ke Shih, Kalle Valo, David S . Miller, Jakub Kicinski, linux-wireless, netdev Cc: kernel-janitors, linux-kernel Variable ul_encalgo is initialized with a value that is never read, it is being re-assigned a new value in every case in the following switch statement. The initialization is redundant and can be removed. Signed-off-by: Colin Ian King <colin.i.king@gmail.com> --- drivers/net/wireless/realtek/rtlwifi/cam.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/cam.c b/drivers/net/wireless/realtek/rtlwifi/cam.c index 7a0355dc6bab..32970ea4b4e7 100644 --- a/drivers/net/wireless/realtek/rtlwifi/cam.c +++ b/drivers/net/wireless/realtek/rtlwifi/cam.c @@ -208,7 +208,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) u32 ul_command; u32 ul_content; - u32 ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; + u32 ul_encalgo; u8 entry_i; switch (rtlpriv->sec.pairwise_enc_algorithm) { -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-01-30 22:37 [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo Colin Ian King @ 2022-01-31 2:53 ` Pkshih 2022-02-01 12:22 ` Kalle Valo 2022-02-02 5:02 ` Dan Carpenter 2022-02-01 12:26 ` Kalle Valo 1 sibling, 2 replies; 9+ messages in thread From: Pkshih @ 2022-01-31 2:53 UTC (permalink / raw) To: kvalo, linux-wireless, colin.i.king, davem, kuba, netdev Cc: kernel-janitors, linux-kernel On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: > Variable ul_encalgo is initialized with a value that is never read, > it is being re-assigned a new value in every case in the following > switch statement. The initialization is redundant and can be removed. > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Acked-by: Ping-Ke Shih <pkshih@realtek.com> > --- > drivers/net/wireless/realtek/rtlwifi/cam.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/realtek/rtlwifi/cam.c > b/drivers/net/wireless/realtek/rtlwifi/cam.c > index 7a0355dc6bab..32970ea4b4e7 100644 > --- a/drivers/net/wireless/realtek/rtlwifi/cam.c > +++ b/drivers/net/wireless/realtek/rtlwifi/cam.c > @@ -208,7 +208,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > > u32 ul_command; > u32 ul_content; > - u32 ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > + u32 ul_encalgo; > u8 entry_i; > > switch (rtlpriv->sec.pairwise_enc_algorithm) { > -- When I check this patch, I find there is no 'break' for default case. Do we need one? like @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) break; default: ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; + break; } for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { -- Ping-Ke ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-01-31 2:53 ` Pkshih @ 2022-02-01 12:22 ` Kalle Valo 2022-02-02 5:02 ` Dan Carpenter 1 sibling, 0 replies; 9+ messages in thread From: Kalle Valo @ 2022-02-01 12:22 UTC (permalink / raw) To: Pkshih Cc: linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel Pkshih <pkshih@realtek.com> writes: > On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: >> Variable ul_encalgo is initialized with a value that is never read, >> it is being re-assigned a new value in every case in the following >> switch statement. The initialization is redundant and can be removed. >> >> Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > > Acked-by: Ping-Ke Shih <pkshih@realtek.com> > >> --- >> drivers/net/wireless/realtek/rtlwifi/cam.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/wireless/realtek/rtlwifi/cam.c >> b/drivers/net/wireless/realtek/rtlwifi/cam.c >> index 7a0355dc6bab..32970ea4b4e7 100644 >> --- a/drivers/net/wireless/realtek/rtlwifi/cam.c >> +++ b/drivers/net/wireless/realtek/rtlwifi/cam.c >> @@ -208,7 +208,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) >> >> u32 ul_command; >> u32 ul_content; >> - u32 ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; >> + u32 ul_encalgo; >> u8 entry_i; >> >> switch (rtlpriv->sec.pairwise_enc_algorithm) { >> -- > > When I check this patch, I find there is no 'break' for default case. > Do we need one? like > > @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > break; > default: > ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > + break; > } > > for (entry_i = 0; entry_i < CAM_CONTENT_COUNT; entry_i++) { Yeah, it would be good to have break for consistency. Can someone send a separate patch for that? -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-01-31 2:53 ` Pkshih 2022-02-01 12:22 ` Kalle Valo @ 2022-02-02 5:02 ` Dan Carpenter 2022-02-02 10:10 ` Joe Perches 1 sibling, 1 reply; 9+ messages in thread From: Dan Carpenter @ 2022-02-02 5:02 UTC (permalink / raw) To: Pkshih Cc: kvalo, linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel On Mon, Jan 31, 2022 at 02:53:40AM +0000, Pkshih wrote: > On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: > > When I check this patch, I find there is no 'break' for default case. > Do we need one? like > > @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > break; > default: > ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > + break; No, it's not necessary. The choice of style is up to the original developer. regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-02-02 5:02 ` Dan Carpenter @ 2022-02-02 10:10 ` Joe Perches 2022-02-02 11:05 ` Dan Carpenter 0 siblings, 1 reply; 9+ messages in thread From: Joe Perches @ 2022-02-02 10:10 UTC (permalink / raw) To: Dan Carpenter, Pkshih Cc: kvalo, linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel On Wed, 2022-02-02 at 08:02 +0300, Dan Carpenter wrote: > On Mon, Jan 31, 2022 at 02:53:40AM +0000, Pkshih wrote: > > On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: > > > > When I check this patch, I find there is no 'break' for default case. > > Do we need one? like > > > > @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > > break; > > default: > > ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > > + break; > > No, it's not necessary. The choice of style is up to the original > developer. every case should have one. Documentation/process/deprecated.rst: All switch/case blocks must end in one of: * break; * fallthrough; * continue; * goto <label>; * return [expression]; ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-02-02 10:10 ` Joe Perches @ 2022-02-02 11:05 ` Dan Carpenter 2022-02-02 11:21 ` Joe Perches 0 siblings, 1 reply; 9+ messages in thread From: Dan Carpenter @ 2022-02-02 11:05 UTC (permalink / raw) To: Joe Perches, Kees Cook Cc: Pkshih, kvalo, linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel On Wed, Feb 02, 2022 at 02:10:40AM -0800, Joe Perches wrote: > On Wed, 2022-02-02 at 08:02 +0300, Dan Carpenter wrote: > > On Mon, Jan 31, 2022 at 02:53:40AM +0000, Pkshih wrote: > > > On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: > > > > > > When I check this patch, I find there is no 'break' for default case. > > > Do we need one? like > > > > > > @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > > > break; > > > default: > > > ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > > > + break; > > > > No, it's not necessary. The choice of style is up to the original > > developer. > > every case should have one. > > Documentation/process/deprecated.rst: > > All switch/case blocks must end in one of: > > * break; > * fallthrough; > * continue; > * goto <label>; > * return [expression]; > I doubt that's what Kees had in mind when he wrote that. The extra break statement doesn't improve readability. It also doesn't hurt readability. There is no reason to add a break statement after a default case. No one is going to add another case after the default case. And if they do then a dozen static analysis tools will complain about the missing break. I looked through the code to see if break statements were more common than non-break statement code. Both seem pretty common. I got bored really quickly though and my sample might not have been representative. regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-02-02 11:05 ` Dan Carpenter @ 2022-02-02 11:21 ` Joe Perches 2022-02-02 11:44 ` Dan Carpenter 0 siblings, 1 reply; 9+ messages in thread From: Joe Perches @ 2022-02-02 11:21 UTC (permalink / raw) To: Dan Carpenter, Kees Cook Cc: Pkshih, kvalo, linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel On Wed, 2022-02-02 at 14:05 +0300, Dan Carpenter wrote: > On Wed, Feb 02, 2022 at 02:10:40AM -0800, Joe Perches wrote: > > On Wed, 2022-02-02 at 08:02 +0300, Dan Carpenter wrote: > > > On Mon, Jan 31, 2022 at 02:53:40AM +0000, Pkshih wrote: > > > > On Sun, 2022-01-30 at 22:37 +0000, Colin Ian King wrote: > > > > > > > > When I check this patch, I find there is no 'break' for default case. > > > > Do we need one? like > > > > > > > > @@ -226,6 +226,7 @@ void rtl_cam_empty_entry(struct ieee80211_hw *hw, u8 uc_index) > > > > break; > > > > default: > > > > ul_encalgo = rtlpriv->cfg->maps[SEC_CAM_AES]; > > > > + break; > > > > > > No, it's not necessary. The choice of style is up to the original > > > developer. > > > > every case should have one. > > > > Documentation/process/deprecated.rst: > > > > All switch/case blocks must end in one of: > > > > * break; > > * fallthrough; > > * continue; > > * goto <label>; > > * return [expression]; > > > > I doubt that's what Kees had in mind when he wrote that. uhh, I wrote that. I think Kees reformatted it for .rst > The extra break statement doesn't improve readability. It also doesn't > hurt readability. > > There is no reason to add a break statement after a default case. No > one is going to add another case after the default case. Several hundred switch statements in the kernel use default: as the first block. > And if they > do then a dozen static analysis tools will complain about the missing > break. true, doesn't mean that's a good thing. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-02-02 11:21 ` Joe Perches @ 2022-02-02 11:44 ` Dan Carpenter 0 siblings, 0 replies; 9+ messages in thread From: Dan Carpenter @ 2022-02-02 11:44 UTC (permalink / raw) To: Joe Perches Cc: Kees Cook, Pkshih, kvalo, linux-wireless, colin.i.king, davem, kuba, netdev, kernel-janitors, linux-kernel On Wed, Feb 02, 2022 at 03:21:17AM -0800, Joe Perches wrote: > > I doubt that's what Kees had in mind when he wrote that. > > uhh, I wrote that. I think Kees reformatted it for .rst Heh. You should have mentioned that you invented that rule! That's like editing Wikipedia to say what you want and then citing it as a source... regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo 2022-01-30 22:37 [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo Colin Ian King 2022-01-31 2:53 ` Pkshih @ 2022-02-01 12:26 ` Kalle Valo 1 sibling, 0 replies; 9+ messages in thread From: Kalle Valo @ 2022-02-01 12:26 UTC (permalink / raw) To: Colin Ian King Cc: Ping-Ke Shih, David S . Miller, Jakub Kicinski, linux-wireless, netdev, kernel-janitors, linux-kernel Colin Ian King <colin.i.king@gmail.com> wrote: > Variable ul_encalgo is initialized with a value that is never read, > it is being re-assigned a new value in every case in the following > switch statement. The initialization is redundant and can be removed. > > Signed-off-by: Colin Ian King <colin.i.king@gmail.com> > Acked-by: Ping-Ke Shih <pkshih@realtek.com> Patch applied to wireless-next.git, thanks. e80affde1720 rtlwifi: remove redundant initialization of variable ul_encalgo -- https://patchwork.kernel.org/project/linux-wireless/patch/20220130223714.6999-1-colin.i.king@gmail.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-02-02 11:45 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-30 22:37 [PATCH] rtlwifi: remove redundant initialization of variable ul_encalgo Colin Ian King 2022-01-31 2:53 ` Pkshih 2022-02-01 12:22 ` Kalle Valo 2022-02-02 5:02 ` Dan Carpenter 2022-02-02 10:10 ` Joe Perches 2022-02-02 11:05 ` Dan Carpenter 2022-02-02 11:21 ` Joe Perches 2022-02-02 11:44 ` Dan Carpenter 2022-02-01 12:26 ` Kalle Valo
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.