Commit 1fc54d8f authored by Sam Ravnborg's avatar Sam Ravnborg Committed by David S. Miller
Browse files

[TIPC]: Fix simple sparse warnings



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: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarPer Liden <per.liden@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edb2c34f
......@@ -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 {
......
......@@ -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
......@@ -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;
}
/**
......@@ -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;
}
/**
......@@ -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;
}
/**
......@@ -569,7 +569,7 @@ failed:
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;
......@@ -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);
......@@ -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;
}
......
......@@ -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;
......@@ -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);
......@@ -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))
......@@ -91,7 +91,7 @@ struct cluster *tipc_cltr_create(u32 addr)
}
else {
kfree(c_ptr);
c_ptr = 0;
c_ptr = NULL;
}
return c_ptr;
......@@ -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) {
......@@ -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;
}
/*
......
......@@ -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
......@@ -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);
......
......@@ -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;
}
......@@ -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);
......
......@@ -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;
}
/**
......@@ -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);
......
......@@ -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;
......@@ -1355,7 +1355,7 @@ again:
fragm_crs = 0;
fragm_rest = 0;
sect_rest = 0;
sect_crs = 0;
sect_crs = NULL;
curr_sect = -1;
/* Prepare reusable fragment header: */
......@@ -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>");
......@@ -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));
......@@ -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);
......@@ -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;
}
......@@ -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? */
......@@ -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)
......@@ -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;
}
......
......@@ -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;
......@@ -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:
......
......@@ -121,7 +121,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper,
(struct publication *)kmalloc(sizeof(*publ), GFP_ATOMIC);
if (publ == NULL) {
warn("Memory squeeze; failed to create publication\n");
return 0;
return NULL;
}
memset(publ, 0, sizeof(*publ));
......@@ -168,7 +168,7 @@ struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_head)
warn("Memory squeeze; failed to create name sequence\n");
kfree(nseq);
kfree(sseq);
return 0;
return NULL;
}
memset(nseq, 0, sizeof(*nseq));
......@@ -207,7 +207,7 @@ static inline struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
else
return &sseqs[mid];
}
return 0;
return NULL;
}
/**
......@@ -263,7 +263,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
if ((sseq->lower != lower) || (sseq->upper != upper)) {
warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper);
return 0;
return NULL;
}
} else {
u32 inspos;
......@@ -278,7 +278,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
if ((inspos < nseq->first_free) &&
(upper >= nseq->sseqs[inspos].lower)) {
warn("Overlapping publ <%u,%u,%u>\n", type, lower, upper);
return 0;
return NULL;
}
/* Ensure there is space for new sub-sequence */
......@@ -294,7 +294,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
nseq->alloc *= 2;
} else {
warn("Memory squeeze; failed to create sub-sequence\n");
return 0;
return NULL;
}
}
dbg("Have %u sseqs for type %u\n", nseq->alloc, type);
......@@ -319,7 +319,7 @@ struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
publ = publ_create(type, lower, upper, scope, node, port, key);
if (!publ)
return 0;
return NULL;
dbg("inserting publ %x, node=%x publ->node=%x, subscr->node=%x\n",
publ, node, publ->node, publ->subscr.node);
......@@ -394,7 +394,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst,
i, &nseq->sseqs[i], nseq->sseqs[i].lower,
nseq->sseqs[i].upper);
}
return 0;
return NULL;
}
dbg("nameseq_remove: seq: %x, sseq %x, <%u,%u> key %u\n",
nseq, sseq, nseq->type, inst, key);
......@@ -413,7 +413,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst,
prev->zone_list_next = publ->zone_list_next;
sseq->zone_list = publ->zone_list_next;
} else {
sseq->zone_list = 0;
sseq->zone_list = NULL;
}
if (in_own_cluster(node)) {
......@@ -431,7 +431,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst,
prev->cluster_list_next = publ->cluster_list_next;
sseq->cluster_list = publ->cluster_list_next;
} else {
sseq->cluster_list = 0;
sseq->cluster_list = NULL;
}
}
......@@ -450,7 +450,7 @@ struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 inst,
prev->node_list_next = publ->node_list_next;
sseq->node_list = publ->node_list_next;
} else {
sseq->node_list = 0;
sseq->node_list = NULL;
}
}
assert(!publ->node || (publ->node == node));
......@@ -535,7 +535,7 @@ static struct name_seq *nametbl_find_seq(u32 type)
}
}
return 0;
return NULL;
};
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
......@@ -547,7 +547,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
if (lower > upper) {
warn("Failed to publish illegal <%u,%u,%u>\n",
type, lower, upper);
return 0;
return NULL;
}
dbg("Publishing <%u,%u,%u> from %x\n", type, lower, upper, node);
......@@ -556,7 +556,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
dbg("tipc_nametbl_insert_publ: created %x\n", seq);
}
if (!seq)
return 0;
return NULL;
assert(seq->type == type);
return tipc_nameseq_insert_publ(seq, type, lower, upper,
......@@ -570,7 +570,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
struct name_seq *seq = nametbl_find_seq(type);
if (!seq)
return 0;
return NULL;
dbg("Withdrawing <%u,%u> from %x\n", type, lower, node);
publ = tipc_nameseq_remove_publ(seq, lower, node, ref, key);
......@@ -594,7 +594,7 @@ struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
{
struct sub_seq *sseq;
struct publication *publ = 0;
struct publication *publ = NULL;
struct name_seq *seq;
u32 ref;
......@@ -740,12 +740,12 @@ struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
if (table.local_publ_count >= tipc_max_publications) {
warn("Failed publish: max %u local publication\n",
tipc_max_publications);
return 0;
return NULL;
}
if ((type < TIPC_RESERVED_TYPES) && !atomic_read(&rsv_publ_ok)) {
warn("Failed to publish reserved name <%u,%u,%u>\n",
type, lower, upper);
return 0;
return NULL;
}
write_lock_bh(&tipc_nametbl_lock);
......
......@@ -116,7 +116,7 @@
*/
rwlock_t tipc_net_lock = RW_LOCK_UNLOCKED;
struct network tipc_net = { 0 };
struct network tipc_net = { NULL };
struct node *tipc_net_select_remote_node(u32 addr, u32 ref)
{
......@@ -181,7 +181,7 @@ static void net_stop(void)
tipc_zone_delete(tipc_net.zones[z_num]);
}
kfree(tipc_net.zones);
tipc_net.zones = 0;
tipc_net.zones = NULL;
}
static void net_route_named_msg(struct sk_buff *buf)
......
......@@ -155,7 +155,7 @@ static void node_select_active_links(struct node *n_ptr)
u32 i;
u32 highest_prio = 0;
active[0] = active[1] = 0;
active[0] = active[1] = NULL;
for (i = 0; i < MAX_BEARERS; i++) {
struct link *l_ptr = n_ptr->links[i];
......@@ -240,7 +240,7 @@ struct node *tipc_node_attach_link(struct link *l_ptr)
err("Attempt to create third link to %s\n",
addr_string_fill(addr_string, n_ptr->addr));
return 0;
return NULL;
}
if (!n_ptr->links[bearer_id]) {
......@@ -253,12 +253,12 @@ struct node *tipc_node_attach_link(struct link *l_ptr)
l_ptr->b_ptr->publ.name,
addr_string_fill(addr_string, l_ptr->addr));
}
return 0;
return NULL;
}
void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
{
n_ptr->links[l_ptr->b_ptr->identity] = 0;
n_ptr->links[l_ptr->b_ptr->identity] = NULL;
tipc_net.zones[tipc_zone(l_ptr->addr)]->links--;
n_ptr->link_cnt--;
}
......@@ -424,7 +424,7 @@ static void node_lost_contact(struct node *n_ptr)
/* Notify subscribers */
list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) {
ns->node = 0;
ns->node = NULL;
list_del_init(&ns->nodesub_list);
tipc_k_signal((Handler)ns->handle_node_down,
(unsigned long)ns->usr_handle);
......@@ -443,7 +443,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
u32 router_addr;
if (!tipc_addr_domain_valid(addr))
return 0;
return NULL;
/* Look for direct link to destination processsor */
n_ptr = tipc_node_find(addr);
......@@ -452,7 +452,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
/* Cluster local system nodes *must* have direct links */
if (!is_slave(addr) && in_own_cluster(addr))
return 0;
return NULL;
/* Look for cluster local router with direct link to node */
router_addr = tipc_node_select_router(n_ptr, selector);
......@@ -462,7 +462,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
/* Slave nodes can only be accessed within own cluster via a
known router with direct link -- if no router was found,give up */
if (is_slave(addr))
return 0;
return NULL;
/* Inter zone/cluster -- find any direct link to remote cluster */
addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
......@@ -475,7 +475,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
if (router_addr)
return tipc_node_select(router_addr, selector);
return 0;
return NULL;
}
/**
......
......@@ -121,7 +121,7 @@ static inline struct node *tipc_node_find(u32 addr)
if (c_ptr)
return c_ptr->nodes[tipc_node(addr)];
}
return 0;
return NULL;
}
static inline struct node *tipc_node_select(u32 addr, u32 selector)
......
......@@ -47,7 +47,7 @@
void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr,
void *usr_handle, net_ev_handler handle_down)
{
node_sub->node = 0;
node_sub->node = NULL;
if (addr == tipc_own_addr)
return;
if (!tipc_addr_node_valid(addr)) {
......
......@@ -54,8 +54,8 @@
#define MAX_REJECT_SIZE 1024
static struct sk_buff *msg_queue_head = 0;
static struct sk_buff *msg_queue_tail = 0;
static struct sk_buff *msg_queue_head = NULL;
static struct sk_buff *msg_queue_tail = NULL;
spinlock_t tipc_port_list_lock = SPIN_LOCK_UNLOCKED;
static spinlock_t queue_lock = SPIN_LOCK_UNLOCKED;
......@@ -258,11 +258,11 @@ u32 tipc_createport_raw(void *usr_handle,
p_ptr->publ.usr_handle = usr_handle;
INIT_LIST_HEAD(&p_ptr->wait_list);
INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
p_ptr->congested_link = 0;
p_ptr->congested_link = NULL;
p_ptr->max_pkt = MAX_PKT_DEFAULT;
p_ptr->dispatcher = dispatcher;
p_ptr->wakeup = wakeup;
p_ptr->user_port = 0;
p_ptr->user_port = NULL;
k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref);
spin_lock_bh(&tipc_port_list_lock);
INIT_LIST_HEAD(&p_ptr->publications);
......@@ -276,9 +276,9 @@ u32 tipc_createport_raw(void *usr_handle,
int tipc_deleteport(u32 ref)
{
struct port *p_ptr;
struct sk_buff *buf = 0;
struct sk_buff *buf = NULL;
tipc_withdraw(ref, 0, 0);
tipc_withdraw(ref, 0, NULL);
p_ptr = tipc_port_lock(ref);
if (!p_ptr)
return -EINVAL;
......@@ -329,7 +329,7 @@ void *tipc_get_handle(const u32 ref)
p_ptr = tipc_port_lock(ref);
if (!p_ptr)
return 0;
return NULL;
handle = p_ptr->publ.usr_handle;
tipc_port_unlock(p_ptr);
return handle;
......@@ -475,7 +475,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)