From: Pavel Roskin <proski@gnu.org>
To: linux-wireless@vger.kernel.org
Subject: [PATCH 04/35] Avoid overuse of NULL
Date: Sat, 01 Sep 2007 00:34:37 -0400 [thread overview]
Message-ID: <20070901043437.2498.68801.stgit@dv.roinet.com> (raw)
In-Reply-To: <20070901043233.2498.95850.stgit@dv.roinet.com>
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
drivers/net/wireless/at76_usb.c | 76 +++++++++++++++++++--------------------
1 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/drivers/net/wireless/at76_usb.c b/drivers/net/wireless/at76_usb.c
index d1d604e..0bb159d 100644
--- a/drivers/net/wireless/at76_usb.c
+++ b/drivers/net/wireless/at76_usb.c
@@ -313,7 +313,7 @@ static int at76_usbdfu_download(struct usb_device *udev, u8 *dfu_buffer,
}
block = kmalloc(DFU_PACKETSIZE, GFP_KERNEL);
- if (block == NULL)
+ if (!block)
return -ENOMEM;
do {
@@ -734,11 +734,11 @@ static int at76_download_external_fw(struct usb_device *udev, u8 *buf, int size)
if (size < 0)
return -EINVAL;
- if ((size > 0) && (buf == NULL))
+ if (size > 0 && !buf)
return -EFAULT;
block = kmalloc(EXT_FW_BLOCK_SIZE, GFP_KERNEL);
- if (block == NULL)
+ if (!block)
return -ENOMEM;
at76_dbg(DBG_DEVSTART, "downloading external firmware");
@@ -1552,7 +1552,7 @@ static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
{
struct at76_req_join join;
- BUG_ON(ptr == NULL);
+ BUG_ON(!ptr);
memset(&join, 0, sizeof(struct at76_req_join));
memcpy(join.bssid, ptr->bssid, ETH_ALEN);
@@ -1739,8 +1739,8 @@ static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
int buf_len = (seq_nr != 3 ? AUTH_FRAME_SIZE :
AUTH_FRAME_SIZE + 1 + 1 + challenge->len);
- BUG_ON(bss == NULL);
- BUG_ON(seq_nr == 3 && challenge == NULL);
+ BUG_ON(!bss);
+ BUG_ON(seq_nr == 3 && !challenge);
tx_buffer = kmalloc(buf_len + MAX_PADDING_SIZE, GFP_ATOMIC);
if (!tx_buffer)
return -ENOMEM;
@@ -1791,7 +1791,7 @@ static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
int len;
u16 capa;
- BUG_ON(bss == NULL);
+ BUG_ON(!bss);
tx_buffer = kmalloc(ASSOCREQ_MAX_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
if (!tx_buffer)
@@ -1926,7 +1926,7 @@ static void at76_work_assoc_done(struct work_struct *work)
mutex_lock(&priv->mtx);
WARN_ON(priv->mac_state != MAC_ASSOC);
- WARN_ON(priv->curr_bss == NULL);
+ WARN_ON(!priv->curr_bss);
if (priv->mac_state != MAC_ASSOC || !priv->curr_bss)
goto exit;
@@ -1983,21 +1983,20 @@ static void at76_delete_device(struct at76_priv *priv)
/* assuming we used keventd, it must quiesce too */
flush_scheduled_work();
- if (priv->bulk_out_buffer != NULL)
- kfree(priv->bulk_out_buffer);
+ kfree(priv->bulk_out_buffer);
- if (priv->write_urb != NULL) {
+ if (priv->write_urb) {
usb_kill_urb(priv->write_urb);
usb_free_urb(priv->write_urb);
}
- if (priv->read_urb != NULL) {
+ if (priv->read_urb) {
usb_kill_urb(priv->read_urb);
usb_free_urb(priv->read_urb);
}
at76_dbg(DBG_PROC_ENTRY, "%s: unlinked urbs", __func__);
- if (priv->rx_skb != NULL)
+ if (priv->rx_skb)
kfree_skb(priv->rx_skb);
at76_free_bss_list(priv);
@@ -2011,7 +2010,7 @@ static void at76_delete_device(struct at76_priv *priv)
at76_iwevent_bss_disconnect(priv->netdev);
for (i = 0; i < NR_RX_DATA_BUF; i++)
- if (priv->rx_data[i].skb != NULL) {
+ if (priv->rx_data[i].skb) {
dev_kfree_skb(priv->rx_data[i].skb);
priv->rx_data[i].skb = NULL;
}
@@ -2475,7 +2474,6 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,
struct at76_priv *priv = netdev_priv(netdev);
unsigned long flags;
int ret = 0;
- struct iw_scan_req *req = NULL;
at76_dbg(DBG_IOCTL, "%s: SIOCSIWSCAN", netdev->name);
@@ -2517,7 +2515,7 @@ static int at76_iw_handler_set_scan(struct net_device *netdev,
/* Try to do passive or active scan if WE asks as. */
if (wrqu->data.length
&& wrqu->data.length == sizeof(struct iw_scan_req)) {
- req = (struct iw_scan_req *)extra;
+ struct iw_scan_req *req = (struct iw_scan_req *)extra;
if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
priv->scan_mode = SCAN_TYPE_PASSIVE;
@@ -3556,14 +3554,14 @@ static int at76_submit_read_urb(struct at76_priv *priv)
int size;
struct sk_buff *skb = priv->rx_skb;
- if (priv->read_urb == NULL) {
+ if (!priv->read_urb) {
err("%s: priv->read_urb is NULL", __func__);
return -EFAULT;
}
- if (skb == NULL) {
+ if (!skb) {
skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
- if (skb == NULL) {
+ if (!skb) {
err("%s: unable to allocate rx skbuff.",
priv->netdev->name);
ret = -ENOMEM;
@@ -3977,7 +3975,7 @@ static struct bss_info *at76_match_bss(struct at76_priv *priv,
struct bss_info *ptr = NULL;
struct list_head *curr;
- curr = last != NULL ? last->list.next : priv->bss_list.next;
+ curr = last ? last->list.next : priv->bss_list.next;
while (curr != &priv->bss_list) {
ptr = list_entry(curr, struct bss_info, list);
if (at76_match_essid(priv, ptr) && at76_match_mode(priv, ptr)
@@ -4015,7 +4013,7 @@ static void at76_work_join(struct work_struct *work)
priv->curr_bss = at76_match_bss(priv, priv->curr_bss);
spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
- if (priv->curr_bss == NULL) {
+ if (!priv->curr_bss) {
/* here we haven't found a matching (i)bss ... */
if (priv->iw_mode == IW_MODE_ADHOC) {
at76_set_mac_state(priv, MAC_OWN_IBSS);
@@ -4545,7 +4543,7 @@ static void at76_rx_mgmt_assoc(struct at76_priv *priv,
return;
}
- BUG_ON(priv->curr_bss == NULL);
+ BUG_ON(!priv->curr_bss);
if (status == WLAN_STATUS_SUCCESS) {
struct bss_info *ptr = priv->curr_bss;
@@ -4581,7 +4579,7 @@ static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
/* We are not connected, ignore */
if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT
- || priv->curr_bss == NULL)
+ || !priv->curr_bss)
return;
/* Not our BSSID, ignore */
@@ -4642,7 +4640,7 @@ static void at76_rx_mgmt_auth(struct at76_priv *priv,
return;
}
- BUG_ON(priv->curr_bss == NULL);
+ BUG_ON(!priv->curr_bss);
/* Not our BSSID or not for our STA, ignore */
if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
@@ -4696,7 +4694,7 @@ static void at76_rx_mgmt_deauth(struct at76_priv *priv,
return;
}
- BUG_ON(priv->curr_bss == NULL);
+ BUG_ON(!priv->curr_bss);
/* Not our BSSID, ignore */
if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
@@ -4741,7 +4739,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
if (priv->mac_state == MAC_CONNECTED) {
/* in state MAC_CONNECTED we use the mgmt_timer to control
the beacon of the BSS */
- BUG_ON(priv->curr_bss == NULL);
+ BUG_ON(!priv->curr_bss);
if (!compare_ether_addr(priv->curr_bss->bssid, mgmt->addr3)) {
/* We got our AP's beacon, defer the timeout handler.
@@ -4770,7 +4768,7 @@ static void at76_rx_mgmt_beacon(struct at76_priv *priv,
}
}
- if (match == NULL) {
+ if (!match) {
/* BSS not in the list - append it */
match = kmalloc(sizeof(struct bss_info), GFP_ATOMIC);
if (!match) {
@@ -4977,10 +4975,10 @@ static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)
only read link quality info from management packets.
Atmel driver actually averages the present, and previous
values, we just present the raw value at the moment - TJS */
- if (priv->iw_mode == IW_MODE_ADHOC ||
- (priv->curr_bss != NULL
- && !compare_ether_addr(mgmt->addr3,
- priv->curr_bss->bssid)))
+ if (priv->iw_mode == IW_MODE_ADHOC
+ || (priv->curr_bss
+ && !compare_ether_addr(mgmt->addr3,
+ priv->curr_bss->bssid)))
at76_update_wstats(priv, buf);
}
@@ -5183,7 +5181,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
bptr = priv->rx_data;
optr = NULL;
for (i = 0; i < NR_RX_DATA_BUF; i++, bptr++) {
- if (bptr->skb == NULL) {
+ if (!bptr->skb) {
optr = bptr;
oldest = 0UL;
continue;
@@ -5192,7 +5190,7 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
if (!compare_ether_addr(i802_11_hdr->addr2, bptr->sender))
break;
- if (optr == NULL) {
+ if (!optr) {
optr = bptr;
oldest = bptr->last_rx;
} else if (bptr->last_rx < oldest)
@@ -5284,8 +5282,8 @@ static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
return NULL;
}
- BUG_ON(optr == NULL);
- if (optr->skb != NULL) {
+ BUG_ON(!optr);
+ if (optr->skb) {
/* swap the skb's */
skb = optr->skb;
optr->skb = priv->rx_skb;
@@ -5331,7 +5329,7 @@ static void at76_rx_data(struct at76_priv *priv)
at76_dbg_dumpbuf("packet", skb->data + AT76_RX_HDRLEN, length);
skb = at76_check_for_rx_frags(priv);
- if (skb == NULL)
+ if (!skb)
return;
/* Atmel header and the FCS are already removed */
@@ -5383,7 +5381,7 @@ static void at76_rx_monitor_mode(struct at76_priv *priv)
skblen = sizeof(struct at76_rx_radiotap) + length;
skb = dev_alloc_skb(skblen);
- if (skb == NULL) {
+ if (!skb) {
err("%s: MONITOR MODE: dev_alloc_skb for radiotap header "
"returned NULL", priv->netdev->name);
return;
@@ -5522,12 +5520,12 @@ exit:
static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
{
struct net_device *netdev;
- struct at76_priv *priv = NULL;
+ struct at76_priv *priv;
int i;
/* allocate memory for our device state and initialize it */
netdev = alloc_etherdev(sizeof(struct at76_priv));
- if (netdev == NULL) {
+ if (!netdev) {
err("out of memory");
return NULL;
}
next prev parent reply other threads:[~2007-09-01 4:34 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-01 4:34 [PATCH 00/35] Update at76_usb to the start of mac80211 port Pavel Roskin
2007-09-01 4:34 ` [PATCH 01/35] Protect at76_get_op_mode() and at76_get_mib() against short reads Pavel Roskin
2007-09-01 4:34 ` [PATCH 02/35] Use existing macros to find bulk in and bulk out endpoints Pavel Roskin
2007-09-01 4:34 ` [PATCH 03/35] Rewrite at76_alloc_urbs() in a more linear fashion Pavel Roskin
2007-09-01 4:34 ` Pavel Roskin [this message]
2007-09-01 4:34 ` [PATCH 05/35] Add myself to the author list Pavel Roskin
2007-09-01 4:34 ` [PATCH 06/35] Move (de)initialization functions closer to the end of file Pavel Roskin
2007-09-01 4:34 ` [PATCH 07/35] Don't use shift on numeric constants in usb_control_msg() arguments Pavel Roskin
2007-09-01 4:35 ` [PATCH 08/35] Merge at76_download_external_fw() into at76_load_external_fw() Pavel Roskin
2007-09-01 4:35 ` [PATCH 09/35] Simplify at76_usbdfu_download() Pavel Roskin
2007-09-01 4:35 ` [PATCH 10/35] Add minimal support to 505AMX Pavel Roskin
2007-09-01 4:35 ` [PATCH 11/35] Simplify logic in at76_get_reg_domain() Pavel Roskin
2007-09-01 4:35 ` [PATCH 12/35] Fix hex2str() and mac2str() to avoid buffer overlap Pavel Roskin
2007-09-01 4:35 ` [PATCH 13/35] Rename some long functions and fields Pavel Roskin
2007-09-01 4:35 ` [PATCH 14/35] Fix incorrect queue management in at76_tx_mgmt() Pavel Roskin
2007-09-01 4:35 ` [PATCH 15/35] Introduce at76_quiesce(), use it to stop network activity Pavel Roskin
2007-09-01 4:35 ` [PATCH 16/35] Don't disable and enable tasklets, it doesn't work as expected Pavel Roskin
2007-09-01 4:35 ` [PATCH 17/35] Start beacon timeout task when connected Pavel Roskin
2007-09-01 4:35 ` [PATCH 18/35] Only cancel correct timeouts for Auth and Assoc replies Pavel Roskin
2007-09-01 9:17 ` Johannes Berg
2007-09-01 10:54 ` Pavel Roskin
2007-09-01 11:04 ` Johannes Berg
2007-09-01 13:16 ` John W. Linville
2007-09-01 20:09 ` Pavel Roskin
2007-09-01 4:36 ` [PATCH 19/35] Improve output of the regdomain id Pavel Roskin
2007-09-01 4:36 ` [PATCH 20/35] Protect at76_iw_handler_set_scan() with mutex Pavel Roskin
2007-09-01 4:36 ` [PATCH 21/35] Eliminate vendor IDs Pavel Roskin
2007-09-01 4:36 ` [PATCH 22/35] Only retry resubmitting rx_urb once Pavel Roskin
2007-09-01 4:36 ` [PATCH 23/35] Simplify at76_get_mib_mdomain() Pavel Roskin
2007-09-01 4:36 ` [PATCH 24/35] Do implicit scanning only with current ESSID Pavel Roskin
2007-09-01 4:36 ` [PATCH 25/35] Don't dump mib_mdomain while scanning, it's done on device startup Pavel Roskin
2007-09-01 4:36 ` [PATCH 26/35] Improve dump of MAC_ADDR Pavel Roskin
2007-09-01 4:36 ` [PATCH 27/35] Remove unneeded braces, found by checkpatch.pl Pavel Roskin
2007-09-01 4:36 ` [PATCH 28/35] Convert dbg() to at76_dbg() or remove it Pavel Roskin
2007-09-01 4:37 ` [PATCH 29/35] Eliminate at76_dbg_dumpbuf() in favor of hex2str() Pavel Roskin
2007-09-01 4:37 ` [PATCH 30/35] Eliminate pr_debug() in favor of at76_dbg() Pavel Roskin
2007-09-01 4:37 ` [PATCH 31/35] Simplify logic in at76_is_hidden_ssid() Pavel Roskin
2007-09-01 4:37 ` [PATCH 32/35] Massive cleanup of dump functions Pavel Roskin
2007-09-01 4:37 ` [PATCH 33/35] Remove international roaming support Pavel Roskin
2007-09-01 4:37 ` [PATCH 34/35] Don't do additional MIB dumps if DEBUG is defined Pavel Roskin
2007-09-01 4:37 ` [PATCH 35/35] Replace scan_runs with scan_need_any Pavel Roskin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070901043437.2498.68801.stgit@dv.roinet.com \
--to=proski@gnu.org \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.