drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:591:2: warning: variable 'mode' is used uninitialized whenever switch default is taken

From: kernel test robot
Date: Fri Feb 26 2021 - 09:14:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2c87f7a38f930ef6f6a7bdd04aeb82ce3971b54b
commit: 3f0caa3cbf941cb962212770326649c21a527028 mt76: mt7915: add support for continuous tx in testmode
date: 4 weeks ago
config: arm-randconfig-r036-20210226 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project b889ef4214bc6dc8880fdd4badc0dcd9a3197753)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3f0caa3cbf941cb962212770326649c21a527028
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3f0caa3cbf941cb962212770326649c21a527028
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:591:2: warning: variable 'mode' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
default:
^~~~~~~
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:595:13: note: uninitialized use occurs here
rateval = mode << 6 | rate_idx;
^~~~
drivers/net/wireless/mediatek/mt76/mt7915/testmode.c:504:37: note: initialize the variable 'mode' to silence this warning
u8 rate_idx = td->tx_rate_idx, mode;
^
= '\0'
1 warning generated.


vim +/mode +591 drivers/net/wireless/mediatek/mt76/mt7915/testmode.c

493
494 static int
495 mt7915_tm_set_tx_cont(struct mt7915_phy *phy, bool en)
496 {
497 #define TX_CONT_START 0x05
498 #define TX_CONT_STOP 0x06
499 struct mt7915_dev *dev = phy->dev;
500 struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
501 int freq1 = ieee80211_frequency_to_channel(chandef->center_freq1);
502 struct mt76_testmode_data *td = &phy->mt76->test;
503 u32 func_idx = en ? TX_CONT_START : TX_CONT_STOP;
504 u8 rate_idx = td->tx_rate_idx, mode;
505 u16 rateval;
506 struct mt7915_tm_rf_test req = {
507 .action = 1,
508 .icap_len = 120,
509 .op.rf.func_idx = cpu_to_le32(func_idx),
510 };
511 struct tm_tx_cont *tx_cont = &req.op.rf.param.tx_cont;
512
513 tx_cont->control_ch = chandef->chan->hw_value;
514 tx_cont->center_ch = freq1;
515 tx_cont->tx_ant = td->tx_antenna_mask;
516 tx_cont->band = phy != &dev->phy;
517
518 switch (chandef->width) {
519 case NL80211_CHAN_WIDTH_40:
520 tx_cont->bw = CMD_CBW_40MHZ;
521 break;
522 case NL80211_CHAN_WIDTH_80:
523 tx_cont->bw = CMD_CBW_80MHZ;
524 break;
525 case NL80211_CHAN_WIDTH_80P80:
526 tx_cont->bw = CMD_CBW_8080MHZ;
527 break;
528 case NL80211_CHAN_WIDTH_160:
529 tx_cont->bw = CMD_CBW_160MHZ;
530 break;
531 case NL80211_CHAN_WIDTH_5:
532 tx_cont->bw = CMD_CBW_5MHZ;
533 break;
534 case NL80211_CHAN_WIDTH_10:
535 tx_cont->bw = CMD_CBW_10MHZ;
536 break;
537 case NL80211_CHAN_WIDTH_20:
538 tx_cont->bw = CMD_CBW_20MHZ;
539 break;
540 case NL80211_CHAN_WIDTH_20_NOHT:
541 tx_cont->bw = CMD_CBW_20MHZ;
542 break;
543 default:
544 break;
545 }
546
547 if (!en) {
548 req.op.rf.param.func_data = cpu_to_le32(phy != &dev->phy);
549 goto out;
550 }
551
552 if (td->tx_rate_mode <= MT76_TM_TX_MODE_OFDM) {
553 struct ieee80211_supported_band *sband;
554 u8 idx = rate_idx;
555
556 if (chandef->chan->band == NL80211_BAND_5GHZ)
557 sband = &phy->mt76->sband_5g.sband;
558 else
559 sband = &phy->mt76->sband_2g.sband;
560
561 if (td->tx_rate_mode == MT76_TM_TX_MODE_OFDM)
562 idx += 4;
563 rate_idx = sband->bitrates[idx].hw_value & 0xff;
564 }
565
566 switch (td->tx_rate_mode) {
567 case MT76_TM_TX_MODE_CCK:
568 mode = MT_PHY_TYPE_CCK;
569 break;
570 case MT76_TM_TX_MODE_OFDM:
571 mode = MT_PHY_TYPE_OFDM;
572 break;
573 case MT76_TM_TX_MODE_HT:
574 mode = MT_PHY_TYPE_HT;
575 break;
576 case MT76_TM_TX_MODE_VHT:
577 mode = MT_PHY_TYPE_VHT;
578 break;
579 case MT76_TM_TX_MODE_HE_SU:
580 mode = MT_PHY_TYPE_HE_SU;
581 break;
582 case MT76_TM_TX_MODE_HE_EXT_SU:
583 mode = MT_PHY_TYPE_HE_EXT_SU;
584 break;
585 case MT76_TM_TX_MODE_HE_TB:
586 mode = MT_PHY_TYPE_HE_TB;
587 break;
588 case MT76_TM_TX_MODE_HE_MU:
589 mode = MT_PHY_TYPE_HE_MU;
590 break;
> 591 default:
592 break;
593 }
594
595 rateval = mode << 6 | rate_idx;
596 tx_cont->rateval = cpu_to_le16(rateval);
597
598 out:
599 if (!en) {
600 int ret;
601
602 ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_RF_TEST, &req,
603 sizeof(req), true);
604 if (ret)
605 return ret;
606
607 return mt7915_tm_rf_switch_mode(dev, RF_OPER_NORMAL);
608 }
609
610 mt7915_tm_rf_switch_mode(dev, RF_OPER_RF_TEST);
611 mt7915_tm_update_channel(phy);
612
613 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_RF_TEST, &req,
614 sizeof(req), true);
615 }
616

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip