From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by dpdk.org (Postfix) with ESMTP id 07D434C70 for ; Thu, 29 Mar 2018 19:05:38 +0200 (CEST) Received: by mail-pg0-f67.google.com with SMTP id a15so3450400pgn.5 for ; Thu, 29 Mar 2018 10:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RzR0TsjFqZkmaDlcFvuBe+c8OtqRFcfKQFfymEydwJE=; b=BwEMzbfRuduHRmaqbHrPXLeR16wTMB9LWVX5263kgnI2PWzWl1BbdJwP14M/p2Ypwe Sudsp75CZ/X2VH6PISmuEYWXhOzgjxAODNr1Asq/YrliY57wuaMXPBo8zeqgcOuass13 IUUW0TuDEH7khfyaAjfc+fOyx5nBjGr80Rae0d4uzZUXHCXyfz3castOHR9Sb4KsNBX7 bs3xl52yiZbh6PD9VM8gYCyLmgzL/cmydBH4aPNp/5t/1879ZEuFifzwnBChnB5gidWO woM9M4fQKEHkPd38XpRsxDQrLYZ647Mc2xecqD1O8tqggi56RL3NUFOJha5Db2xzBX88 JA3Q== 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=RzR0TsjFqZkmaDlcFvuBe+c8OtqRFcfKQFfymEydwJE=; b=Dg/EbPjOfFyoolnjy3NxKaFJ/pnKW4TBnppFwUBn3RlPJVCRFXRws8bY4WVPo3cpFv jHchzMcKJu5et08SYc4ACMf7IJ9go8LCzObclETkVuOIIb6mrh0romMBrobCg97TUSgu 6BRnAsZI7y44tQP8kOf0RpkR9Q3OCNXu4SlCxHaMwfQNt5e7l+KMt5YotnCY0WdDJEr6 xmb2or0UKGoCeLyalldtJGx/khKSt31jDAnkzd/c+kwK4C8sNpkPOi2ncKD9vyCHeZt8 ks8yOp0SEvZGshsABSd9r8sdyIh8YBrXVkW70DTyx8+iXsbyhoQJ9Pzi40QmTXzl1eWp f8lQ== X-Gm-Message-State: AElRT7EYgV/mjR+qhj5IKgzkNRbau7Z5/p7sJxn+FER6182fyovUG3Q5 bBVn2dvlzcf7AApjaF0DRlGNYqLatZ4= X-Google-Smtp-Source: AIpwx4/klL4oSnPhPPl7oF9XvP8yZv+6Cf7DA2tsE/nGa39t6yYdsHKd/CWTH8XduKxltd5qolxY/g== X-Received: by 2002:a17:902:8206:: with SMTP id x6-v6mr9443637pln.256.1522343136845; Thu, 29 Mar 2018 10:05:36 -0700 (PDT) Received: from xeon-e3.lan (204-195-71-95.wavecable.com. [204.195.71.95]) by smtp.gmail.com with ESMTPSA id p1sm12748631pgr.67.2018.03.29.10.05.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 10:05:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 29 Mar 2018 10:05:31 -0700 Message-Id: <20180329170531.2478-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180329170531.2478-1-stephen@networkplumber.org> References: <20180329170531.2478-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/2] rte_metrics: fix strncpy truncation warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2018 17:05:39 -0000 Fixes: librte_metrics/rte_metrics.c:218:4: error: ‘strncpy’ specified bound 64 equals destination size [-Werror=stringop-truncation] strncpy(names[idx_name].name, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ stats->metadata[idx_name].name, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RTE_METRICS_MAX_NAME_LEN); ~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Stephen Hemminger --- lib/librte_metrics/rte_metrics.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c index 556ae1ba8b4d..e0f803ef0880 100644 --- a/lib/librte_metrics/rte_metrics.c +++ b/lib/librte_metrics/rte_metrics.c @@ -214,10 +214,13 @@ rte_metrics_get_names(struct rte_metric_name *names, rte_spinlock_unlock(&stats->lock); return return_value; } - for (idx_name = 0; idx_name < stats->cnt_stats; idx_name++) + + for (idx_name = 0; idx_name < stats->cnt_stats; idx_name++) { strncpy(names[idx_name].name, stats->metadata[idx_name].name, - RTE_METRICS_MAX_NAME_LEN); + RTE_METRICS_MAX_NAME_LEN - 1); + names[idx_name].name[RTE_METRICS_MAX_NAME_LEN - 1] = '\0'; + } } return_value = stats->cnt_stats; rte_spinlock_unlock(&stats->lock); -- 2.16.2