staging/ozwpan: Fix NULL vs zero in ozpd.c (sparse warning)
This patch fixes the warning "Using plain integer as NULL pointer", generated by sparse, by replacing the offending 0s with NULL. If the initialization with NULL was unnecessary (due to unconditional assignment before first use) it was removed. Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
36d2041a3d
commit
86b02be043
|
@ -61,8 +61,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = {
|
||||||
oz_def_app_start,
|
oz_def_app_start,
|
||||||
oz_def_app_stop,
|
oz_def_app_stop,
|
||||||
oz_def_app_rx,
|
oz_def_app_rx,
|
||||||
0,
|
NULL,
|
||||||
0,
|
NULL,
|
||||||
OZ_APPID_UNUSED1},
|
OZ_APPID_UNUSED1},
|
||||||
|
|
||||||
{oz_def_app_init,
|
{oz_def_app_init,
|
||||||
|
@ -70,8 +70,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = {
|
||||||
oz_def_app_start,
|
oz_def_app_start,
|
||||||
oz_def_app_stop,
|
oz_def_app_stop,
|
||||||
oz_def_app_rx,
|
oz_def_app_rx,
|
||||||
0,
|
NULL,
|
||||||
0,
|
NULL,
|
||||||
OZ_APPID_UNUSED2},
|
OZ_APPID_UNUSED2},
|
||||||
|
|
||||||
{oz_cdev_init,
|
{oz_cdev_init,
|
||||||
|
@ -79,8 +79,8 @@ static struct oz_app_if g_app_if[OZ_APPID_MAX] = {
|
||||||
oz_cdev_start,
|
oz_cdev_start,
|
||||||
oz_cdev_stop,
|
oz_cdev_stop,
|
||||||
oz_cdev_rx,
|
oz_cdev_rx,
|
||||||
0,
|
NULL,
|
||||||
0,
|
NULL,
|
||||||
OZ_APPID_SERIAL},
|
OZ_APPID_SERIAL},
|
||||||
};
|
};
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
@ -121,7 +121,7 @@ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt)
|
||||||
void oz_pd_set_state(struct oz_pd *pd, unsigned state)
|
void oz_pd_set_state(struct oz_pd *pd, unsigned state)
|
||||||
{
|
{
|
||||||
pd->state = state;
|
pd->state = state;
|
||||||
oz_event_log(OZ_EVT_PD_STATE, 0, 0, 0, state);
|
oz_event_log(OZ_EVT_PD_STATE, 0, 0, NULL, state);
|
||||||
#ifdef WANT_TRACE
|
#ifdef WANT_TRACE
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case OZ_PD_S_IDLE:
|
case OZ_PD_S_IDLE:
|
||||||
|
@ -171,7 +171,7 @@ struct oz_pd *oz_pd_alloc(u8 *mac_addr)
|
||||||
memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
|
memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
|
||||||
if (0 != oz_elt_buf_init(&pd->elt_buff)) {
|
if (0 != oz_elt_buf_init(&pd->elt_buff)) {
|
||||||
kfree(pd);
|
kfree(pd);
|
||||||
pd = 0;
|
pd = NULL;
|
||||||
}
|
}
|
||||||
spin_lock_init(&pd->tx_frame_lock);
|
spin_lock_init(&pd->tx_frame_lock);
|
||||||
INIT_LIST_HEAD(&pd->tx_queue);
|
INIT_LIST_HEAD(&pd->tx_queue);
|
||||||
|
@ -355,7 +355,7 @@ int oz_pd_sleep(struct oz_pd *pd)
|
||||||
*/
|
*/
|
||||||
static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
|
static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
|
||||||
{
|
{
|
||||||
struct oz_tx_frame *f = 0;
|
struct oz_tx_frame *f = NULL;
|
||||||
spin_lock_bh(&pd->tx_frame_lock);
|
spin_lock_bh(&pd->tx_frame_lock);
|
||||||
if (pd->tx_pool) {
|
if (pd->tx_pool) {
|
||||||
f = container_of(pd->tx_pool, struct oz_tx_frame, link);
|
f = container_of(pd->tx_pool, struct oz_tx_frame, link);
|
||||||
|
@ -363,7 +363,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd)
|
||||||
pd->tx_pool_count--;
|
pd->tx_pool_count--;
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&pd->tx_frame_lock);
|
spin_unlock_bh(&pd->tx_frame_lock);
|
||||||
if (f == 0)
|
if (f == NULL)
|
||||||
f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC);
|
f = kmalloc(sizeof(struct oz_tx_frame), GFP_ATOMIC);
|
||||||
if (f) {
|
if (f) {
|
||||||
f->total_size = sizeof(struct oz_hdr);
|
f->total_size = sizeof(struct oz_hdr);
|
||||||
|
@ -399,7 +399,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f)
|
||||||
f->link.next = pd->tx_pool;
|
f->link.next = pd->tx_pool;
|
||||||
pd->tx_pool = &f->link;
|
pd->tx_pool = &f->link;
|
||||||
pd->tx_pool_count++;
|
pd->tx_pool_count++;
|
||||||
f = 0;
|
f = NULL;
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&pd->tx_frame_lock);
|
spin_unlock_bh(&pd->tx_frame_lock);
|
||||||
kfree(f);
|
kfree(f);
|
||||||
|
@ -433,7 +433,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty)
|
||||||
if (!empty && !oz_are_elts_available(&pd->elt_buff))
|
if (!empty && !oz_are_elts_available(&pd->elt_buff))
|
||||||
return -1;
|
return -1;
|
||||||
f = oz_tx_frame_alloc(pd);
|
f = oz_tx_frame_alloc(pd);
|
||||||
if (f == 0)
|
if (f == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
f->skb = NULL;
|
f->skb = NULL;
|
||||||
f->hdr.control =
|
f->hdr.control =
|
||||||
|
@ -455,7 +455,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty)
|
||||||
*/
|
*/
|
||||||
static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f)
|
static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb = 0;
|
struct sk_buff *skb;
|
||||||
struct net_device *dev = pd->net_dev;
|
struct net_device *dev = pd->net_dev;
|
||||||
struct oz_hdr *oz_hdr;
|
struct oz_hdr *oz_hdr;
|
||||||
struct oz_elt *elt;
|
struct oz_elt *elt;
|
||||||
|
@ -464,8 +464,8 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f)
|
||||||
* as the space we need.
|
* as the space we need.
|
||||||
*/
|
*/
|
||||||
skb = alloc_skb(f->total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
|
skb = alloc_skb(f->total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
|
||||||
if (skb == 0)
|
if (skb == NULL)
|
||||||
return 0;
|
return NULL;
|
||||||
/* Reserve the head room for lower layers.
|
/* Reserve the head room for lower layers.
|
||||||
*/
|
*/
|
||||||
skb_reserve(skb, LL_RESERVED_SPACE(dev));
|
skb_reserve(skb, LL_RESERVED_SPACE(dev));
|
||||||
|
@ -492,7 +492,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f)
|
||||||
return skb;
|
return skb;
|
||||||
fail:
|
fail:
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Context: softirq or process
|
* Context: softirq or process
|
||||||
|
@ -544,7 +544,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
|
||||||
if (dev_queue_xmit(skb) < 0) {
|
if (dev_queue_xmit(skb) < 0) {
|
||||||
oz_trace2(OZ_TRACE_TX_FRAMES,
|
oz_trace2(OZ_TRACE_TX_FRAMES,
|
||||||
"Dropping ISOC Frame\n");
|
"Dropping ISOC Frame\n");
|
||||||
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
|
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
atomic_inc(&g_submitted_isoc);
|
atomic_inc(&g_submitted_isoc);
|
||||||
|
@ -555,7 +555,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
|
||||||
} else {
|
} else {
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n");
|
oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n");
|
||||||
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
|
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data)
|
||||||
oz_event_log(OZ_EVT_TX_FRAME,
|
oz_event_log(OZ_EVT_TX_FRAME,
|
||||||
0,
|
0,
|
||||||
(((u16)f->hdr.control)<<8)|f->hdr.last_pkt_num,
|
(((u16)f->hdr.control)<<8)|f->hdr.last_pkt_num,
|
||||||
0, f->hdr.pkt_num);
|
NULL, f->hdr.pkt_num);
|
||||||
if (dev_queue_xmit(skb) < 0)
|
if (dev_queue_xmit(skb) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ out: oz_prepare_frame(pd, 1);
|
||||||
*/
|
*/
|
||||||
static int oz_send_isoc_frame(struct oz_pd *pd)
|
static int oz_send_isoc_frame(struct oz_pd *pd)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb = 0;
|
struct sk_buff *skb;
|
||||||
struct net_device *dev = pd->net_dev;
|
struct net_device *dev = pd->net_dev;
|
||||||
struct oz_hdr *oz_hdr;
|
struct oz_hdr *oz_hdr;
|
||||||
struct oz_elt *elt;
|
struct oz_elt *elt;
|
||||||
|
@ -634,7 +634,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd)
|
||||||
if (list.next == &list)
|
if (list.next == &list)
|
||||||
return 0;
|
return 0;
|
||||||
skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
|
skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC);
|
||||||
if (skb == 0) {
|
if (skb == NULL) {
|
||||||
oz_trace("Cannot alloc skb\n");
|
oz_trace("Cannot alloc skb\n");
|
||||||
oz_elt_info_free_chain(&pd->elt_buff, &list);
|
oz_elt_info_free_chain(&pd->elt_buff, &list);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -659,7 +659,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd)
|
||||||
memcpy(elt, ei->data, ei->length);
|
memcpy(elt, ei->data, ei->length);
|
||||||
elt = oz_next_elt(elt);
|
elt = oz_next_elt(elt);
|
||||||
}
|
}
|
||||||
oz_event_log(OZ_EVT_TX_ISOC, 0, 0, 0, 0);
|
oz_event_log(OZ_EVT_TX_ISOC, 0, 0, NULL, 0);
|
||||||
dev_queue_xmit(skb);
|
dev_queue_xmit(skb);
|
||||||
oz_elt_info_free_chain(&pd->elt_buff, &list);
|
oz_elt_info_free_chain(&pd->elt_buff, &list);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -671,8 +671,8 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn)
|
||||||
{
|
{
|
||||||
struct list_head *e;
|
struct list_head *e;
|
||||||
struct oz_tx_frame *f;
|
struct oz_tx_frame *f;
|
||||||
struct list_head *first = 0;
|
struct list_head *first = NULL;
|
||||||
struct list_head *last = 0;
|
struct list_head *last = NULL;
|
||||||
u8 diff;
|
u8 diff;
|
||||||
u32 pkt_num;
|
u32 pkt_num;
|
||||||
|
|
||||||
|
@ -686,7 +686,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn)
|
||||||
break;
|
break;
|
||||||
oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n",
|
oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n",
|
||||||
pkt_num, pd->nb_queued_frames);
|
pkt_num, pd->nb_queued_frames);
|
||||||
if (first == 0)
|
if (first == NULL)
|
||||||
first = e;
|
first = e;
|
||||||
last = e;
|
last = e;
|
||||||
e = e->next;
|
e = e->next;
|
||||||
|
@ -695,7 +695,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn)
|
||||||
if (first) {
|
if (first) {
|
||||||
last->next->prev = &pd->tx_queue;
|
last->next->prev = &pd->tx_queue;
|
||||||
pd->tx_queue.next = last->next;
|
pd->tx_queue.next = last->next;
|
||||||
last->next = 0;
|
last->next = NULL;
|
||||||
}
|
}
|
||||||
pd->last_sent_frame = &pd->tx_queue;
|
pd->last_sent_frame = &pd->tx_queue;
|
||||||
spin_unlock(&pd->tx_frame_lock);
|
spin_unlock(&pd->tx_frame_lock);
|
||||||
|
@ -718,7 +718,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num)
|
||||||
if (st->ep_num == ep_num)
|
if (st->ep_num == ep_num)
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
return 0;
|
return NULL;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Context: softirq
|
* Context: softirq
|
||||||
|
@ -733,7 +733,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num)
|
||||||
spin_lock_bh(&pd->stream_lock);
|
spin_lock_bh(&pd->stream_lock);
|
||||||
if (!pd_stream_find(pd, ep_num)) {
|
if (!pd_stream_find(pd, ep_num)) {
|
||||||
list_add(&st->link, &pd->stream_list);
|
list_add(&st->link, &pd->stream_list);
|
||||||
st = 0;
|
st = NULL;
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&pd->stream_lock);
|
spin_unlock_bh(&pd->stream_lock);
|
||||||
kfree(st);
|
kfree(st);
|
||||||
|
@ -779,14 +779,14 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
|
||||||
struct net_device *dev = pd->net_dev;
|
struct net_device *dev = pd->net_dev;
|
||||||
struct oz_isoc_stream *st;
|
struct oz_isoc_stream *st;
|
||||||
u8 nb_units = 0;
|
u8 nb_units = 0;
|
||||||
struct sk_buff *skb = 0;
|
struct sk_buff *skb = NULL;
|
||||||
struct oz_hdr *oz_hdr = 0;
|
struct oz_hdr *oz_hdr = NULL;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
spin_lock_bh(&pd->stream_lock);
|
spin_lock_bh(&pd->stream_lock);
|
||||||
st = pd_stream_find(pd, ep_num);
|
st = pd_stream_find(pd, ep_num);
|
||||||
if (st) {
|
if (st) {
|
||||||
skb = st->skb;
|
skb = st->skb;
|
||||||
st->skb = 0;
|
st->skb = NULL;
|
||||||
nb_units = st->nb_units;
|
nb_units = st->nb_units;
|
||||||
st->nb_units = 0;
|
st->nb_units = 0;
|
||||||
oz_hdr = st->oz_hdr;
|
oz_hdr = st->oz_hdr;
|
||||||
|
@ -799,7 +799,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
|
||||||
/* Allocate enough space for max size frame. */
|
/* Allocate enough space for max size frame. */
|
||||||
skb = alloc_skb(pd->max_tx_size + OZ_ALLOCATED_SPACE(dev),
|
skb = alloc_skb(pd->max_tx_size + OZ_ALLOCATED_SPACE(dev),
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
if (skb == 0)
|
if (skb == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
/* Reserve the head room for lower layers. */
|
/* Reserve the head room for lower layers. */
|
||||||
skb_reserve(skb, LL_RESERVED_SPACE(dev));
|
skb_reserve(skb, LL_RESERVED_SPACE(dev));
|
||||||
|
@ -874,13 +874,13 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, u8 *data, int len)
|
||||||
oz_event_log(OZ_EVT_TX_ISOC, nb_units, iso.frame_number,
|
oz_event_log(OZ_EVT_TX_ISOC, nb_units, iso.frame_number,
|
||||||
skb, atomic_read(&g_submitted_isoc));
|
skb, atomic_read(&g_submitted_isoc));
|
||||||
if (dev_queue_xmit(skb) < 0) {
|
if (dev_queue_xmit(skb) < 0) {
|
||||||
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
|
oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0);
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
out: oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, 0, 0);
|
out: oz_event_log(OZ_EVT_TX_ISOC_DROP, 0, 0, NULL, 0);
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue