Skip to content

Commit

Permalink
ibdiags: Use NULL instead of 0 in all places where it used as a pointer
Browse files Browse the repository at this point in the history
Standard coding style. Found by sparse.

Reviewed-by: Nicolas Morey-Chaisemartin <NMoreyChaisemartin@suse.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
  • Loading branch information
jgunthorpe authored and weiny2 committed Apr 15, 2019
1 parent 511eaed commit c5489ce
Show file tree
Hide file tree
Showing 33 changed files with 144 additions and 144 deletions.
2 changes: 1 addition & 1 deletion libibmad/src/bm.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call,
return NULL;
}

if (mad_send_via(&rpc, portid, 0, &bm_data, srcport) < 0)
if (mad_send_via(&rpc, portid, NULL, &bm_data, srcport) < 0)
return NULL;

return_ok:
Expand Down
2 changes: 1 addition & 1 deletion libibmad/src/fields.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
{
if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_)
return NULL;
return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val);
return _mad_dump_field(ib_mad_f + field, NULL, buf, bufsz, val);
}

char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val)
Expand Down
6 changes: 3 additions & 3 deletions libibmad/src/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ uint64_t mad_trid(void)
uint64_t next;

if (!trid) {
srandom((int)time(0) * getpid());
srandom((int)time(NULL) * getpid());
trid = random();
}
next = ++trid;
Expand Down Expand Up @@ -189,11 +189,11 @@ int mad_build_pkt(void *umad, ib_rpc_t * rpc, ib_portid_t * dport,
addr.flow_label = 0;
umad_set_grh(umad, &addr);
} else
umad_set_grh(umad, 0);
umad_set_grh(umad, NULL);
umad_set_pkey(umad, is_smi ? 0 : dport->pkey_idx);

mad = umad_get_mad(umad);
p = mad_encode(mad, rpc, lid_routed ? 0 : &dport->drpath, data);
p = mad_encode(mad, rpc, lid_routed ? NULL : &dport->drpath, data);
if (!p)
return -1;

Expand Down
2 changes: 1 addition & 1 deletion libibmad/src/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int mad_register_port_client(int port_id, int mgmt, uint8_t rmpp_version)
return -1;
}

agent = umad_register(port_id, mgmt, vers, rmpp_version, 0);
agent = umad_register(port_id, mgmt, vers, rmpp_version, NULL);
if (agent < 0)
DEBUG("Can't register agent for class %d", mgmt);

Expand Down
6 changes: 3 additions & 3 deletions libibmad/src/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,

switch (dest_type) {
case IB_DEST_LID:
lid = strtol(addr_str, 0, 0);
lid = strtol(addr_str, NULL, 0);
if (!IB_LID_VALID(lid)) {
errno = EINVAL;
return -1;
Expand All @@ -168,7 +168,7 @@ int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
return 0;

case IB_DEST_GUID:
if (!(guid = strtoull(addr_str, 0, 0))) {
if (!(guid = strtoull(addr_str, NULL, 0))) {
errno = EINVAL;
return -1;
}
Expand All @@ -186,7 +186,7 @@ int ib_resolve_portid_str_via(ib_portid_t * portid, char *addr_str,
ib_portid_set(portid, lid, 0, 0);

/* handle DR parsing and set DrSLID to local lid */
if (ib_resolve_self_via(&selfportid, &selfport, 0, srcport) < 0)
if (ib_resolve_self_via(&selfportid, &selfport, NULL, srcport) < 0)
return -1;
if (str2drpath(&portid->drpath, routepath, selfportid.lid, 0) <
0) {
Expand Down
4 changes: 2 additions & 2 deletions libibmad/src/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len,
if (save_mad) {
memcpy(save_mad, umad_get_mad(sndbuf),
save_mad_len < len ? save_mad_len : len);
save_mad = 0;
save_mad = NULL;
}

if (max_retries <= 0) {
Expand Down Expand Up @@ -227,7 +227,7 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc,
len = 0;
memset(sndbuf, 0, umad_size() + IB_MAD_SIZE);

if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0)
if ((len = mad_build_pkt(sndbuf, rpc, dport, NULL, payload)) < 0)
return NULL;

if ((len = _do_madrpc(port->port_id, sndbuf, rcvbuf,
Expand Down
2 changes: 1 addition & 1 deletion libibmad/src/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf,
if (!portid->qkey)
portid->qkey = IB_DEFAULT_QP1_QKEY;

p = mad_rpc_rmpp(ibmad_port, &rpc, portid, 0 /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */
p = mad_rpc_rmpp(ibmad_port, &rpc, portid, NULL /*&sa->rmpp */ , rcvbuf); /* TODO: RMPP */

sa->recsz = rpc.recsz;

Expand Down
4 changes: 2 additions & 2 deletions libibmad/src/serv.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int mad_respond_via(void *umad, ib_portid_t * portid, uint32_t rstatus,
portid->qp, rpc.mgtclass, rpc.method, rpc.attr.id, rpc.attr.mod,
rpc.datasz, rpc.dataoffs, portid->qkey);

if (mad_build_pkt(umad, &rpc, portid, 0, 0) < 0)
if (mad_build_pkt(umad, &rpc, portid, NULL, NULL) < 0)
return -1;

if (ibdebug > 1)
Expand Down Expand Up @@ -183,7 +183,7 @@ void *mad_receive_via(void *umad, int timeout, struct ibmad_port *srcport)
if (!umad)
umad_free(mad);
DEBUG("recv failed: %s", strerror(errno));
return 0;
return NULL;
}

return mad;
Expand Down
4 changes: 2 additions & 2 deletions libibmad/src/vendor.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid,
portid->qkey = IB_DEFAULT_QP1_QKEY;

if (resp_expected) {
p_ret = mad_rpc_rmpp(srcport, rpcold, portid, 0, data); /* FIXME: no RMPP for now */
p_ret = mad_rpc_rmpp(srcport, rpcold, portid, NULL, data); /* FIXME: no RMPP for now */
errno = rpc.error;
return p_ret;
}

return mad_send_via(rpcold, portid, 0, data, srcport) < 0 ? 0 : data; /* FIXME: no RMPP for now */
return mad_send_via(rpcold, portid, NULL, data, srcport) < 0 ? NULL : data; /* FIXME: no RMPP for now */
}
6 changes: 3 additions & 3 deletions libibnetdisc/src/chassis.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ static int fill_voltaire_chassis_record(ibnd_node_t * node)
{
int p = 0;
ibnd_port_t *port;
ibnd_node_t *remnode = 0;
ibnd_node_t *remnode = NULL;

if (node->ch_found) /* somehow this node has already been passed */
return 0;
Expand Down Expand Up @@ -1005,8 +1005,8 @@ static void pass_on_spines_interpolate_chguid(ibnd_chassis_t * chassis)
static int build_chassis(ibnd_node_t * node, ibnd_chassis_t * chassis)
{
int p = 0;
ibnd_node_t *remnode = 0;
ibnd_port_t *port = 0;
ibnd_node_t *remnode = NULL;
ibnd_port_t *port = NULL;

/* we get here with node = chassis_spine */
if (insert_spine(node, chassis))
Expand Down
4 changes: 2 additions & 2 deletions libibnetdisc/src/query_smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ int smp_engine_init(smp_engine_t * engine, char * ca_name, int ca_port,
}

if ((engine->smi_agent = umad_register(engine->umad_fd,
IB_SMI_CLASS, 1, 0, 0)) < 0) {
IB_SMI_CLASS, 1, 0, NULL)) < 0) {
IBND_ERROR("Failed to register SMI agent on (%s:%d)\n",
ca_name, ca_port);
goto eio_close;
}

if ((engine->smi_dir_agent = umad_register(engine->umad_fd,
IB_SMI_DIRECT_CLASS, 1, 0, 0)) < 0) {
IB_SMI_DIRECT_CLASS, 1, 0, NULL)) < 0) {
IBND_ERROR("Failed to register SMI_DIRECT agent on (%s:%d)\n",
ca_name, ca_port);
goto eio_close;
Expand Down
30 changes: 15 additions & 15 deletions libibnetdisc/test/testleaks.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ int main(int argc, char **argv)
{
struct ibnd_config config = { 0 };
int rc = 0;
char *ca = 0;
char *ca = NULL;
int ca_port = 0;
ibnd_fabric_t *fabric = NULL;
char *from = NULL;
Expand All @@ -84,18 +84,18 @@ int main(int argc, char **argv)

static char const str_opts[] = "S:D:n:C:P:t:shuf:i:";
static const struct option long_opts[] = {
{"S", 1, 0, 'S'},
{"D", 1, 0, 'D'},
{"num-hops", 1, 0, 'n'},
{"ca-name", 1, 0, 'C'},
{"ca-port", 1, 0, 'P'},
{"timeout", 1, 0, 't'},
{"show", 0, 0, 's'},
{"help", 0, 0, 'h'},
{"usage", 0, 0, 'u'},
{"debug", 0, 0, 2},
{"from", 1, 0, 'f'},
{"iters", 1, 0, 'i'},
{"S", 1, NULL, 'S'},
{"D", 1, NULL, 'D'},
{"num-hops", 1, NULL, 'n'},
{"ca-name", 1, NULL, 'C'},
{"ca-port", 1, NULL, 'P'},
{"timeout", 1, NULL, 't'},
{"show", 0, NULL, 's'},
{"help", 0, NULL, 'h'},
{"usage", 0, NULL, 'u'},
{"debug", 0, NULL, 2},
{"from", 1, NULL, 'f'},
{"iters", 1, NULL, 'i'},
{}
};

Expand All @@ -118,7 +118,7 @@ int main(int argc, char **argv)
ca = strdup(optarg);
break;
case 'P':
ca_port = strtoul(optarg, 0, 0);
ca_port = strtoul(optarg, NULL, 0);
break;
case 'n':
config.max_hops = strtoul(optarg, NULL, 0);
Expand All @@ -127,7 +127,7 @@ int main(int argc, char **argv)
iters = (int)strtol(optarg, NULL, 0);
break;
case 't':
config.timeout_ms = strtoul(optarg, 0, 0);
config.timeout_ms = strtoul(optarg, NULL, 0);
break;
default:
usage();
Expand Down
6 changes: 3 additions & 3 deletions src/dump_fts.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ int main(int argc, char **argv)
"do not try to resolve destinations"},
{"Multicast", 'M', 0, NULL, "show multicast forwarding tables"},
{"node-name-map", 1, 1, "<file>", "node name map file"},
{0}
{}
};
char usage_args[] = "[<dest dr_path|lid|guid> [<startlid> [<endlid>]]]";
const char *usage_examples[] = {
Expand All @@ -454,9 +454,9 @@ int main(int argc, char **argv)
argv += optind;

if (argc > 0)
startlid = strtoul(argv[0], 0, 0);
startlid = strtoul(argv[0], NULL, 0);
if (argc > 1)
endlid = strtoul(argv[1], 0, 0);
endlid = strtoul(argv[1], NULL, 0);

node_name_map = open_node_name_map(node_name_map_file);

Expand Down
4 changes: 2 additions & 2 deletions src/ibaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int main(int argc, char **argv)
{"gid_show", 'g', 0, NULL, "show gid address only"},
{"lid_show", 'l', 0, NULL, "show lid range only"},
{"Lid_show", 'L', 0, NULL, "show lid range (in decimal) only"},
{0}
{}
};
char usage_args[] = "[<lid|dr_path|guid>]";
const char *usage_examples[] = {
Expand All @@ -139,7 +139,7 @@ int main(int argc, char **argv)
argv += optind;

if (argc > 1)
port = strtoul(argv[1], 0, 0);
port = strtoul(argv[1], NULL, 0);

if (!show_lid && !show_gid)
show_lid = show_gid = 1;
Expand Down
12 changes: 6 additions & 6 deletions src/ibcacheedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ static int parse_beforeafter(char *arg, uint64_t *before, uint64_t *after)
before_str = arg;
after_str = ptr + 1;

(*before) = strtoull(before_str, 0, 0);
(*after) = strtoull(after_str, 0, 0);
(*before) = strtoull(before_str, NULL, 0);
(*after) = strtoull(after_str, NULL, 0);
return 0;
}

Expand Down Expand Up @@ -119,9 +119,9 @@ static int parse_guidbeforeafter(char *arg,
(*ptr2) = '\0';
after_str = ptr2 + 1;

(*guid) = strtoull(guid_str, 0, 0);
(*before) = strtoull(before_str, 0, 0);
(*after) = strtoull(after_str, 0, 0);
(*guid) = strtoull(guid_str, NULL, 0);
(*before) = strtoull(before_str, NULL, 0);
(*after) = strtoull(after_str, NULL, 0);
return 0;
}

Expand Down Expand Up @@ -264,7 +264,7 @@ int main(int argc, char **argv)
"Specify before and after sysimgguid to edit"},
{"portguid", 4, 1, "NODEGUID:BEFOREGUID:AFTERGUID",
"Specify before and after port guid to edit"},
{0}
{}
};
const char *usage_args = "<orig.cache> <new.cache>";

Expand Down
6 changes: 3 additions & 3 deletions src/ibccconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static const match_rec_t match_tbl[] = {
"<trigger_threshold> <ccti_min>"},
{"CongestionControlTable", "CT", congestion_control_table, 0,
"<cctilimit> <index> <cctentry> <cctentry> ..."},
{0}
{}
};

static uint64_t cckey;
Expand Down Expand Up @@ -548,7 +548,7 @@ static int process_opt(void *context, int ch)
{
switch (ch) {
case 'c':
cckey = (uint64_t) strtoull(optarg, 0, 0);
cckey = (uint64_t) strtoull(optarg, NULL, 0);
break;
default:
return -1;
Expand All @@ -568,7 +568,7 @@ int main(int argc, char **argv)

const struct ibdiag_opt opts[] = {
{"cckey", 'c', 1, "<key>", "CC key"},
{0}
{}
};
const char *usage_examples[] = {
"SwitchCongestionSetting 2 0x1F 0x1FFFFFFFFF 0x0 0xF 8 0 0:0 1\t# Configure Switch Congestion Settings",
Expand Down
8 changes: 4 additions & 4 deletions src/ibccquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static const match_rec_t match_tbl[] = {
{"CACongestionSetting", "CS", ca_congestion_setting, 0, ""},
{"CongestionControlTable", "CT", congestion_control_table, 0, ""},
{"Timestamp", "TI", timestamp_dump, 0, ""},
{0}
{}
};

static uint64_t cckey = 0;
Expand Down Expand Up @@ -205,7 +205,7 @@ static const char *switch_port_congestion_setting(ib_portid_t *dest,
int outputcount = 0;

if (argc > 0)
portnum = strtol(argv[0], 0, 0);
portnum = strtol(argv[0], NULL, 0);

/* Figure out number of ports first */
if (!smp_query_via(data, dest, IB_ATTR_NODE_INFO, 0, 0, srcport))
Expand Down Expand Up @@ -343,7 +343,7 @@ static int process_opt(void *context, int ch)
{
switch (ch) {
case 'c':
cckey = (uint64_t) strtoull(optarg, 0, 0);
cckey = (uint64_t) strtoull(optarg, NULL, 0);
break;
default:
return -1;
Expand All @@ -363,7 +363,7 @@ int main(int argc, char **argv)

const struct ibdiag_opt opts[] = {
{"cckey", 'c', 1, "<key>", "CC key"},
{0}
{}
};
const char *usage_examples[] = {
"CongestionInfo 3\t\t\t# Congestion Info by lid",
Expand Down

0 comments on commit c5489ce

Please sign in to comment.