Bug 47681

Summary: ath/ath5k/phy.c:1977: possible missing break ?
Product: Drivers Reporter: David Binderman (dcb314)
Component: network-wirelessAssignee: John W. Linville (linville)
Status: CLOSED CODE_FIX    
Severity: normal CC: florian, linville
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.6-rc6 Subsystem:
Regression: No Bisected commit-id:
Attachments: 0001-ath5k-add-missing-breaks-in-ath5k_hw_set_spur_mitiga.patch

Description David Binderman 2012-09-18 20:04:27 UTC
I just ran the static analyser cppcheck over the source code of the
linux kernel version 3.6-rc6.

It said

[linux-3.6-rc6/drivers/net/wireless/ath/ath5k/phy.c:1977]: (warning) Redundant assignment of "symbol_width" in switch

The source code is

        case AR5K_BWMODE_10MHZ:
            /* Both sample_freq and chip_freq are 20MHz (?) */
            spur_delta_phase = (spur_offset << 18) / 25;
            spur_freq_sigma_delta = (spur_delta_phase >> 10);
            symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 2;
        case AR5K_BWMODE_5MHZ:
            /* Both sample_freq and chip_freq are 10MHz (?) */
            spur_delta_phase = (spur_offset << 19) / 25;
            spur_freq_sigma_delta = (spur_delta_phase >> 10);
            symbol_width = AR5K_SPUR_SYMBOL_WIDTH_BASE_100Hz / 4;
        default:

I agree with cppcheck, I think there are some missing break statements
in these cases.
Comment 1 John W. Linville 2012-09-24 18:31:43 UTC
Created attachment 80981 [details]
0001-ath5k-add-missing-breaks-in-ath5k_hw_set_spur_mitiga.patch

Looks like a second break was missing as well...
Comment 2 Florian Mickler 2012-10-15 21:27:48 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc1:

commit 944f8a1a6f5ff8b503f3544811d0aa4ac27dd2aa
Author: John W. Linville <linville@tuxdriver.com>
Date:   Mon Sep 24 14:30:19 2012 -0400

    ath5k: add missing breaks in ath5k_hw_set_spur_mitigation_filter