Skip to content

Commit 0e35fd5

Browse files
ajstephensdavem330
authored andcommitted
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>
1 parent 2da5991 commit 0e35fd5

9 files changed

Lines changed: 49 additions & 49 deletions

File tree

‎net/tipc/bcast.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
611611
bcbearer->bpairs[bp_index].secondary = p;
612612
update:
613613
if (bcbearer->remains_new.count == 0)
614-
return TIPC_OK;
614+
return 0;
615615

616616
bcbearer->remains = bcbearer->remains_new;
617617
}
@@ -620,7 +620,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
620620

621621
bcbearer->bearer.publ.blocked = 1;
622622
bcl->stats.bearer_congs++;
623-
return ~TIPC_OK;
623+
return 1;
624624
}
625625

626626
/**
@@ -756,7 +756,7 @@ int tipc_bclink_reset_stats(void)
756756
spin_lock_bh(&bc_lock);
757757
memset(&bcl->stats, 0, sizeof(bcl->stats));
758758
spin_unlock_bh(&bc_lock);
759-
return TIPC_OK;
759+
return 0;
760760
}
761761

762762
int tipc_bclink_set_queue_limits(u32 limit)
@@ -769,7 +769,7 @@ int tipc_bclink_set_queue_limits(u32 limit)
769769
spin_lock_bh(&bc_lock);
770770
tipc_link_set_queue_limits(bcl, limit);
771771
spin_unlock_bh(&bc_lock);
772-
return TIPC_OK;
772+
return 0;
773773
}
774774

775775
int tipc_bclink_init(void)
@@ -810,7 +810,7 @@ int tipc_bclink_init(void)
810810
tipc_printbuf_init(&bcl->print_buf, pb, BCLINK_LOG_BUF_SIZE);
811811
}
812812

813-
return TIPC_OK;
813+
return 0;
814814
}
815815

816816
void tipc_bclink_stop(void)

‎net/tipc/bearer.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void tipc_bearer_remove_dest(struct bearer *b_ptr, u32 dest)
370370
*/
371371
static int bearer_push(struct bearer *b_ptr)
372372
{
373-
u32 res = TIPC_OK;
373+
u32 res = 0;
374374
struct link *ln, *tln;
375375

376376
if (b_ptr->publ.blocked)
@@ -607,7 +607,7 @@ int tipc_block_bearer(const char *name)
607607
}
608608
spin_unlock_bh(&b_ptr->publ.lock);
609609
read_unlock_bh(&tipc_net_lock);
610-
return TIPC_OK;
610+
return 0;
611611
}
612612

613613
/**
@@ -645,7 +645,7 @@ static int bearer_disable(const char *name)
645645
}
646646
spin_unlock_bh(&b_ptr->publ.lock);
647647
memset(b_ptr, 0, sizeof(struct bearer));
648-
return TIPC_OK;
648+
return 0;
649649
}
650650

651651
int tipc_disable_bearer(const char *name)
@@ -668,7 +668,7 @@ int tipc_bearer_init(void)
668668
tipc_bearers = kcalloc(MAX_BEARERS, sizeof(struct bearer), GFP_ATOMIC);
669669
media_list = kcalloc(MAX_MEDIA, sizeof(struct media), GFP_ATOMIC);
670670
if (tipc_bearers && media_list) {
671-
res = TIPC_OK;
671+
res = 0;
672672
} else {
673673
kfree(tipc_bearers);
674674
kfree(media_list);

‎net/tipc/cluster.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,6 @@ void tipc_cltr_broadcast(struct sk_buff *buf)
571571
int tipc_cltr_init(void)
572572
{
573573
tipc_highest_allowed_slave = LOWEST_SLAVE + tipc_max_slaves;
574-
return tipc_cltr_create(tipc_own_addr) ? TIPC_OK : -ENOMEM;
574+
return tipc_cltr_create(tipc_own_addr) ? 0 : -ENOMEM;
575575
}
576576

‎net/tipc/eth_media.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
8282
dev->dev_addr, clone->len);
8383
dev_queue_xmit(clone);
8484
}
85-
return TIPC_OK;
85+
return 0;
8686
}
8787

8888
/**
@@ -113,12 +113,12 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
113113
if (likely(buf->len == size)) {
114114
buf->next = NULL;
115115
tipc_recv_msg(buf, eb_ptr->bearer);
116-
return TIPC_OK;
116+
return 0;
117117
}
118118
}
119119
}
120120
kfree_skb(buf);
121-
return TIPC_OK;
121+
return 0;
122122
}
123123

124124
/**

‎net/tipc/link.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
15611561
l_ptr->retransm_queue_head = mod(++r_q_head);
15621562
l_ptr->retransm_queue_size = --r_q_size;
15631563
l_ptr->stats.retransmitted++;
1564-
return TIPC_OK;
1564+
return 0;
15651565
} else {
15661566
l_ptr->stats.bearer_congs++;
15671567
msg_dbg(buf_msg(buf), "|>DEF-RETR>");
@@ -1580,7 +1580,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
15801580
l_ptr->unacked_window = 0;
15811581
buf_discard(buf);
15821582
l_ptr->proto_msg_queue = NULL;
1583-
return TIPC_OK;
1583+
return 0;
15841584
} else {
15851585
msg_dbg(buf_msg(buf), "|>DEF-PROT>");
15861586
l_ptr->stats.bearer_congs++;
@@ -1604,7 +1604,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
16041604
msg_set_type(msg, CLOSED_MSG);
16051605
msg_dbg(msg, ">PUSH-DATA>");
16061606
l_ptr->next_out = buf->next;
1607-
return TIPC_OK;
1607+
return 0;
16081608
} else {
16091609
msg_dbg(msg, "|PUSH-DATA|");
16101610
l_ptr->stats.bearer_congs++;
@@ -1628,8 +1628,8 @@ void tipc_link_push_queue(struct link *l_ptr)
16281628

16291629
do {
16301630
res = tipc_link_push_packet(l_ptr);
1631-
}
1632-
while (res == TIPC_OK);
1631+
} while (!res);
1632+
16331633
if (res == PUSH_FAILED)
16341634
tipc_bearer_schedule(l_ptr->b_ptr, l_ptr);
16351635
}
@@ -2998,7 +2998,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
29982998
link_set_supervision_props(l_ptr, new_value);
29992999
tipc_link_send_proto_msg(l_ptr, STATE_MSG,
30003000
0, 0, new_value, 0, 0);
3001-
res = TIPC_OK;
3001+
res = 0;
30023002
}
30033003
break;
30043004
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
30073007
l_ptr->priority = new_value;
30083008
tipc_link_send_proto_msg(l_ptr, STATE_MSG,
30093009
0, 0, 0, new_value, 0);
3010-
res = TIPC_OK;
3010+
res = 0;
30113011
}
30123012
break;
30133013
case TIPC_CMD_SET_LINK_WINDOW:
30143014
if ((new_value >= TIPC_MIN_LINK_WIN) &&
30153015
(new_value <= TIPC_MAX_LINK_WIN)) {
30163016
tipc_link_set_queue_limits(l_ptr, new_value);
3017-
res = TIPC_OK;
3017+
res = 0;
30183018
}
30193019
break;
30203020
}
@@ -3230,7 +3230,7 @@ int link_control(const char *name, u32 op, u32 val)
32303230
if (op == TIPC_CMD_UNBLOCK_LINK) {
32313231
l_ptr->blocked = 0;
32323232
}
3233-
res = TIPC_OK;
3233+
res = 0;
32343234
}
32353235
tipc_node_unlock(node);
32363236
}

‎net/tipc/net.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static int net_init(void)
165165
if (!tipc_net.zones) {
166166
return -ENOMEM;
167167
}
168-
return TIPC_OK;
168+
return 0;
169169
}
170170

171171
static void net_stop(void)
@@ -295,7 +295,7 @@ int tipc_net_start(u32 addr)
295295
info("Started in network mode\n");
296296
info("Own node address %s, network identity %u\n",
297297
addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
298-
return TIPC_OK;
298+
return 0;
299299
}
300300

301301
void tipc_net_stop(void)

‎net/tipc/port.c‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ int tipc_deleteport(u32 ref)
291291
kfree(p_ptr);
292292
dbg("Deleted port %u\n", ref);
293293
tipc_net_route_msg(buf);
294-
return TIPC_OK;
294+
return 0;
295295
}
296296

297297
/**
@@ -336,7 +336,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
336336
return -EINVAL;
337337
*isunreliable = port_unreliable(p_ptr);
338338
tipc_port_unlock(p_ptr);
339-
return TIPC_OK;
339+
return 0;
340340
}
341341

342342
int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
@@ -348,7 +348,7 @@ int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
348348
return -EINVAL;
349349
msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0));
350350
tipc_port_unlock(p_ptr);
351-
return TIPC_OK;
351+
return 0;
352352
}
353353

354354
static int port_unreturnable(struct port *p_ptr)
@@ -365,7 +365,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
365365
return -EINVAL;
366366
*isunrejectable = port_unreturnable(p_ptr);
367367
tipc_port_unlock(p_ptr);
368-
return TIPC_OK;
368+
return 0;
369369
}
370370

371371
int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
@@ -377,7 +377,7 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
377377
return -EINVAL;
378378
msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0));
379379
tipc_port_unlock(p_ptr);
380-
return TIPC_OK;
380+
return 0;
381381
}
382382

383383
/*
@@ -963,7 +963,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
963963
tipc_k_signal((Handler)port_dispatcher_sigh, 0);
964964
}
965965
spin_unlock_bh(&queue_lock);
966-
return TIPC_OK;
966+
return 0;
967967
}
968968

969969
/*
@@ -1068,14 +1068,14 @@ int tipc_createport(u32 user_ref,
10681068
tipc_reg_add_port(up_ptr);
10691069
*portref = p_ptr->publ.ref;
10701070
tipc_port_unlock(p_ptr);
1071-
return TIPC_OK;
1071+
return 0;
10721072
}
10731073

10741074
int tipc_ownidentity(u32 ref, struct tipc_portid *id)
10751075
{
10761076
id->ref = ref;
10771077
id->node = tipc_own_addr;
1078-
return TIPC_OK;
1078+
return 0;
10791079
}
10801080

10811081
int tipc_portimportance(u32 ref, unsigned int *importance)
@@ -1087,7 +1087,7 @@ int tipc_portimportance(u32 ref, unsigned int *importance)
10871087
return -EINVAL;
10881088
*importance = (unsigned int)msg_importance(&p_ptr->publ.phdr);
10891089
tipc_port_unlock(p_ptr);
1090-
return TIPC_OK;
1090+
return 0;
10911091
}
10921092

10931093
int tipc_set_portimportance(u32 ref, unsigned int imp)
@@ -1102,7 +1102,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
11021102
return -EINVAL;
11031103
msg_set_importance(&p_ptr->publ.phdr, (u32)imp);
11041104
tipc_port_unlock(p_ptr);
1105-
return TIPC_OK;
1105+
return 0;
11061106
}
11071107

11081108

@@ -1137,7 +1137,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
11371137
list_add(&publ->pport_list, &p_ptr->publications);
11381138
p_ptr->pub_count++;
11391139
p_ptr->publ.published = 1;
1140-
res = TIPC_OK;
1140+
res = 0;
11411141
}
11421142
exit:
11431143
tipc_port_unlock(p_ptr);
@@ -1160,7 +1160,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
11601160
tipc_nametbl_withdraw(publ->type, publ->lower,
11611161
publ->ref, publ->key);
11621162
}
1163-
res = TIPC_OK;
1163+
res = 0;
11641164
} else {
11651165
list_for_each_entry_safe(publ, tpubl,
11661166
&p_ptr->publications, pport_list) {
@@ -1174,7 +1174,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
11741174
break;
11751175
tipc_nametbl_withdraw(publ->type, publ->lower,
11761176
publ->ref, publ->key);
1177-
res = TIPC_OK;
1177+
res = 0;
11781178
break;
11791179
}
11801180
}
@@ -1218,7 +1218,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
12181218
tipc_nodesub_subscribe(&p_ptr->subscription,peer->node,
12191219
(void *)(unsigned long)ref,
12201220
(net_ev_handler)port_handle_node_down);
1221-
res = TIPC_OK;
1221+
res = 0;
12221222
exit:
12231223
tipc_port_unlock(p_ptr);
12241224
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)
12401240
/* let timer expire on it's own to avoid deadlock! */
12411241
tipc_nodesub_unsubscribe(
12421242
&((struct port *)tp_ptr)->subscription);
1243-
res = TIPC_OK;
1243+
res = 0;
12441244
} else {
12451245
res = -ENOTCONN;
12461246
}
@@ -1305,7 +1305,7 @@ int tipc_isconnected(u32 ref, int *isconnected)
13051305
return -EINVAL;
13061306
*isconnected = p_ptr->publ.connected;
13071307
tipc_port_unlock(p_ptr);
1308-
return TIPC_OK;
1308+
return 0;
13091309
}
13101310

13111311
int tipc_peer(u32 ref, struct tipc_portid *peer)
@@ -1319,7 +1319,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer)
13191319
if (p_ptr->publ.connected) {
13201320
peer->ref = port_peerport(p_ptr);
13211321
peer->node = port_peernode(p_ptr);
1322-
res = TIPC_OK;
1322+
res = 0;
13231323
} else
13241324
res = -ENOTCONN;
13251325
tipc_port_unlock(p_ptr);

‎net/tipc/ref.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int tipc_ref_table_init(u32 requested_size, u32 start)
123123
tipc_ref_table.index_mask = actual_size - 1;
124124
tipc_ref_table.start_mask = start & ~tipc_ref_table.index_mask;
125125

126-
return TIPC_OK;
126+
return 0;
127127
}
128128

129129
/**

0 commit comments

Comments
 (0)