From patchwork Wed Jan 2 12:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746307 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 4431317D2 for ; Wed, 2 Jan 2019 12:37:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3409228800 for ; Wed, 2 Jan 2019 12:37:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2851028806; Wed, 2 Jan 2019 12:37:45 +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 C931828800 for ; Wed, 2 Jan 2019 12:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbfABMho (ORCPT ); Wed, 2 Jan 2019 07:37:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45508 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbfABMho (ORCPT ); Wed, 2 Jan 2019 07:37:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F019A637FC; Wed, 2 Jan 2019 12:37:43 +0000 (UTC) Received: from localhost (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99BA7105B1E5; Wed, 2 Jan 2019 12:37:38 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 01/23] move sim_cmd_file into ibsim/sim_cmd.c Date: Wed, 2 Jan 2019 20:36:05 +0800 Message-Id: <20190102123627.18629-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 02 Jan 2019 12:37:44 +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 The 'sim_cmd_file' function only called by 'do_cmd' function in the sim_cmd.c file. Signed-off-by: Honggang Li --- ibsim/ibsim.c | 38 -------------------------------------- ibsim/sim_cmd.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/ibsim/ibsim.c b/ibsim/ibsim.c index debf591fea92..40e605c75429 100644 --- a/ibsim/ibsim.c +++ b/ibsim/ibsim.c @@ -517,44 +517,6 @@ static int sim_read_pkt(int fd, int client) return -1; // never reached } -int sim_cmd_file(FILE * f, char *s) -{ - char line[4096]; - FILE *cmd_file; - char *p; - - s++; - while (isspace(*s)) - s++; - - if (!s || !*s) { - fprintf(f, "do_cmd_from_file: no file name - skip\n"); - return -1; - } - - p = s + strlen(s) - 1; - while (isspace(*p)) { - *p = '\0'; - p--; - } - - cmd_file = fopen(s, "r"); - if (!cmd_file) { - fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", - s, strerror(errno)); - return -1; - } - - while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { - if((p = strchr(line, '\n')) != NULL) - *p = '\0'; - do_cmd(line, f); - } - - fclose(cmd_file); - return 0; -} - static int sim_init_net(char *netconf, FILE * out) { DEBUG("reading %s", netconf); diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c index 4b8fb62e0906..4345731e5081 100644 --- a/ibsim/sim_cmd.c +++ b/ibsim/sim_cmd.c @@ -1143,6 +1143,44 @@ format_error: return -1; } +int sim_cmd_file(FILE * f, char *s) +{ + char line[4096]; + FILE *cmd_file; + char *p; + + s++; + while (isspace(*s)) + s++; + + if (!s || !*s) { + fprintf(f, "do_cmd_from_file: no file name - skip\n"); + return -1; + } + + p = s + strlen(s) - 1; + while (isspace(*p)) { + *p = '\0'; + p--; + } + + cmd_file = fopen(s, "r"); + if (!cmd_file) { + fprintf(f, "do_cmd_from_file: cannot open file \'%s\': %s\n", + s, strerror(errno)); + return -1; + } + + while (fgets(line, sizeof(line) - 1, cmd_file) != NULL) { + if((p = strchr(line, '\n')) != NULL) + *p = '\0'; + do_cmd(line, f); + } + + fclose(cmd_file); + return 0; +} + int netstarted; int do_cmd(char *buf, FILE *f) From patchwork Wed Jan 2 12:36:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746309 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 E367613AD for ; Wed, 2 Jan 2019 12:38:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF82D274A3 for ; Wed, 2 Jan 2019 12:38:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE188271CB; Wed, 2 Jan 2019 12:38:51 +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 5C753271CB for ; Wed, 2 Jan 2019 12:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729815AbfABMiv (ORCPT ); Wed, 2 Jan 2019 07:38:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45032 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729448AbfABMiu (ORCPT ); Wed, 2 Jan 2019 07:38:50 -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 C70E1C9DA6; Wed, 2 Jan 2019 12:38:50 +0000 (UTC) Received: from localhost (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A4285D9CA; Wed, 2 Jan 2019 12:38:40 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 02/23] Make gcc don't warn about deprecated declarations Date: Wed, 2 Jan 2019 20:36:06 +0800 Message-Id: <20190102123627.18629-2-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:50 +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 --- defs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defs.mk b/defs.mk index 11256c0f0078..4a34f8543861 100644 --- a/defs.mk +++ b/defs.mk @@ -24,7 +24,7 @@ else LIBS:= -L$(libpath) -libmad -libumad endif -CFLAGS += -Wall -g -fpic -I. -I../include $(INCS) +CFLAGS += -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include $(INCS) LDFLAGS+= -fpic srcs?=$(wildcard *.c) 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) From patchwork Wed Jan 2 12:36:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10746313 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 4E22E17D2 for ; Wed, 2 Jan 2019 12:42:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC592875F for ; Wed, 2 Jan 2019 12:42:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 334EB28802; Wed, 2 Jan 2019 12:42:55 +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 CACED2875F for ; Wed, 2 Jan 2019 12:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729850AbfABMmy (ORCPT ); Wed, 2 Jan 2019 07:42:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46384 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729848AbfABMmy (ORCPT ); Wed, 2 Jan 2019 07:42:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D5EA80F88; Wed, 2 Jan 2019 12:42:54 +0000 (UTC) Received: from localhost (ovpn-12-39.pek2.redhat.com [10.72.12.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78BD4608E0; Wed, 2 Jan 2019 12:42:52 +0000 (UTC) From: Honggang Li To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [ibsim patch 04/23] sim_net.c: avoid copy garbage Date: Wed, 2 Jan 2019 20:36:08 +0800 Message-Id: <20190102123627.18629-4-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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 02 Jan 2019 12:42:54 +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 The sizeof(port->vlarb_high) is 128. sizeof(default_vlarb_high) is 30. memcpy(port->vlarb_high, default_vlarb_high, sizeof(port->vlarb_high)) will fill [31, 128] bytes of port->vlarb_high with garbage after default_vlarb_high. ------------------------------------------------------------------------- make[1]: Entering directory '/home/honli/rpmbuild/BUILD/ibsim-0.7/ibsim' cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include -I/usr/include -c -o sim_net.o sim_net.c In file included from /usr/include/string.h:494, from sim_net.c:38: In function 'memcpy', inlined from 'init_ports' at sim_net.c:648:3: /usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' forming offset [31, 128] is out of the bounds [0, 30] of object 'default_vlarb_high' with type 'const struct vlarb[15]' [-Werror=array-bounds] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sim_net.c: In function 'init_ports': sim_net.c:171:27: note: 'default_vlarb_high' declared here static const struct vlarb default_vlarb_high[] = { ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/string.h:494, from sim_net.c:38: In function 'memcpy', inlined from 'init_ports' at sim_net.c:650:3: /usr/include/bits/string_fortified.h:34:10: error: '__builtin_memcpy' forming offset [31, 128] is out of the bounds [0, 30] of object 'default_vlarb_low' with type 'const struct vlarb[15]' [-Werror=array-bounds] return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sim_net.c: In function 'init_ports': sim_net.c:176:27: note: 'default_vlarb_low' declared here static const struct vlarb default_vlarb_low[] = { ^~~~~~~~~~~~~~~~~ In file included from /usr/include/string.h:494, from sim_net.c:38: Signed-off-by: Honggang Li --- ibsim/sim_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibsim/sim_net.c b/ibsim/sim_net.c index a963ff6d6589..a62d39d39174 100644 --- a/ibsim/sim_net.c +++ b/ibsim/sim_net.c @@ -646,9 +646,9 @@ static void init_ports(Node * node, int type, int maxports) memcpy(port->sl2vl + 8 * j, default_sl2vl, 8); memcpy(port->vlarb_high, default_vlarb_high, - sizeof(port->vlarb_high)); + sizeof(default_vlarb_high)); memcpy(port->vlarb_low, default_vlarb_low, - sizeof(port->vlarb_low)); + sizeof(default_vlarb_low)); } }