tipc: Eliminate improper use of TIPC_OK error code

This patch corrects many places where TIPC routines indicated
successful completion by returning TIPC_OK instead of 0.
(The TIPC_OK symbol has the value 0, but it should only be used
in contexts that deal with the error code field of a TIPC
message header.)

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Allan Stephens 2008-07-14 22:44:01 -07:00 committed by David S. Miller
parent 2da59918e2
commit 0e35fd5e52
9 changed files with 49 additions and 49 deletions

View file

@ -611,7 +611,7 @@ swap:
bcbearer->bpairs[bp_index].secondary = p; bcbearer->bpairs[bp_index].secondary = p;
update: update:
if (bcbearer->remains_new.count == 0) if (bcbearer->remains_new.count == 0)
return TIPC_OK; return 0;
bcbearer->remains = bcbearer->remains_new; bcbearer->remains = bcbearer->remains_new;
} }
@ -620,7 +620,7 @@ update:
bcbearer->bearer.publ.blocked = 1; bcbearer->bearer.publ.blocked = 1;
bcl->stats.bearer_congs++; bcl->stats.bearer_congs++;
return ~TIPC_OK; return 1;
} }
/** /**
@ -756,7 +756,7 @@ int tipc_bclink_reset_stats(void)
spin_lock_bh(&bc_lock); spin_lock_bh(&bc_lock);
memset(&bcl->stats, 0, sizeof(bcl->stats)); memset(&bcl->stats, 0, sizeof(bcl->stats));
spin_unlock_bh(&bc_lock); spin_unlock_bh(&bc_lock);
return TIPC_OK; return 0;
} }
int tipc_bclink_set_queue_limits(u32 limit) int tipc_bclink_set_queue_limits(u32 limit)
@ -769,7 +769,7 @@ int tipc_bclink_set_queue_limits(u32 limit)
spin_lock_bh(&bc_lock); spin_lock_bh(&bc_lock);
tipc_link_set_queue_limits(bcl, limit); tipc_link_set_queue_limits(bcl, limit);
spin_unlock_bh(&bc_lock); spin_unlock_bh(&bc_lock);
return TIPC_OK; return 0;
} }
int tipc_bclink_init(void) int tipc_bclink_init(void)
@ -810,7 +810,7 @@ int tipc_bclink_init(void)
tipc_printbuf_init(&bcl->print_buf, pb, BCLINK_LOG_BUF_SIZE); tipc_printbuf_init(&bcl->print_buf, pb, BCLINK_LOG_BUF_SIZE);
} }
return TIPC_OK; return 0;
} }
void tipc_bclink_stop(void) void tipc_bclink_stop(void)

View file

@ -370,7 +370,7 @@ void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest)
*/ */
static int bearer_push(struct bearer *b_ptr) static int bearer_push(struct bearer *b_ptr)
{ {
u32 res = TIPC_OK; u32 res = 0;
struct link *ln, *tln; struct link *ln, *tln;
if (b_ptr->publ.blocked) if (b_ptr->publ.blocked)
@ -607,7 +607,7 @@ int tipc_block_bearer(const char *name)
} }
spin_unlock_bh(&b_ptr->publ.lock); spin_unlock_bh(&b_ptr->publ.lock);
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
return TIPC_OK; return 0;
} }
/** /**
@ -645,7 +645,7 @@ static int bearer_disable(const char *name)
} }
spin_unlock_bh(&b_ptr->publ.lock); spin_unlock_bh(&b_ptr->publ.lock);
memset(b_ptr, 0, sizeof(struct bearer)); memset(b_ptr, 0, sizeof(struct bearer));
return TIPC_OK; return 0;
} }
int tipc_disable_bearer(const char *name) int tipc_disable_bearer(const char *name)
@ -668,7 +668,7 @@ int tipc_bearer_init(void)
tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC); tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC);
media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC); media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC);
if (tipc_bearers && media_list) { if (tipc_bearers && media_list) {
res = TIPC_OK; res = 0;
} else { } else {
kfree(tipc_bearers); kfree(tipc_bearers);
kfree(media_list); kfree(media_list);

View file

@ -571,6 +571,6 @@ exit:
int tipc_cltr_init(void) int tipc_cltr_init(void)
{ {
tipc_highest_allowed_slave = LOWEST_SLAVE + tipc_max_slaves; tipc_highest_allowed_slave = LOWEST_SLAVE + tipc_max_slaves;
return tipc_cltr_create(tipc_own_addr) ? TIPC_OK : -ENOMEM; return tipc_cltr_create(tipc_own_addr) ? 0 : -ENOMEM;
} }

View file

@ -82,7 +82,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
dev->dev_addr, clone->len); dev->dev_addr, clone->len);
dev_queue_xmit(clone); dev_queue_xmit(clone);
} }
return TIPC_OK; return 0;
} }
/** /**
@ -113,12 +113,12 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
if (likely(buf->len == size)) { if (likely(buf->len == size)) {
buf->next = NULL; buf->next = NULL;
tipc_recv_msg(buf, eb_ptr->bearer); tipc_recv_msg(buf, eb_ptr->bearer);
return TIPC_OK; return 0;
} }
} }
} }
kfree_skb(buf); kfree_skb(buf);
return TIPC_OK; return 0;
} }
/** /**

View file

@ -1561,7 +1561,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
l_ptr->retransm_queue_head = mod(++r_q_head); l_ptr->retransm_queue_head = mod(++r_q_head);
l_ptr->retransm_queue_size = --r_q_size; l_ptr->retransm_queue_size = --r_q_size;
l_ptr->stats.retransmitted++; l_ptr->stats.retransmitted++;
return TIPC_OK; return 0;
} else { } else {
l_ptr->stats.bearer_congs++; l_ptr->stats.bearer_congs++;
msg_dbg(buf_msg(buf), "|>DEF-RETR>"); msg_dbg(buf_msg(buf), "|>DEF-RETR>");
@ -1580,7 +1580,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
l_ptr->unacked_window = 0; l_ptr->unacked_window = 0;
buf_discard(buf); buf_discard(buf);
l_ptr->proto_msg_queue = NULL; l_ptr->proto_msg_queue = NULL;
return TIPC_OK; return 0;
} else { } else {
msg_dbg(buf_msg(buf), "|>DEF-PROT>"); msg_dbg(buf_msg(buf), "|>DEF-PROT>");
l_ptr->stats.bearer_congs++; l_ptr->stats.bearer_congs++;
@ -1604,7 +1604,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
msg_set_type(msg, CLOSED_MSG); msg_set_type(msg, CLOSED_MSG);
msg_dbg(msg, ">PUSH-DATA>"); msg_dbg(msg, ">PUSH-DATA>");
l_ptr->next_out = buf->next; l_ptr->next_out = buf->next;
return TIPC_OK; return 0;
} else { } else {
msg_dbg(msg, "|PUSH-DATA|"); msg_dbg(msg, "|PUSH-DATA|");
l_ptr->stats.bearer_congs++; l_ptr->stats.bearer_congs++;
@ -1628,8 +1628,8 @@ void tipc_link_push_queue(struct link *l_ptr)
do { do {
res = tipc_link_push_packet(l_ptr); res = tipc_link_push_packet(l_ptr);
} } while (!res);
while (res == TIPC_OK);
if (res == PUSH_FAILED) if (res == PUSH_FAILED)
tipc_bearer_schedule(l_ptr->b_ptr, l_ptr); tipc_bearer_schedule(l_ptr->b_ptr, l_ptr);
} }
@ -2998,7 +2998,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
link_set_supervision_props(l_ptr, new_value); link_set_supervision_props(l_ptr, new_value);
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
0, 0, new_value, 0, 0); 0, 0, new_value, 0, 0);
res = TIPC_OK; res = 0;
} }
break; break;
case TIPC_CMD_SET_LINK_PRI: case TIPC_CMD_SET_LINK_PRI:
@ -3007,14 +3007,14 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
l_ptr->priority = new_value; l_ptr->priority = new_value;
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
0, 0, 0, new_value, 0); 0, 0, 0, new_value, 0);
res = TIPC_OK; res = 0;
} }
break; break;
case TIPC_CMD_SET_LINK_WINDOW: case TIPC_CMD_SET_LINK_WINDOW:
if ((new_value >= TIPC_MIN_LINK_WIN) && if ((new_value >= TIPC_MIN_LINK_WIN) &&
(new_value <= TIPC_MAX_LINK_WIN)) { (new_value <= TIPC_MAX_LINK_WIN)) {
tipc_link_set_queue_limits(l_ptr, new_value); tipc_link_set_queue_limits(l_ptr, new_value);
res = TIPC_OK; res = 0;
} }
break; break;
} }
@ -3230,7 +3230,7 @@ int link_control(const char *name, u32 op, u32 val)
if (op == TIPC_CMD_UNBLOCK_LINK) { if (op == TIPC_CMD_UNBLOCK_LINK) {
l_ptr->blocked = 0; l_ptr->blocked = 0;
} }
res = TIPC_OK; res = 0;
} }
tipc_node_unlock(node); tipc_node_unlock(node);
} }

View file

@ -165,7 +165,7 @@ static int net_init(void)
if (!tipc_net.zones) { if (!tipc_net.zones) {
return -ENOMEM; return -ENOMEM;
} }
return TIPC_OK; return 0;
} }
static void net_stop(void) static void net_stop(void)
@ -295,7 +295,7 @@ int tipc_net_start(u32 addr)
info("Started in network mode\n"); info("Started in network mode\n");
info("Own node address %s, network identity %u\n", info("Own node address %s, network identity %u\n",
addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
return TIPC_OK; return 0;
} }
void tipc_net_stop(void) void tipc_net_stop(void)

View file

@ -291,7 +291,7 @@ int tipc_deleteport(u32 ref)
kfree(p_ptr); kfree(p_ptr);
dbg("Deleted port %u\n", ref); dbg("Deleted port %u\n", ref);
tipc_net_route_msg(buf); tipc_net_route_msg(buf);
return TIPC_OK; return 0;
} }
/** /**
@ -336,7 +336,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
return -EINVAL; return -EINVAL;
*isunreliable = port_unreliable(p_ptr); *isunreliable = port_unreliable(p_ptr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
@ -348,7 +348,7 @@ int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
return -EINVAL; return -EINVAL;
msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0)); msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0));
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
static int port_unreturnable(struct port *p_ptr) static int port_unreturnable(struct port *p_ptr)
@ -365,7 +365,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
return -EINVAL; return -EINVAL;
*isunrejectable = port_unreturnable(p_ptr); *isunrejectable = port_unreturnable(p_ptr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
@ -377,7 +377,7 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
return -EINVAL; return -EINVAL;
msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0)); msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0));
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
/* /*
@ -963,7 +963,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
tipc_k_signal((Handler)port_dispatcher_sigh, 0); tipc_k_signal((Handler)port_dispatcher_sigh, 0);
} }
spin_unlock_bh(&queue_lock); spin_unlock_bh(&queue_lock);
return TIPC_OK; return 0;
} }
/* /*
@ -1068,14 +1068,14 @@ int tipc_createport(u32 user_ref,
tipc_reg_add_port(up_ptr); tipc_reg_add_port(up_ptr);
*portref = p_ptr->publ.ref; *portref = p_ptr->publ.ref;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
int tipc_ownidentity(u32 ref, struct tipc_portid *id) int tipc_ownidentity(u32 ref, struct tipc_portid *id)
{ {
id->ref = ref; id->ref = ref;
id->node = tipc_own_addr; id->node = tipc_own_addr;
return TIPC_OK; return 0;
} }
int tipc_portimportance(u32 ref, unsigned int *importance) int tipc_portimportance(u32 ref, unsigned int *importance)
@ -1087,7 +1087,7 @@ int tipc_portimportance(u32 ref, unsigned int *importance)
return -EINVAL; return -EINVAL;
*importance = (unsigned int)msg_importance(&p_ptr->publ.phdr); *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
int tipc_set_portimportance(u32 ref, unsigned int imp) int tipc_set_portimportance(u32 ref, unsigned int imp)
@ -1102,7 +1102,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
return -EINVAL; return -EINVAL;
msg_set_importance(&p_ptr->publ.phdr, (u32)imp); msg_set_importance(&p_ptr->publ.phdr, (u32)imp);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
@ -1137,7 +1137,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
list_add(&publ->pport_list, &p_ptr->publications); list_add(&publ->pport_list, &p_ptr->publications);
p_ptr->pub_count++; p_ptr->pub_count++;
p_ptr->publ.published = 1; p_ptr->publ.published = 1;
res = TIPC_OK; res = 0;
} }
exit: exit:
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
@ -1160,7 +1160,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
tipc_nametbl_withdraw(publ->type, publ->lower, tipc_nametbl_withdraw(publ->type, publ->lower,
publ->ref, publ->key); publ->ref, publ->key);
} }
res = TIPC_OK; res = 0;
} else { } else {
list_for_each_entry_safe(publ, tpubl, list_for_each_entry_safe(publ, tpubl,
&p_ptr->publications, pport_list) { &p_ptr->publications, pport_list) {
@ -1174,7 +1174,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
break; break;
tipc_nametbl_withdraw(publ->type, publ->lower, tipc_nametbl_withdraw(publ->type, publ->lower,
publ->ref, publ->key); publ->ref, publ->key);
res = TIPC_OK; res = 0;
break; break;
} }
} }
@ -1218,7 +1218,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
tipc_nodesub_subscribe(&p_ptr->subscription,peer->node, tipc_nodesub_subscribe(&p_ptr->subscription,peer->node,
(void *)(unsigned long)ref, (void *)(unsigned long)ref,
(net_ev_handler)port_handle_node_down); (net_ev_handler)port_handle_node_down);
res = TIPC_OK; res = 0;
exit: exit:
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref); p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref);
@ -1240,7 +1240,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
/* let timer expire on it's own to avoid deadlock! */ /* let timer expire on it's own to avoid deadlock! */
tipc_nodesub_unsubscribe( tipc_nodesub_unsubscribe(
&((struct port *)tp_ptr)->subscription); &((struct port *)tp_ptr)->subscription);
res = TIPC_OK; res = 0;
} else { } else {
res = -ENOTCONN; res = -ENOTCONN;
} }
@ -1305,7 +1305,7 @@ int tipc_isconnected(u32 ref, int *isconnected)
return -EINVAL; return -EINVAL;
*isconnected = p_ptr->publ.connected; *isconnected = p_ptr->publ.connected;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return 0;
} }
int tipc_peer(u32 ref, struct tipc_portid *peer) int tipc_peer(u32 ref, struct tipc_portid *peer)
@ -1319,7 +1319,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer)
if (p_ptr->publ.connected) { if (p_ptr->publ.connected) {
peer->ref = port_peerport(p_ptr); peer->ref = port_peerport(p_ptr);
peer->node = port_peernode(p_ptr); peer->node = port_peernode(p_ptr);
res = TIPC_OK; res = 0;
} else } else
res = -ENOTCONN; res = -ENOTCONN;
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);

View file

@ -123,7 +123,7 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
tipc_ref_table.index_mask = actual_size - 1; tipc_ref_table.index_mask = actual_size - 1;
tipc_ref_table.start_mask = start & ~tipc_ref_table.index_mask; tipc_ref_table.start_mask = start & ~tipc_ref_table.index_mask;
return TIPC_OK; return 0;
} }
/** /**

View file

@ -91,7 +91,7 @@ static int reg_init(void)
} }
} }
spin_unlock_bh(&reg_lock); spin_unlock_bh(&reg_lock);
return users ? TIPC_OK : -ENOMEM; return users ? 0 : -ENOMEM;
} }
/** /**
@ -129,7 +129,7 @@ int tipc_reg_start(void)
tipc_k_signal((Handler)reg_callback, tipc_k_signal((Handler)reg_callback,
(unsigned long)&users[u]); (unsigned long)&users[u]);
} }
return TIPC_OK; return 0;
} }
/** /**
@ -184,7 +184,7 @@ int tipc_attach(u32 *userid, tipc_mode_event cb, void *usr_handle)
if (cb && (tipc_mode != TIPC_NOT_RUNNING)) if (cb && (tipc_mode != TIPC_NOT_RUNNING))
tipc_k_signal((Handler)reg_callback, (unsigned long)user_ptr); tipc_k_signal((Handler)reg_callback, (unsigned long)user_ptr);
return TIPC_OK; return 0;
} }
/** /**
@ -230,7 +230,7 @@ int tipc_reg_add_port(struct user_port *up_ptr)
struct tipc_user *user_ptr; struct tipc_user *user_ptr;
if (up_ptr->user_ref == 0) if (up_ptr->user_ref == 0)
return TIPC_OK; return 0;
if (up_ptr->user_ref > MAX_USERID) if (up_ptr->user_ref > MAX_USERID)
return -EINVAL; return -EINVAL;
if ((tipc_mode == TIPC_NOT_RUNNING) || !users ) if ((tipc_mode == TIPC_NOT_RUNNING) || !users )
@ -240,7 +240,7 @@ int tipc_reg_add_port(struct user_port *up_ptr)
user_ptr = &users[up_ptr->user_ref]; user_ptr = &users[up_ptr->user_ref];
list_add(&up_ptr->uport_list, &user_ptr->ports); list_add(&up_ptr->uport_list, &user_ptr->ports);
spin_unlock_bh(&reg_lock); spin_unlock_bh(&reg_lock);
return TIPC_OK; return 0;
} }
/** /**
@ -250,7 +250,7 @@ int tipc_reg_add_port(struct user_port *up_ptr)
int tipc_reg_remove_port(struct user_port *up_ptr) int tipc_reg_remove_port(struct user_port *up_ptr)
{ {
if (up_ptr->user_ref == 0) if (up_ptr->user_ref == 0)
return TIPC_OK; return 0;
if (up_ptr->user_ref > MAX_USERID) if (up_ptr->user_ref > MAX_USERID)
return -EINVAL; return -EINVAL;
if (!users ) if (!users )
@ -259,6 +259,6 @@ int tipc_reg_remove_port(struct user_port *up_ptr)
spin_lock_bh(&reg_lock); spin_lock_bh(&reg_lock);
list_del_init(&up_ptr->uport_list); list_del_init(&up_ptr->uport_list);
spin_unlock_bh(&reg_lock); spin_unlock_bh(&reg_lock);
return TIPC_OK; return 0;
} }