From patchwork Mon Oct 5 16:02:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 11816975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FF06139F for ; Mon, 5 Oct 2020 16:06:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB20920663 for ; Mon, 5 Oct 2020 16:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB20920663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.3053.8832 (Exim 4.92) (envelope-from ) id 1kPSze-0004aA-Kh; Mon, 05 Oct 2020 16:05:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 3053.8832; Mon, 05 Oct 2020 16:05:42 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kPSze-0004Zy-BV; Mon, 05 Oct 2020 16:05:42 +0000 Received: by outflank-mailman (input) for mailman id 3053; Mon, 05 Oct 2020 16:05:41 +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.92) (envelope-from ) id 1kPSzc-0004ZS-W7 for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 16:05:41 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 45f20369-f9e3-40b3-a7fc-4ebc56793578; Mon, 05 Oct 2020 16:05:40 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAA511435; Mon, 5 Oct 2020 09:05:39 -0700 (PDT) Received: from e109506-lin.cambridge.arm.com (e109506-lin.cambridge.arm.com [10.1.198.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03B2A3F66B; Mon, 5 Oct 2020 09:05:38 -0700 (PDT) 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.92) (envelope-from ) id 1kPSzc-0004ZS-W7 for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 16:05:41 +0000 X-Inumbo-ID: 45f20369-f9e3-40b3-a7fc-4ebc56793578 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 45f20369-f9e3-40b3-a7fc-4ebc56793578; Mon, 05 Oct 2020 16:05:40 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AAA511435; Mon, 5 Oct 2020 09:05:39 -0700 (PDT) Received: from e109506-lin.cambridge.arm.com (e109506-lin.cambridge.arm.com [10.1.198.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03B2A3F66B; Mon, 5 Oct 2020 09:05:38 -0700 (PDT) From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, Ian Jackson , Wei Liu Subject: [PATCH 1/2] tools: use memcpy instead of strncpy in getBridge Date: Mon, 5 Oct 2020 17:02:48 +0100 Message-Id: <3de58159c6fde0cdfa4d0f292fa55fdb931cb3aa.1601913536.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Use memcpy in getBridge to prevent gcc warnings about truncated strings. We know that we might truncate it, so the gcc warning here is wrong. Revert previous change changing buffer sizes as bigger buffers are not needed. Signed-off-by: Bertrand Marquis --- tools/libs/stat/xenstat_linux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linux.c index d2ee6fda64..1db35c604c 100644 --- a/tools/libs/stat/xenstat_linux.c +++ b/tools/libs/stat/xenstat_linux.c @@ -78,7 +78,12 @@ static void getBridge(char *excludeName, char *result, size_t resultLen) sprintf(tmp, "/sys/class/net/%s/bridge", de->d_name); if (access(tmp, F_OK) == 0) { - strncpy(result, de->d_name, resultLen); + /* + * Do not use strncpy to prevent compiler warning with + * gcc >= 10.0 + * If de->d_name is longer then resultLen we truncate it + */ + memcpy(result, de->d_name, resultLen - 1); result[resultLen - 1] = 0; } } @@ -264,7 +269,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[256] = { 0 }, devNoBridge[257] = { 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); From patchwork Mon Oct 5 16:02:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bertrand Marquis X-Patchwork-Id: 11816977 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9647139F for ; Mon, 5 Oct 2020 16:07:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A9D120663 for ; Mon, 5 Oct 2020 16:07:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A9D120663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.3054.8845 (Exim 4.92) (envelope-from ) id 1kPSzi-0004cE-Ov; Mon, 05 Oct 2020 16:05:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 3054.8845; Mon, 05 Oct 2020 16:05:46 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kPSzi-0004c7-Lb; Mon, 05 Oct 2020 16:05:46 +0000 Received: by outflank-mailman (input) for mailman id 3054; Mon, 05 Oct 2020 16:05:45 +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.92) (envelope-from ) id 1kPSzh-0004ZS-SW for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 16:05:45 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 73854755-f9e2-4046-ac3c-4ee76d2eb441; Mon, 05 Oct 2020 16:05:40 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A6A3C143D; Mon, 5 Oct 2020 09:05:40 -0700 (PDT) Received: from e109506-lin.cambridge.arm.com (e109506-lin.cambridge.arm.com [10.1.198.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DBEF83F66B; Mon, 5 Oct 2020 09:05:39 -0700 (PDT) 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.92) (envelope-from ) id 1kPSzh-0004ZS-SW for xen-devel@lists.xenproject.org; Mon, 05 Oct 2020 16:05:45 +0000 X-Inumbo-ID: 73854755-f9e2-4046-ac3c-4ee76d2eb441 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 73854755-f9e2-4046-ac3c-4ee76d2eb441; Mon, 05 Oct 2020 16:05:40 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A6A3C143D; Mon, 5 Oct 2020 09:05:40 -0700 (PDT) Received: from e109506-lin.cambridge.arm.com (e109506-lin.cambridge.arm.com [10.1.198.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DBEF83F66B; Mon, 5 Oct 2020 09:05:39 -0700 (PDT) From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: jgross@suse.com, Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH 2/2] tool/libx: Fix libxenlight gcc warning Date: Mon, 5 Oct 2020 17:02:49 +0100 Message-Id: <1c0b3a351e20e31093b5f59edd7fafeac1ceb75c.1601913536.git.bertrand.marquis@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Fix gcc10 compilation warning about uninitialized variable by setting it to 0. Signed-off-by: Bertrand Marquis Acked-by: Wei Liu --- tools/libxl/libxl_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libxl/libxl_mem.c b/tools/libxl/libxl_mem.c index e52a9624ea..c739d00f39 100644 --- a/tools/libxl/libxl_mem.c +++ b/tools/libxl/libxl_mem.c @@ -562,7 +562,7 @@ out: int libxl_get_free_memory_0x040700(libxl_ctx *ctx, uint32_t *memkb) { - uint64_t my_memkb; + uint64_t my_memkb = 0; int rc; rc = libxl_get_free_memory(ctx, &my_memkb);