From patchwork Wed Jan 2 12:36:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B0E613AD for ; Wed, 2 Jan 2019 12:39:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36881271CB for ; Wed, 2 Jan 2019 12:39:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24E6427F8F; Wed, 2 Jan 2019 12:39:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A0E5271CB for ; Wed, 2 Jan 2019 12:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbfABMjA (ORCPT ); Wed, 2 Jan 2019 07:39:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45140 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729448AbfABMjA (ORCPT ); Wed, 2 Jan 2019 07:39:00 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A55AEDA314; Wed, 2 Jan 2019 12:38:59 +0000 (UTC) Received: from localhost (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 42B775D9C5; Wed, 2 Jan 2019 12:38:55 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 03/23] ibsim: return 'NULL' instead of '0' if fucntion return a pointer Date: Wed, 2 Jan 2019 20:36:07 +0800 Message-Id: <20190102123627.18629-3-honli@redhat.com> In-Reply-To: <20190102123627.18629-1-honli@redhat.com> References: <20190102123627.18629-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 02 Jan 2019 12:38:59 +0000 (UTC) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Honggang Li --- ibsim/ibsim.c | 2 +- ibsim/sim_cmd.c | 2 +- ibsim/sim_mad.c | 18 +++++++++--------- ibsim/sim_net.c | 32 ++++++++++++++++---------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index 40e605c75429..4e01f55f1817 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -664,7 +664,7 @@ Client *find_client(Port * port, int response, int qp, uint64_t trid) return cl; } DEBUG("no client found"); - return 0; + return NULL; } void usage(char *prog_name) diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4345731e5081..92343525645b 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -633,7 +633,7 @@ static Port *find_port(int lid) } if (port && (port->lid + (1 << port->lmc)) > lid) return port; - return 0; + return NULL; } static int do_change_baselid(FILE * f, char *line) diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c index 0312c05f2e34..edb23952b47a 100644 --- a/ibsim/sim_mad.c +++ b/ibsim/sim_mad.c @@ -1639,7 +1639,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (lid == 0) { IBWARN("invalid lid 0"); - return 0; + return NULL; } if (is_port_lid(port, lid)) @@ -1649,11 +1649,11 @@ static Port *lid_route_MAD(Port * port, int lid) pc_add_error_xmitdiscards(port); IBWARN("failed: disconnected node 0x%" PRIx64 " or port 0x%" PRIx64 "?", node->nodeguid, port->portguid); - return 0; + return NULL; } if (!pc_updated(&tport, port)) // if Client connected via HCA ... - return 0; + return NULL; for (hop = 0; !is_port_lid(port, lid) && hop < MAXHOPS; hop++) { portnum = switch_lookup(node, lid); @@ -1662,7 +1662,7 @@ static Port *lid_route_MAD(Port * port, int lid) pc_add_error_rcvswitchrelay(port); DEBUG("illegal lid %u (outport %d node %s ports %d)", lid, portnum, node->nodeid, node->numports); - return 0; + return NULL; } DEBUG("node %" PRIx64 " outport %d", node->nodeguid, portnum); @@ -1676,7 +1676,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (!link_valid(port)) { pc_add_error_xmitdiscards(port); - return 0; + return NULL; } tport = port; // prepare to pass PKT to next port @@ -1687,7 +1687,7 @@ static Port *lid_route_MAD(Port * port, int lid) if (port_get_remote(port, &node, &port) < 0) { pc_add_error_xmitdiscards(tport); IBWARN("no remote"); - return 0; + return NULL; } if (!node || !port) // double check ?... @@ -1695,11 +1695,11 @@ static Port *lid_route_MAD(Port * port, int lid) if (!link_valid(port)) { pc_add_error_xmitdiscards(tport); - return 0; + return NULL; } if (!pc_updated(&tport, port)) //try to transmit PKT - return 0; + return NULL; } DEBUG("routed to node %s port 0x%" PRIx64 " portnum %d (%p)", @@ -1818,7 +1818,7 @@ static Smpfn *get_handle_fn(ib_rpc_t rpc, int response) Smpfn *fn; if (response) - return 0; + return NULL; fn = get_smp_handler(rpc.mgtclass & 0xf , rpc.attr.id); return fn; diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index 8695815d9a74..a963ff6d6589 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -251,7 +251,7 @@ static Switch *new_switch(Node * nd, int set_esp0) if (netswitches >= maxnetswitches) { IBPANIC("no more switches (max %d)", maxnetswitches); - return 0; + return NULL; } sw = switches + netswitches++; @@ -304,22 +304,22 @@ static Node *new_node(int type, char *nodename, char *nodedesc, int nodeports) Node *nd; if (build_nodeid(nodeid, sizeof(nodeid), nodename) < 0) - return 0; + return NULL; if (find_node(nodeid)) { IBWARN("node id %s already exists", nodeid); - return 0; + return NULL; } if (netnodes >= maxnetnodes) { IBPANIC("no more nodes (max %d)", maxnetnodes); - return 0; + return NULL; } if (find_node_by_guid(guids[type])) { IBWARN("node %s guid %" PRIx64 " already exists", node_type_name(type), guids[type]); - return 0; + return NULL; } nd = nodes + netnodes++; @@ -354,7 +354,7 @@ static Node *new_node(int type, char *nodename, char *nodedesc, int nodeports) if ((nd->portsbase = new_ports(nd, nodeports, firstport)) < 0) { IBWARN("can't alloc %d ports for node %s", nodeports, nd->nodeid); - return 0; + return NULL; } netvendid = 0; @@ -376,7 +376,7 @@ static char *parse_node_id(char *buf, char **rest_buf) if (!(s = strchr(buf, '"')) || !(e = strchr(s + 1, '"'))) { IBWARN("can't find valid id in <%s>", buf); - return 0; + return NULL; } *e = 0; if (rest_buf) @@ -678,7 +678,7 @@ char *map_alias(char *alias) if (aliases[i][len] == '#') return aliases[i] + len + 1; } - return 0; + return NULL; } char *expand_name(char *base, char *name, char **portstr) @@ -686,7 +686,7 @@ char *expand_name(char *base, char *name, char **portstr) char *s; if (!base) - return 0; + return NULL; if (!strchr(base, '@')) { if (netprefix[0] != 0 && !strchr(base, '#')) @@ -703,7 +703,7 @@ char *expand_name(char *base, char *name, char **portstr) PDEBUG("alias %s", name); if (!(s = map_alias(name))) - return 0; + return NULL; strncpy(name, s, NODEIDLEN - 1); @@ -1481,13 +1481,13 @@ Node *find_node(char *desc) Node *nd, *e; if (!desc) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (!strcmp(desc, nd->nodeid)) return nd; - return 0; + return NULL; } Node *find_node_by_desc(char *desc) @@ -1495,13 +1495,13 @@ Node *find_node_by_desc(char *desc) Node *nd, *e; if (!desc) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (!strcmp(desc, nd->nodedesc)) return nd; - return 0; + return NULL; } Node *find_node_by_guid(uint64_t guid) @@ -1509,13 +1509,13 @@ Node *find_node_by_guid(uint64_t guid) Node *nd, *e; if (ignoreduplicate) - return 0; + return NULL; for (nd = nodes, e = nodes + netnodes; nd < e; nd++) if (nd->nodeguid == guid) return nd; - return 0; + return NULL; } Port *node_get_port(Node * node, int portnum)