From patchwork Fri Mar 8 19:55:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10845377 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 467E117E9 for ; Fri, 8 Mar 2019 19:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E5F42DE17 for ; Fri, 8 Mar 2019 19:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22FE02FE8A; Fri, 8 Mar 2019 19:55:33 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6C3E92FE96 for ; Fri, 8 Mar 2019 19:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726876AbfCHTzb (ORCPT ); Fri, 8 Mar 2019 14:55:31 -0500 Received: from mail-qk1-f174.google.com ([209.85.222.174]:32940 "EHLO mail-qk1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbfCHTza (ORCPT ); Fri, 8 Mar 2019 14:55:30 -0500 Received: by mail-qk1-f174.google.com with SMTP id x9so11914686qkf.0 for ; Fri, 08 Mar 2019 11:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m4btgDiEyPWDNRHYUoVQ5g12llgwV4mpC245mVUwUOM=; b=fcdMYvcVXlr8zUJzTTDaDmvOh3rFEacQfCKNZKqSrOdviVrP+D3b+SMHcl50Wd3IaG 42iqf/+l84hHaeAjZggqjisPS4H0mAUBD6j3FczkOZOHjy/JzJ6CGFIRNXVNlrYhvw4S H2uOHTKvfZicu47OPeByZJwtLQPwcoKJZxJUtLeQV2HbIPpOKzct4/DQZ15wLeRnWAD2 7ByqXR/kHapR6Y8nl75jZqL+HKyiT57jQ8q1o4supqvOc5PfzXv9LUYzdruISna0lSr9 znH3jPK74DygjD5SiLM+z3rRrGSkay5HCE+hVwhy1Ph/T7/PYeLo6BD0sjfJ7Ok3QVRS 8VCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m4btgDiEyPWDNRHYUoVQ5g12llgwV4mpC245mVUwUOM=; b=ger6XNJGt4L21LhK8eqWI6YbXgjFBORUxDtI7ncAkOjaVeLS/eKs46HS5K7LFe/ARg cqxc+8HQlw05AF1iMTdfc9Y84heqsiQPPuyUt2xfdTk7MIZrT2W2R9Fgdi9r3S/KjUNC j7zOKHvTeYq28oL11nqvTSYRQCTJcd3lbb77VwVeLc2FT3EskhkZwF7OenrqOpv3cNEZ oUCeSKuXigXx4A24X5aVrZY3hVIYrq8zFHct/mCvLNaeY/NsZ9ycm84JzJy4j7yKObn5 q1ARrOT6zw+I/mD3iLnyTkYB0niZlu9/dmv8bR1c9wp7yDEXj8yOa+KK4kGXFsdzNbgJ 6CqQ== X-Gm-Message-State: APjAAAUXKj2vOoxEWaus3mYBRMhKcoqi8VJaDMnoa9micwBQpkkF1DaC vu6rgHZoAe8chxKak1CEJIstVBvPxtENQw== X-Google-Smtp-Source: APXvYqzmhgahfga3+QrfYNAIn7eeg2x6FhFsZOZGIEfI9WY0ghPSd3gpecj+yHdgu/DlgHjK7mog+A== X-Received: by 2002:a37:8b06:: with SMTP id n6mr14734678qkd.340.1552074928777; Fri, 08 Mar 2019 11:55:28 -0800 (PST) Received: from ziepe.ca ([24.137.65.181]) by smtp.gmail.com with ESMTPSA id l31sm5527062qtb.20.2019.03.08.11.55.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 11:55:23 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1h2LaU-0000w3-JX; Fri, 08 Mar 2019 15:55:22 -0400 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH ibdiags 11/14] ibdiags: Rename local variables to avoid shadow Date: Fri, 8 Mar 2019 15:55:12 -0400 Message-Id: <20190308195515.3408-12-jgg@ziepe.ca> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308195515.3408-1-jgg@ziepe.ca> References: <20190308195515.3408-1-jgg@ziepe.ca> MIME-Version: 1.0 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 From: Jason Gunthorpe Change the names of these variables to avoid shadowing a global. Signed-off-by: Jason Gunthorpe --- src/dump_fts.c | 68 ++++++++++++++++++++++----------------------- src/ibdiag_common.c | 20 ++++++------- src/ibqueryerrors.c | 17 ++++++------ 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/dump_fts.c b/src/dump_fts.c index 998383aa470453..3a9299d174e441 100644 --- a/src/dump_fts.c +++ b/src/dump_fts.c @@ -110,8 +110,8 @@ static int dump_mlid(char *str, int strlen, unsigned mlid, unsigned nports, uint16_t mft[16][IB_MLIDS_IN_BLOCK] = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0}, { 0 }, { 0 } }; -static void dump_multicast_tables(ibnd_node_t *node, unsigned startlid, - unsigned endlid, struct ibmad_port *mad_port) +static void dump_multicast_tables(ibnd_node_t *node, unsigned startl, + unsigned endl, struct ibmad_port *mad_port) { ib_portid_t *portid = &node->path_portid; char nd[IB_SMP_DATA_SIZE] = { 0 }; @@ -131,33 +131,33 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startlid, mad_decode_field(node->switchinfo, IB_SW_MCAST_FDB_CAP_F, &cap); mad_decode_field(node->switchinfo, IB_SW_MCAST_FDB_TOP_F, &top); - if (!endlid || endlid > IB_MIN_MCAST_LID + cap - 1) - endlid = IB_MIN_MCAST_LID + cap - 1; - if (!dump_all && top && top < endlid) { + if (!endl || endl > IB_MIN_MCAST_LID + cap - 1) + endl = IB_MIN_MCAST_LID + cap - 1; + if (!dump_all && top && top < endl) { if (top < IB_MIN_MCAST_LID - 1) IBWARN("illegal top mlid %x", top); else - endlid = top; + endl = top; } - if (!startlid) - startlid = IB_MIN_MCAST_LID; - else if (startlid < IB_MIN_MCAST_LID) { - IBWARN("illegal start mlid %x, set to %x", startlid, + if (!startl) + startl = IB_MIN_MCAST_LID; + else if (startl < IB_MIN_MCAST_LID) { + IBWARN("illegal start mlid %x, set to %x", startl, IB_MIN_MCAST_LID); - startlid = IB_MIN_MCAST_LID; + startl = IB_MIN_MCAST_LID; } - if (endlid > IB_MAX_MCAST_LID) { - IBWARN("illegal end mlid %x, truncate to %x", endlid, + if (endl > IB_MAX_MCAST_LID) { + IBWARN("illegal end mlid %x, truncate to %x", endl, IB_MAX_MCAST_LID); - endlid = IB_MAX_MCAST_LID; + endl = IB_MAX_MCAST_LID; } mapnd = remap_node_name(node_name_map, nodeguid, nd); printf("Multicast mlids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 - " (%s):\n", startlid, endlid, portid2str(portid), nodeguid, + " (%s):\n", startl, endl, portid2str(portid), nodeguid, mapnd); if (brief) @@ -182,8 +182,8 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startlid, chunks = ALIGN(nports + 1, 16) / 16; - startblock = startlid / IB_MLIDS_IN_BLOCK; - lastblock = endlid / IB_MLIDS_IN_BLOCK; + startblock = startl / IB_MLIDS_IN_BLOCK; + lastblock = endl / IB_MLIDS_IN_BLOCK; for (block = startblock; block <= lastblock; block++) { for (j = 0; j < chunks; j++) { int status; @@ -207,10 +207,10 @@ static void dump_multicast_tables(ibnd_node_t *node, unsigned startlid, i = block * IB_MLIDS_IN_BLOCK; e = i + IB_MLIDS_IN_BLOCK; - if (i < startlid) - i = startlid; - if (e > endlid + 1) - e = endlid + 1; + if (i < startl) + i = startl; + if (e > endl + 1) + e = endl + 1; for (; i < e; i++) { if (dump_mlid(str, sizeof str, i, nports, mft) == 0) @@ -301,7 +301,7 @@ static int dump_lid(char *str, int str_len, int lid, int valid, return rc; } -static void dump_unicast_tables(ibnd_node_t *node, int startlid, int endlid, +static void dump_unicast_tables(ibnd_node_t *node, int startl, int endl, struct ibmad_port *mad_port, ibnd_fabric_t *fabric) { @@ -322,27 +322,27 @@ static void dump_unicast_tables(ibnd_node_t *node, int startlid, int endlid, nports = node->numports; memcpy(nd, node->nodedesc, strlen(node->nodedesc)); - if (!endlid || endlid > top) - endlid = top; + if (!endl || endl > top) + endl = top; - if (endlid > IB_MAX_UCAST_LID) { - IBWARN("illegal lft top %d, truncate to %d", endlid, + if (endl > IB_MAX_UCAST_LID) { + IBWARN("illegal lft top %d, truncate to %d", endl, IB_MAX_UCAST_LID); - endlid = IB_MAX_UCAST_LID; + endl = IB_MAX_UCAST_LID; } mapnd = remap_node_name(node_name_map, nodeguid, nd); printf("Unicast lids [0x%x-0x%x] of switch %s guid 0x%016" PRIx64 - " (%s):\n", startlid, endlid, portid2str(portid), nodeguid, + " (%s):\n", startl, endl, portid2str(portid), nodeguid, mapnd); DEBUG("Switch top is 0x%x\n", top); printf(" Lid Out Destination\n"); printf(" Port Info \n"); - startblock = startlid / IB_SMP_DATA_SIZE; - endblock = ALIGN(endlid, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE; + startblock = startl / IB_SMP_DATA_SIZE; + endblock = ALIGN(endl, IB_SMP_DATA_SIZE) / IB_SMP_DATA_SIZE; for (block = startblock; block < endblock; block++) { int status; DEBUG("reading block %d", block); @@ -357,10 +357,10 @@ static void dump_unicast_tables(ibnd_node_t *node, int startlid, int endlid, } i = block * IB_SMP_DATA_SIZE; e = i + IB_SMP_DATA_SIZE; - if (i < startlid) - i = startlid; - if (e > endlid + 1) - e = endlid + 1; + if (i < startl) + i = startl; + if (e > endl + 1) + e = endl + 1; for (; i < e; i++) { unsigned outport = lft[i % IB_SMP_DATA_SIZE]; diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c index 977d8e1d05d394..1d87bad0f4c397 100644 --- a/src/ibdiag_common.c +++ b/src/ibdiag_common.c @@ -328,7 +328,7 @@ static struct option *make_long_opts(const char *exclude_str, const struct ibdiag_opt *custom_opts, const struct ibdiag_opt *map[]) { - struct option *long_opts, *l; + struct option *res, *l; const struct ibdiag_opt *o; unsigned n = 0; @@ -336,12 +336,12 @@ static struct option *make_long_opts(const char *exclude_str, for (o = custom_opts; o->name; o++) n++; - long_opts = malloc((sizeof(common_opts) / sizeof(common_opts[0]) + n) * - sizeof(*long_opts)); - if (!long_opts) + res = malloc((sizeof(common_opts) / sizeof(common_opts[0]) + n) * + sizeof(*res)); + if (!res) return NULL; - l = long_opts; + l = res; if (custom_opts) for (o = custom_opts; o->name; o++) @@ -355,7 +355,7 @@ static struct option *make_long_opts(const char *exclude_str, memset(l, 0, sizeof(*l)); - return long_opts; + return res; } static void make_str_opts(const struct option *o, char *p, unsigned size) @@ -637,11 +637,11 @@ static int resolve_gid(char *ca_name, uint8_t ca_port, ib_portid_t *portid, ibmad_gid_t gid, ib_portid_t *sm_id, const struct ibmad_port *srcport) { - ib_portid_t sm_portid; + ib_portid_t tmp; char buf[IB_SA_DATA_SIZE] = { 0 }; if (!sm_id) { - sm_id = &sm_portid; + sm_id = &tmp; if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0) return -1; } @@ -657,13 +657,13 @@ static int resolve_guid(char *ca_name, uint8_t ca_port, ib_portid_t *portid, uint64_t *guid, ib_portid_t *sm_id, const struct ibmad_port *srcport) { - ib_portid_t sm_portid; + ib_portid_t tmp; uint8_t buf[IB_SA_DATA_SIZE] = { 0 }; uint64_t prefix; ibmad_gid_t selfgid; if (!sm_id) { - sm_id = &sm_portid; + sm_id = &tmp; if (resolve_sm_portid(ca_name, ca_port, sm_id) < 0) return -1; } diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c index 358eb48e493e7a..54e06e183097ea 100644 --- a/src/ibqueryerrors.c +++ b/src/ibqueryerrors.c @@ -1122,14 +1122,15 @@ int main(int argc, char **argv) mad_rpc_set_timeout(ibmad_port, ibd_timeout); if (port_guid_str) { - ibnd_port_t *port = ibnd_find_port_guid(fabric, port_guid); - if (port) - print_node(port->node, NULL); + ibnd_port_t *ndport = ibnd_find_port_guid(fabric, port_guid); + if (ndport) + print_node(ndport->node, NULL); else fprintf(stderr, "Failed to find node: %s\n", port_guid_str); } else if (dr_path) { - ibnd_port_t *port; + ibnd_port_t *ndport; + uint8_t ni[IB_SMP_DATA_SIZE] = { 0 }; if (!smp_query_via(ni, &portid, IB_ATTR_NODE_INFO, 0, ibd_timeout, ibmad_port)) { @@ -1139,12 +1140,12 @@ int main(int argc, char **argv) mad_decode_field(ni, IB_NODE_PORT_GUID_F, &(port_guid)); - port = ibnd_find_port_guid(fabric, port_guid); - if (port) { + ndport = ibnd_find_port_guid(fabric, port_guid); + if (ndport) { if(obtain_sl) - if(path_record_query(self_gid,port->guid)) + if(path_record_query(self_gid,ndport->guid)) goto close_port; - print_node(port->node, NULL); + print_node(ndport->node, NULL); } else fprintf(stderr, "Failed to find node: %s\n", dr_path); } else {