From patchwork Tue Aug 13 13:52:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11092309 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 689F61395 for ; Tue, 13 Aug 2019 13:53:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A23B28699 for ; Tue, 13 Aug 2019 13:53:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E91C286A4; Tue, 13 Aug 2019 13:53:54 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D40FC28699 for ; Tue, 13 Aug 2019 13:53:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXDm-0006SG-CB; Tue, 13 Aug 2019 13:52:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXDk-0006S8-G3 for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 13:52:16 +0000 X-Inumbo-ID: 8e7c79c4-bdd1-11e9-ace5-33e37f24dc84 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8e7c79c4-bdd1-11e9-ace5-33e37f24dc84; Tue, 13 Aug 2019 13:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1565704335; h=from:to:cc:subject:date:message-id:mime-version; bh=i7Olcy1mMFqeL4hThALbIgKSUsvURztvVTRhgDHjJuI=; b=R5yhL32AGTV5OL4uUyRfk1ADPbf4B+J6iMXjX8o0IQBxoreJNAKQP2QY RjFGnVpbuAaq9iLF8cga6/wPeOQUBzlZ7HVsmNsyKHayxO+25dYlECb8Y ulTWi4oA6PQ9LBi9NAkqWTEp+FvBHELSwd0skWYK08GeKJyuslhZqCkWV U=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: azq86Yq4fQtESadWrLJiDNfIaFmipZ86eSLsTXkH7AUkeho2BGAhiHmZrFWbm2l2rTEjBLKnx0 5TEdDqkoLwHKCYv8QGeFv2UWzSVnwLVHu0nUlgay5wT4EATItzPi5BxkhUkUOl+ohcDLTxJFYX 8/GYwYqlzdqwAH8DVD7ZnsR5qPmVcu8hW8EIsckvQiZYpj+9HXj61SliIwbXHe/EGXiRthBAw/ cnRo1oxMRdbB4Tl2waQbO51RHMw0wiGKHKgjKJ9LSa95q+qBa6biNayMksaqj38rbb47BAuW1Z iS0= X-SBRS: 2.7 X-MesageID: 4408663 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,381,1559534400"; d="scan'208";a="4408663" From: Andrew Cooper To: Xen-devel Date: Tue, 13 Aug 2019 14:52:11 +0100 Message-ID: <20190813135211.13668-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] tools/xenstat: Fix -Wformat-truncation= issue X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Building with GCC 8.3 on Buster identifies: src/xenstat_linux.c: In function 'xenstat_collect_networks': src/xenstat_linux.c:307:32: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=] snprintf(devNoBridge, 16, "p%s", devBridge); ^ src/xenstat_linux.c:307:2: note: 'snprintf' output between 2 and 17 bytes into a destination of size 16 snprintf(devNoBridge, 16, "p%s", devBridge); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ devNoBridge[] needs one charater more than devBridge[], so allocate one byte more. Replace a raw 16 in the snprintf() call with a sizeof() expression instead. Finally, libxenstat, unlike most of the rest of the Xen, doesn't use -Werror which is why this issue went unnoticed in CI. Fix this. Signed-off-by: Andrew Cooper Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu --- tools/xenstat/libxenstat/Makefile | 2 +- tools/xenstat/libxenstat/src/xenstat_linux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile index 58f9d63de5..ea115ae0e6 100644 --- a/tools/xenstat/libxenstat/Makefile +++ b/tools/xenstat/libxenstat/Makefile @@ -31,7 +31,7 @@ OBJECTS-$(CONFIG_NetBSD) += src/xenstat_netbsd.o OBJECTS-$(CONFIG_FreeBSD) += src/xenstat_freebsd.o SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR) -CFLAGS+=-fPIC +CFLAGS+=-fPIC -Werror CFLAGS+=-Isrc $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude) -include $(XEN_ROOT)/tools/config.h LDLIBS-y = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -lyajl diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/xenstat/libxenstat/src/xenstat_linux.c index 9421ca43c8..7530349eee 100644 --- a/tools/xenstat/libxenstat/src/xenstat_linux.c +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c @@ -264,7 +264,7 @@ int xenstat_collect_networks(xenstat_node * node) { /* Helper variables for parseNetDevLine() function defined above */ int i; - char line[512] = { 0 }, iface[16] = { 0 }, devBridge[16] = { 0 }, devNoBridge[16] = { 0 }; + char line[512] = { 0 }, iface[16] = { 0 }, devBridge[16] = { 0 }, devNoBridge[17] = { 0 }; unsigned long long rxBytes, rxPackets, rxErrs, rxDrops, txBytes, txPackets, txErrs, txDrops; struct priv_data *priv = get_priv_data(node->handle); @@ -304,7 +304,7 @@ int xenstat_collect_networks(xenstat_node * node) /* We get the bridge devices for use with bonding interface to get bonding interface stats */ getBridge("vir", devBridge, sizeof(devBridge)); - snprintf(devNoBridge, 16, "p%s", devBridge); + snprintf(devNoBridge, sizeof(devNoBridge), "p%s", devBridge); while (fgets(line, 512, priv->procnetdev)) { xenstat_domain *domain; From patchwork Tue Aug 13 14:21:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11092337 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 8066D112C for ; Tue, 13 Aug 2019 14:23:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DEB227CEE for ; Tue, 13 Aug 2019 14:23:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E70E2860C; Tue, 13 Aug 2019 14:23:08 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA07027CEE for ; Tue, 13 Aug 2019 14:23:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXgC-00010U-IW; Tue, 13 Aug 2019 14:21:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxXgA-00010P-UM for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 14:21:38 +0000 X-Inumbo-ID: a8aeecce-bdd5-11e9-aafe-fb24cb3e9b9f Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a8aeecce-bdd5-11e9-aafe-fb24cb3e9b9f; Tue, 13 Aug 2019 14:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1565706097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=t5/h+6Ej+TC8Zr6OBX3eJkOkppP45klkWsjKMFGsuOg=; b=CCyZ4V12kHoYL8LaYNT/IYrsu0HAfbxokwXinzQ8Sdc/OJBlg2cC6S0H ZSfXYd1TxuV018hI6z2IynUn+SE0cPwaCY6He818SvdX5wBY/nEP0Pc4N TpQIHgo2kMvZiMtW4VN4yXUotRFxDkICtpDEzKG68t4Ls6BCpvt0WGvEl M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: C/s2QiV6b5tHjj+MLy7u+4Gy74glFwMsn0dP5CnSgrBlBDAyvREkt2PfnWpQYXYITRunK2Tvsq SwazN5AzKq/f7UE2RUv6vImsXXOrbe+BS3ym4dQFEiq/honI3XpNcG0zaD12AgPyME6ojwmcDf vJN71kQkUagAEb6oIoV5M1Oos32U7MB45jiBOfxvoVpX+JaqAAOi30lLUb4VCk7UTjGJ8B0w42 wGwmaxO5mgwQ0RtKPZsJ4x5FasTPQTQtrIQbBPiC4TD2yvN1to+5QjtNAa7Qn1z8eRELhOr7Ro glw= X-SBRS: 2.7 X-MesageID: 4218879 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,381,1559534400"; d="scan'208";a="4218879" From: Andrew Cooper To: Xen-devel Date: Tue, 13 Aug 2019 15:21:28 +0100 Message-ID: <20190813142128.18551-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190813135211.13668-1-andrew.cooper3@citrix.com> References: <20190813135211.13668-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/1] toos/xenstat: Fix -Wunused-function issue X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When compiling xenstat with -Werror, Clang complains: src/xenstat.c:134:34: error: unused function 'parse' [-Werror,-Wunused-function] static inline unsigned long long parse(char *s, char *match) ^ 1 error generated. Drop the function. It really is unused. Spotted by Travis-CI. Signed-off-by: Andrew Cooper Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu --- tools/xenstat/libxenstat/src/xenstat.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c index bba143eb53..6f93d4e982 100644 --- a/tools/xenstat/libxenstat/src/xenstat.c +++ b/tools/xenstat/libxenstat/src/xenstat.c @@ -131,20 +131,6 @@ void xenstat_uninit(xenstat_handle * handle) } } -static inline unsigned long long parse(char *s, char *match) -{ - char *s1 = strstr(s,match); - unsigned long long ret; - - if ( s1 == NULL ) - return 0LL; - s1 += 2; - if ( *s1++ != ':' ) - return 0LL; - sscanf(s1,"%llu",&ret); - return ret; -} - xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags) { #define DOMAIN_CHUNK_SIZE 256