Skip to content

Commit

Permalink
[TIPC]: Fix simple sparse warnings
Browse files Browse the repository at this point in the history
Tried to run the new tipc stack through sparse.
Following patch fixes all cases where 0 was used
as replacement of NULL.
Use NULL to document this is a pointer and to silence sparse.

This brough sparse warning count down with 127 to 24 warnings.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Per Liden <per.liden@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
sravnborg authored and davem330 committed Mar 21, 2006
1 parent edb2c34 commit 1fc54d8
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion net/tipc/bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static void bclink_send_nack(struct node *n_ptr)
msg_set_bcgap_to(msg, n_ptr->bclink.gap_to);
msg_set_bcast_tag(msg, tipc_own_tag);

if (tipc_bearer_send(&bcbearer->bearer, buf, 0)) {
if (tipc_bearer_send(&bcbearer->bearer, buf, NULL)) {
bcl->stats.sent_nacks++;
buf_discard(buf);
} else {
Expand Down
20 changes: 10 additions & 10 deletions net/tipc/bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@

#define MAX_ADDR_STR 32

static struct media *media_list = 0;
static struct media *media_list = NULL;
static u32 media_count = 0;

struct bearer *tipc_bearers = 0;
struct bearer *tipc_bearers = NULL;

/**
* media_name_valid - validate media name
Expand Down Expand Up @@ -79,7 +79,7 @@ static struct media *media_find(const char *name)
if (!strcmp(m_ptr->name, name))
return m_ptr;
}
return 0;
return NULL;
}

/**
Expand Down Expand Up @@ -287,7 +287,7 @@ static struct bearer *bearer_find(const char *name)
if (b_ptr->active && (!strcmp(b_ptr->publ.name, name)))
return b_ptr;
}
return 0;
return NULL;
}

/**
Expand All @@ -307,7 +307,7 @@ struct bearer *tipc_bearer_find_interface(const char *if_name)
if (!strcmp(b_if_name, if_name))
return b_ptr;
}
return 0;
return NULL;
}

/**
Expand Down Expand Up @@ -569,7 +569,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)

int tipc_block_bearer(const char *name)
{
struct bearer *b_ptr = 0;
struct bearer *b_ptr = NULL;
struct link *l_ptr;
struct link *temp_l_ptr;

Expand Down Expand Up @@ -666,8 +666,8 @@ int tipc_bearer_init(void)
} else {
kfree(tipc_bearers);
kfree(media_list);
tipc_bearers = 0;
media_list = 0;
tipc_bearers = NULL;
media_list = NULL;
res = -ENOMEM;
}
write_unlock_bh(&tipc_net_lock);
Expand All @@ -691,8 +691,8 @@ void tipc_bearer_stop(void)
}
kfree(tipc_bearers);
kfree(media_list);
tipc_bearers = 0;
media_list = 0;
tipc_bearers = NULL;
media_list = NULL;
media_count = 0;
}

Expand Down
12 changes: 6 additions & 6 deletions net/tipc/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
u32 lower, u32 upper);
struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest);

struct node **tipc_local_nodes = 0;
struct node **tipc_local_nodes = NULL;
struct node_map tipc_cltr_bcast_nodes = {0,{0,}};
u32 tipc_highest_allowed_slave = 0;

Expand All @@ -61,7 +61,7 @@ struct cluster *tipc_cltr_create(u32 addr)

c_ptr = (struct cluster *)kmalloc(sizeof(*c_ptr), GFP_ATOMIC);
if (c_ptr == NULL)
return 0;
return NULL;
memset(c_ptr, 0, sizeof(*c_ptr));

c_ptr->addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
Expand All @@ -73,7 +73,7 @@ struct cluster *tipc_cltr_create(u32 addr)
c_ptr->nodes = (struct node **)kmalloc(alloc, GFP_ATOMIC);
if (c_ptr->nodes == NULL) {
kfree(c_ptr);
return 0;
return NULL;
}
memset(c_ptr->nodes, 0, alloc);
if (in_own_cluster(addr))
Expand All @@ -91,7 +91,7 @@ struct cluster *tipc_cltr_create(u32 addr)
}
else {
kfree(c_ptr);
c_ptr = 0;
c_ptr = NULL;
}

return c_ptr;
Expand Down Expand Up @@ -204,7 +204,7 @@ struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector)

assert(!in_own_cluster(c_ptr->addr));
if (!c_ptr->highest_node)
return 0;
return NULL;

/* Start entry must be random */
while (mask > c_ptr->highest_node) {
Expand All @@ -222,7 +222,7 @@ struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector)
if (tipc_node_has_active_links(c_ptr->nodes[n_num]))
return c_ptr->nodes[n_num];
}
return 0;
return NULL;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion net/tipc/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static inline struct cluster *tipc_cltr_find(u32 addr)

if (z_ptr)
return z_ptr->clusters[1];
return 0;
return NULL;
}

#endif
4 changes: 2 additions & 2 deletions net/tipc/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,11 +683,11 @@ int tipc_cfg_init(void)
memset(&mng, 0, sizeof(mng));
INIT_LIST_HEAD(&mng.link_subscribers);

res = tipc_attach(&mng.user_ref, 0, 0);
res = tipc_attach(&mng.user_ref, NULL, NULL);
if (res)
goto failed;

res = tipc_createport(mng.user_ref, 0, TIPC_CRITICAL_IMPORTANCE,
res = tipc_createport(mng.user_ref, NULL, TIPC_CRITICAL_IMPORTANCE,
NULL, NULL, NULL,
NULL, cfg_named_msg_event, NULL,
NULL, &mng.port_ref);
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 sz)

pb->crs = pb->buf = raw;
pb->size = sz;
pb->next = 0;
pb->next = NULL;
pb->buf[0] = 0;
pb->buf[sz-1] = ~0;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
}
}
pb_next = pb->next;
pb->next = 0;
pb->next = NULL;
pb = pb_next;
}
spin_unlock_bh(&print_lock);
Expand Down
4 changes: 2 additions & 2 deletions net/tipc/eth_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)

static void disable_bearer(struct tipc_bearer *tb_ptr)
{
((struct eth_bearer *)tb_ptr->usr_handle)->bearer = 0;
((struct eth_bearer *)tb_ptr->usr_handle)->bearer = NULL;
}

/**
Expand Down Expand Up @@ -285,7 +285,7 @@ void tipc_eth_media_stop(void)
for (i = 0; i < MAX_ETH_BEARERS ; i++) {
if (eth_bearers[i].bearer) {
eth_bearers[i].bearer->blocked = 1;
eth_bearers[i].bearer = 0;
eth_bearers[i].bearer = NULL;
}
if (eth_bearers[i].dev) {
dev_remove_pack(&eth_bearers[i].tipc_packet_type);
Expand Down
28 changes: 14 additions & 14 deletions net/tipc/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
if (win <= 0)
break;
list_del_init(&p_ptr->wait_list);
p_ptr->congested_link = 0;
p_ptr->congested_link = NULL;
assert(p_ptr->wakeup);
spin_lock_bh(p_ptr->publ.lock);
p_ptr->publ.congested = 0;
Expand Down Expand Up @@ -1355,7 +1355,7 @@ static int link_send_sections_long(struct port *sender,
fragm_crs = 0;
fragm_rest = 0;
sect_rest = 0;
sect_crs = 0;
sect_crs = NULL;
curr_sect = -1;

/* Prepare reusable fragment header: */
Expand Down Expand Up @@ -1549,7 +1549,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
msg_dbg(buf_msg(buf), ">DEF-PROT>");
l_ptr->unacked_window = 0;
buf_discard(buf);
l_ptr->proto_msg_queue = 0;
l_ptr->proto_msg_queue = NULL;
return TIPC_OK;
} else {
msg_dbg(buf_msg(buf), "|>DEF-PROT>");
Expand Down Expand Up @@ -1860,7 +1860,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
struct sk_buff **tail,
struct sk_buff *buf)
{
struct sk_buff *prev = 0;
struct sk_buff *prev = NULL;
struct sk_buff *crs = *head;
u32 seq_no = msg_seqno(buf_msg(buf));

Expand Down Expand Up @@ -1953,7 +1953,7 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
u32 gap, u32 tolerance, u32 priority, u32 ack_mtu)
{
struct sk_buff *buf = 0;
struct sk_buff *buf = NULL;
struct tipc_msg *msg = l_ptr->pmsg;
u32 msg_size = sizeof(l_ptr->proto_msg);

Expand Down Expand Up @@ -2426,7 +2426,7 @@ static int link_recv_changeover_msg(struct link **l_ptr,
}
}
exit:
*buf = 0;
*buf = NULL;
buf_discard(tunnel_buf);
return 0;
}
Expand Down Expand Up @@ -2586,13 +2586,13 @@ static inline void incr_timer_cnt(struct sk_buff *buf)
int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
struct tipc_msg **m)
{
struct sk_buff *prev = 0;
struct sk_buff *prev = NULL;
struct sk_buff *fbuf = *fb;
struct tipc_msg *fragm = buf_msg(fbuf);
struct sk_buff *pbuf = *pending;
u32 long_msg_seq_no = msg_long_msgno(fragm);

*fb = 0;
*fb = NULL;
msg_dbg(fragm,"FRG<REC<");

/* Is there an incomplete message waiting for this fragment? */
Expand Down Expand Up @@ -2670,8 +2670,8 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,

static void link_check_defragm_bufs(struct link *l_ptr)
{
struct sk_buff *prev = 0;
struct sk_buff *next = 0;
struct sk_buff *prev = NULL;
struct sk_buff *next = NULL;
struct sk_buff *buf = l_ptr->defragm_buf;

if (!buf)
Expand Down Expand Up @@ -2750,19 +2750,19 @@ static struct link *link_find_link(const char *name, struct node **node)
struct link *l_ptr;

if (!link_name_validate(name, &link_name_parts))
return 0;
return NULL;

b_ptr = tipc_bearer_find_interface(link_name_parts.if_local);
if (!b_ptr)
return 0;
return NULL;

*node = tipc_node_find(link_name_parts.addr_peer);
if (!*node)
return 0;
return NULL;

l_ptr = (*node)->links[b_ptr->identity];
if (!l_ptr || strcmp(l_ptr->name, name))
return 0;
return NULL;

return l_ptr;
}
Expand Down
6 changes: 3 additions & 3 deletions net/tipc/name_distr.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ void tipc_named_withdraw(struct publication *publ)
void tipc_named_node_up(unsigned long node)
{
struct publication *publ;
struct distr_item *item = 0;
struct sk_buff *buf = 0;
struct distr_item *item = NULL;
struct sk_buff *buf = NULL;
u32 left = 0;
u32 rest;
u32 max_item_buf;
Expand Down Expand Up @@ -200,7 +200,7 @@ void tipc_named_node_up(unsigned long node)
"<%u.%u.%u>\n", tipc_zone(node),
tipc_cluster(node), tipc_node(node));
tipc_link_send(buf, node, node);
buf = 0;
buf = NULL;
}
}
exit:
Expand Down
Loading

0 comments on commit 1fc54d8

Please sign in to comment.