Move default action from after switch to within
Move from this type of constructions: switch (val) { case 1: something; break; } default-action; into following: switch (val) { case 1: something; break; default: default-action; break } for cases where the switch statement is not expected to contain a full set of enum values and as such, does not lose value from not having the default target. This makes the intent of default behavior clearer for static analyzers like gcc with -Wswitch-default. Signed-off-by: Chaoli Zhou <quic_zchaoli@quicinc.com>
This commit is contained in:
parent
7614fcebe0
commit
f8a05de669
11 changed files with 49 additions and 36 deletions
|
@ -29,10 +29,10 @@ static const char * mlme_auth_alg_str(int alg)
|
|||
return "SHARED_KEY";
|
||||
case WLAN_AUTH_FT:
|
||||
return "FT";
|
||||
}
|
||||
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_NO_HOSTAPD_LOGGER */
|
||||
|
||||
|
||||
|
|
|
@ -206,10 +206,10 @@ static const char * timeout_next_str(int val)
|
|||
return "REMOVE";
|
||||
case STA_DISASSOC_FROM_CLI:
|
||||
return "DISASSOC_FROM_CLI";
|
||||
}
|
||||
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int hostapd_ctrl_iface_sta_mib(struct hostapd_data *hapd,
|
||||
|
|
|
@ -530,10 +530,10 @@ static int fils_process_hlp_ip(struct hostapd_data *hapd,
|
|||
switch (iph->ip_p) {
|
||||
case 17:
|
||||
return fils_process_hlp_udp(hapd, sta, dst, pos, len);
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int fils_process_hlp_req(struct hostapd_data *hapd,
|
||||
|
@ -567,10 +567,10 @@ static int fils_process_hlp_req(struct hostapd_data *hapd,
|
|||
case ETH_P_IP:
|
||||
return fils_process_hlp_ip(hapd, sta, pos, pkt + 2,
|
||||
end - pkt - 2);
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int fils_process_hlp(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
|
|
|
@ -1263,9 +1263,10 @@ static int ieee80211_chan_to_freq_us(u8 op_class, u8 chan)
|
|||
if (chan < 25 || chan > 29)
|
||||
return -1;
|
||||
return 56160 + 2160 * (chan - 24);
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_chan_to_freq_eu(u8 op_class, u8 chan)
|
||||
|
@ -1313,9 +1314,10 @@ static int ieee80211_chan_to_freq_eu(u8 op_class, u8 chan)
|
|||
if (chan != 25)
|
||||
return -1;
|
||||
return 56160 + 2160 * (chan - 24);
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_chan_to_freq_jp(u8 op_class, u8 chan)
|
||||
|
@ -1369,9 +1371,10 @@ static int ieee80211_chan_to_freq_jp(u8 op_class, u8 chan)
|
|||
if (chan != 25)
|
||||
return -1;
|
||||
return 56160 + 2160 * (chan - 24);
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_chan_to_freq_cn(u8 op_class, u8 chan)
|
||||
|
@ -1395,9 +1398,10 @@ static int ieee80211_chan_to_freq_cn(u8 op_class, u8 chan)
|
|||
if (chan < 149 || chan > 165)
|
||||
return -1;
|
||||
return 5000 + 5 * chan;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_chan_to_freq_global(u8 op_class, u8 chan)
|
||||
|
@ -1482,9 +1486,10 @@ static int ieee80211_chan_to_freq_global(u8 op_class, u8 chan)
|
|||
if (chan < 25 || chan > 29)
|
||||
return -1;
|
||||
return 56160 + 2160 * (chan - 24);
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ieee80211_chan_to_freq - Convert channel info to frequency
|
||||
|
@ -2613,10 +2618,10 @@ int op_class_to_bandwidth(u8 op_class)
|
|||
return 6480;
|
||||
case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */
|
||||
return 8640;
|
||||
}
|
||||
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum oper_chan_width op_class_to_ch_width(u8 op_class)
|
||||
|
@ -2677,9 +2682,10 @@ enum oper_chan_width op_class_to_ch_width(u8 op_class)
|
|||
return CONF_OPER_CHWIDTH_6480MHZ;
|
||||
case 183: /* 60 GHz band, EDMG CB4, channel 25..29 */
|
||||
return CONF_OPER_CHWIDTH_8640MHZ;
|
||||
}
|
||||
default:
|
||||
return CONF_OPER_CHWIDTH_USE_HT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct wpabuf * ieee802_11_defrag_data(struct ieee802_11_elems *elems,
|
||||
|
|
|
@ -603,10 +603,10 @@ static int sswu_curve_param(int group, int *z)
|
|||
case 30:
|
||||
*z = 7;
|
||||
return 0;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void debug_print_bignum(const char *title, const struct crypto_bignum *a,
|
||||
|
|
|
@ -2736,10 +2736,10 @@ int wpa_cipher_key_len(int cipher)
|
|||
return 16;
|
||||
case WPA_CIPHER_TKIP:
|
||||
return 32;
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wpa_cipher_rsc_len(int cipher)
|
||||
|
@ -2751,10 +2751,10 @@ int wpa_cipher_rsc_len(int cipher)
|
|||
case WPA_CIPHER_GCMP:
|
||||
case WPA_CIPHER_TKIP:
|
||||
return 6;
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum wpa_alg wpa_cipher_to_alg(int cipher)
|
||||
|
@ -2778,9 +2778,10 @@ enum wpa_alg wpa_cipher_to_alg(int cipher)
|
|||
return WPA_ALG_BIP_GMAC_256;
|
||||
case WPA_CIPHER_BIP_CMAC_256:
|
||||
return WPA_ALG_BIP_CMAC_256;
|
||||
}
|
||||
default:
|
||||
return WPA_ALG_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wpa_cipher_valid_pairwise(int cipher)
|
||||
|
|
|
@ -454,10 +454,10 @@ static const EVP_CIPHER * aes_get_evp_cipher(size_t keylen)
|
|||
return EVP_aes_192_ecb();
|
||||
case 32:
|
||||
return EVP_aes_256_ecb();
|
||||
}
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void * aes_encrypt_init(const u8 *key, size_t len)
|
||||
|
@ -4090,11 +4090,13 @@ int crypto_ec_key_group(struct crypto_ec_key *key)
|
|||
case NID_brainpoolP512r1:
|
||||
return 30;
|
||||
#endif /* NID_brainpoolP512r1 */
|
||||
}
|
||||
wpa_printf(MSG_ERROR, "OpenSSL: Unsupported curve (nid=%d) in EC key",
|
||||
default:
|
||||
wpa_printf(MSG_ERROR,
|
||||
"OpenSSL: Unsupported curve (nid=%d) in EC key",
|
||||
nid);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int crypto_ec_key_cmp(struct crypto_ec_key *key1, struct crypto_ec_key *key2)
|
||||
|
|
|
@ -5551,9 +5551,10 @@ static const char * openssl_pkey_type_str(const EVP_PKEY *pkey)
|
|||
return "DH";
|
||||
case EVP_PKEY_EC:
|
||||
return "EC";
|
||||
}
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void openssl_debug_dump_certificate(int i, X509 *cert)
|
||||
|
|
|
@ -219,9 +219,10 @@ enum chan_width convert2width(int width)
|
|||
return CHAN_WIDTH_160;
|
||||
case NL80211_CHAN_WIDTH_320:
|
||||
return CHAN_WIDTH_320;
|
||||
}
|
||||
default:
|
||||
return CHAN_WIDTH_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int is_ap_interface(enum nl80211_iftype nlmode)
|
||||
|
@ -3189,10 +3190,10 @@ static u32 wpa_cipher_to_cipher_suite(unsigned int cipher)
|
|||
return RSN_CIPHER_SUITE_WEP40;
|
||||
case WPA_CIPHER_GTK_NOT_USED:
|
||||
return RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED;
|
||||
}
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int wpa_cipher_to_cipher_suites(unsigned int ciphers, u32 suites[],
|
||||
|
|
|
@ -147,9 +147,10 @@ static const char * linkmode_str(int mode)
|
|||
return "kernel-control";
|
||||
case 1:
|
||||
return "userspace-control";
|
||||
}
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char * operstate_str(int state)
|
||||
|
@ -161,9 +162,10 @@ static const char * operstate_str(int state)
|
|||
return "IF_OPER_DORMANT";
|
||||
case IF_OPER_UP:
|
||||
return "IF_OPER_UP";
|
||||
}
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int netlink_send_oper_ifla(struct netlink_data *netlink, int ifindex,
|
||||
|
|
|
@ -530,10 +530,10 @@ static enum wpa_driver_if_type wpas_p2p_if_type(int p2p_group_interface)
|
|||
return WPA_IF_P2P_GO;
|
||||
case P2P_GROUP_INTERFACE_CLIENT:
|
||||
return WPA_IF_P2P_CLIENT;
|
||||
}
|
||||
|
||||
default:
|
||||
return WPA_IF_P2P_GROUP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static struct wpa_supplicant * wpas_get_p2p_group(struct wpa_supplicant *wpa_s,
|
||||
|
|
Loading…
Add table
Reference in a new issue