[lvc-project] [PATCH] wifi: rt2x00: remove useless code in rt2x00queue_create_tx_descriptor()
Kalle Valo
kvalo at kernel.org
Tue Dec 12 21:04:11 MSK 2023
Dmitry Antipov <dmantipov at yandex.ru> writes:
> In 'rt2x00queue_create_tx_descriptor()', there is no need to call
> 'ieee80211_get_rts_cts_rate()' while checking for RTS/CTS frame
> since this function returns NULL or pointer to internal bitrate
> table entry, and the return value is not actually used. This way,
> 'rate' becomes block-scoped later when determining the modulation.
> Compile tested only.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
> ---
> drivers/net/wireless/ralink/rt2x00/rt2x00queue.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
> index 98df0aef8168..7f9955deb204 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00queue.c
> @@ -389,7 +389,6 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
> struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
> struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
> struct ieee80211_tx_rate *txrate = &tx_info->control.rates[0];
> - struct ieee80211_rate *rate;
I think this should be kept.
> @@ -463,7 +459,8 @@ static void rt2x00queue_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
> else if (txrate->flags & IEEE80211_TX_RC_MCS)
> txdesc->rate_mode = RATE_MODE_HT_MIX;
> else {
> - rate = ieee80211_get_tx_rate(rt2x00dev->hw, tx_info);
> + struct ieee80211_rate *rate =
> + ieee80211_get_tx_rate(rt2x00dev->hw, tx_info);
As I find it bad practice to declarare variables within if/else blocks.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
More information about the lvc-project
mailing list