Skip to content

Commit

Permalink
mwifiex: remove unnecessary variable initialization
Browse files Browse the repository at this point in the history
Skip initialization of local variables with some default values
if the values are not going to be used further down the code path.

Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Yogesh Ashok Powar authored and John W. Linville committed May 5, 2011
1 parent 57f16b5 commit 270e58e
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 165 deletions.
7 changes: 3 additions & 4 deletions drivers/net/wireless/mwifiex/11n.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ int mwifiex_ret_11n_addba_req(struct mwifiex_private *priv,
*/
int mwifiex_ret_11n_cfg(struct host_cmd_ds_command *resp, void *data_buf)
{
struct mwifiex_ds_11n_tx_cfg *tx_cfg = NULL;
struct mwifiex_ds_11n_tx_cfg *tx_cfg;
struct host_cmd_ds_11n_cfg *htcfg = &resp->params.htcfg;

if (data_buf) {
Expand Down Expand Up @@ -274,7 +274,7 @@ int mwifiex_cmd_amsdu_aggr_ctrl(struct host_cmd_ds_command *cmd,
int mwifiex_ret_amsdu_aggr_ctrl(struct host_cmd_ds_command *resp,
void *data_buf)
{
struct mwifiex_ds_11n_amsdu_aggr_ctrl *amsdu_aggr_ctrl = NULL;
struct mwifiex_ds_11n_amsdu_aggr_ctrl *amsdu_aggr_ctrl;
struct host_cmd_ds_amsdu_aggr_ctrl *amsdu_ctrl =
&resp->params.amsdu_aggr_ctrl;

Expand Down Expand Up @@ -461,8 +461,7 @@ mwifiex_cfg_tx_buf(struct mwifiex_private *priv,
struct mwifiex_bssdescriptor *bss_desc)
{
u16 max_amsdu = MWIFIEX_TX_DATA_BUF_SIZE_2K;
u16 tx_buf = 0;
u16 curr_tx_buf_size = 0;
u16 tx_buf, curr_tx_buf_size = 0;

if (bss_desc->bcn_ht_cap) {
if (le16_to_cpu(bss_desc->bcn_ht_cap->cap_info) &
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/wireless/mwifiex/11n_aggr.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mwifiex_11n_form_amsdu_pkt(struct sk_buff *skb_aggr,
* later with ethertype
*/
};
struct tx_packet_hdr *tx_header = NULL;
struct tx_packet_hdr *tx_header;

skb_put(skb_aggr, sizeof(*tx_header));

Expand Down Expand Up @@ -182,7 +182,7 @@ int mwifiex_11n_deaggregate_pkt(struct mwifiex_private *priv,
struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);
struct rxpd *local_rx_pd = (struct rxpd *) skb->data;
struct sk_buff *skb_daggr;
struct mwifiex_rxinfo *rx_info_daggr = NULL;
struct mwifiex_rxinfo *rx_info_daggr;
int ret = -1;
struct rx_packet_hdr *rx_pkt_hdr;
struct mwifiex_adapter *adapter = priv->adapter;
Expand Down Expand Up @@ -285,8 +285,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv,
struct mwifiex_adapter *adapter = priv->adapter;
struct sk_buff *skb_aggr, *skb_src;
struct mwifiex_txinfo *tx_info_aggr, *tx_info_src;
int pad = 0;
int ret = 0;
int pad = 0, ret;
struct mwifiex_tx_param tx_param;
struct txpd *ptx_pd = NULL;

Expand Down
15 changes: 7 additions & 8 deletions drivers/net/wireless/mwifiex/11n_rxreorder.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv,
*rx_reor_tbl_ptr, int start_win)
{
int no_pkt_to_send, i;
void *rx_tmp_ptr = NULL;
void *rx_tmp_ptr;
unsigned long flags;

no_pkt_to_send = (start_win > rx_reor_tbl_ptr->start_win) ?
Expand Down Expand Up @@ -88,7 +88,7 @@ mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv,
struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr)
{
int i, j, xchg;
void *rx_tmp_ptr = NULL;
void *rx_tmp_ptr;
unsigned long flags;

for (i = 0; i < rx_reor_tbl_ptr->win_size; ++i) {
Expand Down Expand Up @@ -335,8 +335,8 @@ int mwifiex_cmd_11n_addba_rsp_gen(struct mwifiex_private *priv,
&cmd->params.add_ba_rsp;
struct host_cmd_ds_11n_addba_req *cmd_addba_req =
(struct host_cmd_ds_11n_addba_req *) data_buf;
u8 tid = 0;
int win_size = 0;
u8 tid;
int win_size;
uint16_t block_ack_param_set;

cmd->command = cpu_to_le16(HostCmd_CMD_11N_ADDBA_RSP);
Expand Down Expand Up @@ -406,9 +406,8 @@ int mwifiex_11n_rx_reorder_pkt(struct mwifiex_private *priv,
u8 *ta, u8 pkt_type, void *payload)
{
struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
int start_win, end_win, win_size;
int ret = 0;
u16 pkt_index = 0;
int start_win, end_win, win_size, ret;
u16 pkt_index;

rx_reor_tbl_ptr =
mwifiex_11n_get_rx_reorder_tbl((struct mwifiex_private *) priv,
Expand Down Expand Up @@ -540,7 +539,7 @@ int mwifiex_ret_11n_addba_resp(struct mwifiex_private *priv,
(struct host_cmd_ds_11n_addba_rsp *)
&resp->params.add_ba_rsp;
int tid, win_size;
struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr = NULL;
struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr;
uint16_t block_ack_param_set;

block_ack_param_set = le16_to_cpu(add_ba_rsp->block_ack_param_set);
Expand Down
23 changes: 9 additions & 14 deletions drivers/net/wireless/mwifiex/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@ mwifiex_channels_to_cfg80211_channel_type(int channel_type)
static int
mwifiex_is_alg_wep(u32 cipher)
{
int alg = 0;

switch (cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
alg = 1;
break;
return 1;
default:
alg = 0;
break;
}
return alg;

return 0;
}

/*
Expand Down Expand Up @@ -408,7 +405,7 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
static int
mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr)
{
int ret = 0;
int ret;

if (frag_thr < MWIFIEX_FRAG_MIN_VALUE
|| frag_thr > MWIFIEX_FRAG_MAX_VALUE)
Expand Down Expand Up @@ -449,7 +446,6 @@ static int
mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
{
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);

int ret = 0;

if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
Expand All @@ -473,7 +469,7 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
enum nl80211_iftype type, u32 *flags,
struct vif_params *params)
{
int ret = 0;
int ret;
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);

if (priv->bss_mode == type) {
Expand Down Expand Up @@ -717,7 +713,7 @@ static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv)
{
struct ieee80211_channel *chan;
struct mwifiex_bss_info bss_info;
int ie_len = 0;
int ie_len;
u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)];

if (mwifiex_get_bss_info(priv, &bss_info))
Expand Down Expand Up @@ -903,8 +899,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
{
struct mwifiex_802_11_ssid req_ssid;
struct mwifiex_ssid_bssid ssid_bssid;
int ret = 0;
int auth_type = 0;
int ret, auth_type = 0;

memset(&req_ssid, 0, sizeof(struct mwifiex_802_11_ssid));
memset(&ssid_bssid, 0, sizeof(struct mwifiex_ssid_bssid));
Expand Down Expand Up @@ -1247,8 +1242,8 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = {
int mwifiex_register_cfg80211(struct net_device *dev, u8 *mac,
struct mwifiex_private *priv)
{
int ret = 0;
void *wdev_priv = NULL;
int ret;
void *wdev_priv;
struct wireless_dev *wdev;

wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
Expand Down
28 changes: 14 additions & 14 deletions drivers/net/wireless/mwifiex/cmdevt.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
{

struct mwifiex_adapter *adapter = priv->adapter;
int ret = 0;
int ret;
struct host_cmd_ds_command *host_cmd;
uint16_t cmd_code;
uint16_t cmd_size;
Expand Down Expand Up @@ -222,8 +222,8 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv,
*/
static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
{
int ret = 0;
u16 cmd_len = 0;
int ret;
u16 cmd_len;
struct mwifiex_private *priv;
struct mwifiex_opt_sleep_confirm_buffer *sleep_cfm_buf =
(struct mwifiex_opt_sleep_confirm_buffer *)
Expand Down Expand Up @@ -364,13 +364,13 @@ int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter)
*/
int mwifiex_process_event(struct mwifiex_adapter *adapter)
{
int ret = 0;
int ret;
struct mwifiex_private *priv =
mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
struct sk_buff *skb = adapter->event_skb;
u32 eventcause = adapter->event_cause;
struct timeval tstamp;
struct mwifiex_rxinfo *rx_info = NULL;
struct mwifiex_rxinfo *rx_info;

/* Save the last event to debug log */
adapter->dbg.last_event_index =
Expand Down Expand Up @@ -446,10 +446,10 @@ int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
u16 cmd_action, u32 cmd_oid, void *data_buf)
{
int ret = 0;
int ret;
struct mwifiex_adapter *adapter = priv->adapter;
struct cmd_ctrl_node *cmd_node = NULL;
struct host_cmd_ds_command *cmd_ptr = NULL;
struct cmd_ctrl_node *cmd_node;
struct host_cmd_ds_command *cmd_ptr;

if (!adapter) {
pr_err("PREP_CMD: adapter is NULL\n");
Expand Down Expand Up @@ -605,8 +605,8 @@ mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
*/
int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter)
{
struct mwifiex_private *priv = NULL;
struct cmd_ctrl_node *cmd_node = NULL;
struct mwifiex_private *priv;
struct cmd_ctrl_node *cmd_node;
int ret = 0;
struct host_cmd_ds_command *host_cmd;
unsigned long cmd_flags;
Expand Down Expand Up @@ -673,7 +673,7 @@ int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter)
*/
int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
{
struct host_cmd_ds_command *resp = NULL;
struct host_cmd_ds_command *resp;
struct mwifiex_private *priv =
mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
int ret = 0;
Expand Down Expand Up @@ -805,7 +805,7 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
{
struct mwifiex_adapter *adapter =
(struct mwifiex_adapter *) function_context;
struct cmd_ctrl_node *cmd_node = NULL;
struct cmd_ctrl_node *cmd_node;
struct timeval tstamp;

adapter->num_cmd_timeout++;
Expand Down Expand Up @@ -877,7 +877,7 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
void
mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
{
struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
struct cmd_ctrl_node *cmd_node = NULL, *tmp_node;
unsigned long flags;

/* Cancel current cmd */
Expand Down Expand Up @@ -1160,7 +1160,7 @@ int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
{
struct host_cmd_ds_802_11_ps_mode_enh *psmode_enh =
&cmd->params.psmode_enh;
u8 *tlv = NULL;
u8 *tlv;
u16 cmd_size = 0;

cmd->command = cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH);
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/wireless/mwifiex/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ mwifiex_info_read(struct file *file, char __user *ubuf,
unsigned long page = get_zeroed_page(GFP_KERNEL);
char *p = (char *) page, fmt[64];
struct mwifiex_bss_info info;
ssize_t ret = 0;
ssize_t ret;
int i = 0;

if (!p)
Expand Down Expand Up @@ -288,7 +288,7 @@ mwifiex_getlog_read(struct file *file, char __user *ubuf,
(struct mwifiex_private *) file->private_data;
unsigned long page = get_zeroed_page(GFP_KERNEL);
char *p = (char *) page;
ssize_t ret = 0;
ssize_t ret;
struct mwifiex_ds_get_stats stats;

if (!p)
Expand Down Expand Up @@ -400,7 +400,7 @@ mwifiex_debug_read(struct file *file, char __user *ubuf,
struct mwifiex_debug_data *d = &items[0];
unsigned long page = get_zeroed_page(GFP_KERNEL);
char *p = (char *) page;
ssize_t ret = 0;
ssize_t ret;
size_t size, addr;
long val;
int i, j;
Expand Down Expand Up @@ -507,7 +507,7 @@ mwifiex_regrdwr_write(struct file *file,
unsigned long addr = get_zeroed_page(GFP_KERNEL);
char *buf = (char *) addr;
size_t buf_size = min(count, (size_t) (PAGE_SIZE - 1));
int ret = 0;
int ret;
u32 reg_type = 0, reg_offset = 0, reg_value = UINT_MAX;

if (!buf)
Expand Down Expand Up @@ -650,7 +650,7 @@ mwifiex_rdeeprom_read(struct file *file, char __user *ubuf,
(struct mwifiex_private *) file->private_data;
unsigned long addr = get_zeroed_page(GFP_KERNEL);
char *buf = (char *) addr;
int pos = 0, ret = 0, i = 0;
int pos = 0, ret = 0, i;
u8 value[MAX_EEPROM_DATA];

if (!buf)
Expand Down
Loading

0 comments on commit 270e58e

Please sign in to comment.