Use 'NULL' (instead of '0') as null pointer when functions return bad status. It is in order to prevent cut-and-paste errors when a tested statements are used in functions which return integers.
Signed-off-by: Sasha Khapyorsky <[email protected]> --- libibmad/src/bm.c | 2 +- libibmad/src/fields.c | 6 +++--- libibmad/src/gs.c | 4 ++-- libibmad/src/mad.c | 4 ++-- libibmad/src/rpc.c | 14 +++++++------- libibmad/src/sa.c | 2 +- libibmad/src/vendor.c | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libibmad/src/bm.c b/libibmad/src/bm.c index e335d92..2983855 100644 --- a/libibmad/src/bm.c +++ b/libibmad/src/bm.c @@ -58,7 +58,7 @@ uint8_t *bm_call_via(void *data, ib_portid_t * portid, ib_bm_call_t * call, DEBUG("route %s data %p", portid2str(portid), data); if (portid->lid <= 0) { IBWARN("only lid routes are supported"); - return 0; + return NULL; } resp_expected = response_expected(call->method); diff --git a/libibmad/src/fields.c b/libibmad/src/fields.c index 129f7e5..c8e4e79 100644 --- a/libibmad/src/fields.c +++ b/libibmad/src/fields.c @@ -633,7 +633,7 @@ static char *_mad_dump_field(const ib_field_t * f, const char *name, char *buf, int l, n; if (bufsz <= 32) - return 0; /* buf too small */ + return NULL; /* buf too small */ if (!name) name = f->name; @@ -680,14 +680,14 @@ int mad_print_field(enum MAD_FIELDS field, const char *name, void *val) char *mad_dump_field(enum MAD_FIELDS field, char *buf, int bufsz, void *val) { if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_) - return 0; + return NULL; return _mad_dump_field(ib_mad_f + field, 0, buf, bufsz, val); } char *mad_dump_val(enum MAD_FIELDS field, char *buf, int bufsz, void *val) { if (field <= IB_NO_FIELD || field >= IB_FIELD_LAST_) - return 0; + return NULL; return _mad_dump_val(ib_mad_f + field, buf, bufsz, val); } diff --git a/libibmad/src/gs.c b/libibmad/src/gs.c index c7e4ff6..4701866 100644 --- a/libibmad/src/gs.c +++ b/libibmad/src/gs.c @@ -56,7 +56,7 @@ uint8_t *pma_query_via(void *rcvbuf, ib_portid_t * dest, int port, if (lid == -1) { IBWARN("only lid routed is supported"); - return 0; + return NULL; } rpc.mgtclass = IB_PERFORMANCE_CLASS; @@ -89,7 +89,7 @@ uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest, if (lid == -1) { IBWARN("only lid routed is supported"); - return 0; + return NULL; } if (!mask) diff --git a/libibmad/src/mad.c b/libibmad/src/mad.c index 89ff978..8defabd 100644 --- a/libibmad/src/mad.c +++ b/libibmad/src/mad.c @@ -78,11 +78,11 @@ void *mad_encode(void *buf, ib_rpc_t * rpc, ib_dr_path_t * drpath, void *data) if (rpc->mgtclass == IB_SMI_DIRECT_CLASS) { if (!drpath) { IBWARN("encoding dr mad without drpath (null)"); - return 0; + return NULL; } if (drpath->cnt >= IB_SUBNET_PATH_HOPS_MAX) { IBWARN("dr path with hop count %d", drpath->cnt); - return 0; + return NULL; } mad_set_field(buf, 0, IB_DRSMP_HOPCNT_F, drpath->cnt); mad_set_field(buf, 0, IB_DRSMP_HOPPTR_F, diff --git a/libibmad/src/rpc.c b/libibmad/src/rpc.c index 0b989da..c6fd392 100644 --- a/libibmad/src/rpc.c +++ b/libibmad/src/rpc.c @@ -218,7 +218,7 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc, memset(sndbuf, 0, umad_size() + IB_MAD_SIZE); if ((len = mad_build_pkt(sndbuf, rpc, dport, 0, payload)) < 0) - return 0; + return NULL; timeout = rpc->timeout ? rpc->timeout : port->timeout ? port->timeout : madrpc_timeout; @@ -228,7 +228,7 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc, port->class_agents[rpc->mgtclass], len, timeout, retries)) < 0) { IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport)); - return 0; + return NULL; } mad = umad_get_mad(rcvbuf); @@ -248,7 +248,7 @@ void *mad_rpc(const struct ibmad_port *port, ib_rpc_t * rpc, if (status != 0) { ERRS("MAD completed with error status 0x%x; dport (%s)", status, portid2str(dport)); - return 0; + return NULL; } if (ibdebug) { @@ -274,7 +274,7 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc, DEBUG("rmpp %p data %p", rmpp, data); if ((len = mad_build_pkt(sndbuf, rpc, dport, rmpp, data)) < 0) - return 0; + return NULL; timeout = rpc->timeout ? rpc->timeout : port->timeout ? port->timeout : madrpc_timeout; @@ -284,7 +284,7 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc, port->class_agents[rpc->mgtclass], len, timeout, retries)) < 0) { IBWARN("_do_madrpc failed; dport (%s)", portid2str(dport)); - return 0; + return NULL; } mad = umad_get_mad(rcvbuf); @@ -292,7 +292,7 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc, if ((status = mad_get_field(mad, 0, IB_MAD_STATUS_F)) != 0) { ERRS("MAD completed with error status 0x%x; dport (%s)", status, portid2str(dport)); - return 0; + return NULL; } if (ibdebug) { @@ -306,7 +306,7 @@ void *mad_rpc_rmpp(const struct ibmad_port *port, ib_rpc_t * rpc, if ((rmpp->flags & 0x3) && mad_get_field(mad, 0, IB_SA_RMPP_VERS_F) != 1) { IBWARN("bad rmpp version"); - return 0; + return NULL; } rmpp->type = mad_get_field(mad, 0, IB_SA_RMPP_TYPE_F); rmpp->status = mad_get_field(mad, 0, IB_SA_RMPP_STATUS_F); diff --git a/libibmad/src/sa.c b/libibmad/src/sa.c index 27e6ee9..5f34039 100644 --- a/libibmad/src/sa.c +++ b/libibmad/src/sa.c @@ -56,7 +56,7 @@ uint8_t *sa_rpc_call(const struct ibmad_port *ibmad_port, void *rcvbuf, if (portid->lid <= 0) { IBWARN("only lid routes are supported"); - return 0; + return NULL; } rpc.mgtclass = IB_SA_CLASS; diff --git a/libibmad/src/vendor.c b/libibmad/src/vendor.c index 4bf9561..6736f32 100644 --- a/libibmad/src/vendor.c +++ b/libibmad/src/vendor.c @@ -66,11 +66,11 @@ uint8_t *ib_vendor_call_via(void *data, ib_portid_t * portid, DEBUG("route %s data %p", portid2str(portid), data); if (portid->lid <= 0) - return 0; /* no direct SMI */ + return NULL; /* no direct SMI */ if (!(range1 = mad_is_vendor_range1(call->mgmt_class)) && !(mad_is_vendor_range2(call->mgmt_class))) - return 0; + return NULL; resp_expected = response_expected(call->method); -- 1.6.4 _______________________________________________ general mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
