Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2323476pxb; Tue, 12 Oct 2021 04:18:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwut7rtWpNwYuDDw0uaH+ygnfdZacxaoA8wvYbCoriR+4wKq4VRiOuiJbCkcfU+wQpIFhhb X-Received: by 2002:a17:903:1248:b0:13e:7226:9f3a with SMTP id u8-20020a170903124800b0013e72269f3amr29717970plh.32.1634037529933; Tue, 12 Oct 2021 04:18:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634037529; cv=none; d=google.com; s=arc-20160816; b=gB+m4qEU2SWj7DC1LiY65VU4/2/fjFeVf8d56cNbqIF8IL3NGyK8WtrEvUAxfaq45+ fTOn9yc9HryVeITGRz1ESC5b2AVpKHjLHNt9NzWeHA+HuzlOKHLMOJKYQzjQvnIjdrpW S1Q+vQf5ojAIgPdcZ3wTtD0T/PFoIY4YXt3gQM3GvDDAFBb85Ianm+pyzbHVQBfWyNIL BvhY5TVryg2aSw9tahleP4nPoSoOpwMJHXVGI0AdSZFtczSX8aRcWos/+vDrM1dd0mJ3 zGE6UNog/IpUTWhoGyVVidW7sKUn+zITuf4opBKSJmitiwQ0KnVpbYjLOagtuaSMQ0bu +f1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=toin2qRutuPFHVWf+g8domdh9ga8LXuWYrISewj7CEM=; b=gb9fOxII3BmSoAaGeTDmtyMnMlkxJkrrmd3dN/c/P879HtgKfSi7WcrengwPHQtgQk EYujTYNhbs62TgwtjNWUh6oih9p+mfnxsx3fClKujmS2gJZtsSzL1pCIqh9JYXdYSDe0 YXJtaSGxVSGonjVDd+skP9tsAiQiMb8pdFQNcdjCSp+Ok2rf/MrYZhAGoYxwp2jmGXfO 9WrJXSqf6/5aHw5JWERF56Rgd6/YzlWqf+KkhXar0j48Q8Eyyi0pfzxrCPfBE4oYlF+z 7c/bDruWfHNw+E/9FPSCyzwbatjP1QzSQf6SVEevpZ9dqF4wGSutaDDS+oxmBgEuj/AR 1mdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j0050Lny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si1470207plh.349.2021.10.12.04.18.36; Tue, 12 Oct 2021 04:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j0050Lny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236134AbhJLLTJ (ORCPT + 99 others); Tue, 12 Oct 2021 07:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232665AbhJLLTH (ORCPT ); Tue, 12 Oct 2021 07:19:07 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C25C061570; Tue, 12 Oct 2021 04:17:06 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id q5so5538971pgr.7; Tue, 12 Oct 2021 04:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=toin2qRutuPFHVWf+g8domdh9ga8LXuWYrISewj7CEM=; b=j0050LnyUGXdh7+N0cUFjwwpgCK+nBjYRj668ZBSS+1KLxHmQrxXIb/5qyKAQ40ToG Hu6ge+c26Hz1/Ad+kY75fcr5aWzmS9vSo3ThWdyxcFcbnxwV0iERsRQY8AldmR7Qcccx rmsm853DLLhxZSVVlhhXoKr6vmmo/b2wmHB/CIDNgUDNTUmemSdftPF19+xsyBOozOp/ Tv6xbI1iCD/ghms30JSUznvToFpursgOUWShVDTetiSik2VP4D6q92T8LY/Lk4wjnXXc tTuFGCSLj685t2IYUBDTRSjecEWPruU+sn0tY0GFK81a27vzgeyVZkI4dJqecG7LwBav 7x6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=toin2qRutuPFHVWf+g8domdh9ga8LXuWYrISewj7CEM=; b=iJ4mSOc6UNkKNgSpmg2tknwagkJ/1/QcYZBToPuAQMhvpg3vkI1zCaL6TO6R3i0gcy jBAxs531k/zlB3qmfyn4Ryzjx16wYBIdf+S5746pWT06DcR6k+Q8QdBi4KvLgGC1SlnK GBtEvmvTS802NiS4CuRSQfOcflDqhaAuNnsOeehicAmPHONOaKxPLgTCCRPcBh0RVPzc 9/VZ3SI1DWDLfpc1pNa0NZwJ5pKUo+mJj4C8rilILEKzReh/78YoDtpIJ65tuhLnmY1z ZFeK/f3MJslSsnTWeXo2EPKtyNoSGRCz0+L/oidAwUApZJ5faIjNooLXC14Ybqb9JFrF 7JnQ== X-Gm-Message-State: AOAM530pL0vtLCq508R2Xm1e9KA2xtVZR1rtr+TnvS1v787gVPhCPyFr SzEENsb0ILRXglEooGmH0nc= X-Received: by 2002:aa7:814f:0:b0:44d:626:8b96 with SMTP id d15-20020aa7814f000000b0044d06268b96mr15953073pfn.65.1634037426042; Tue, 12 Oct 2021 04:17:06 -0700 (PDT) Received: from debian11-dev-61.localdomain (192.243.120.180.16clouds.com. [192.243.120.180]) by smtp.gmail.com with ESMTPSA id 63sm10383409pfv.192.2021.10.12.04.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 04:17:05 -0700 (PDT) From: davidcomponentone@gmail.com To: ast@kernel.org Cc: daniel@iogearbox.net, davem@davemloft.net, kuba@kernel.org, hawk@kernel.org, john.fastabend@gmail.com, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, kpsingh@kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, David Yang , Zeal Robot Subject: [PATCH] Fix application of sizeof to pointer Date: Tue, 12 Oct 2021 19:16:49 +0800 Message-Id: <20211012111649.983253-1-davidcomponentone@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Yang The coccinelle check report: "./samples/bpf/xdp_redirect_cpu_user.c:397:32-38: ERROR: application of sizeof to pointer" Using the "strlen" to fix it. Reported-by: Zeal Robot Signed-off-by: David Yang --- samples/bpf/xdp_redirect_cpu_user.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c index 6e25fba64c72..d84e6949007c 100644 --- a/samples/bpf/xdp_redirect_cpu_user.c +++ b/samples/bpf/xdp_redirect_cpu_user.c @@ -325,7 +325,6 @@ int main(int argc, char **argv) int add_cpu = -1; int ifindex = -1; int *cpu, i, opt; - char *ifname; __u32 qsize; int n_cpus; @@ -393,9 +392,8 @@ int main(int argc, char **argv) fprintf(stderr, "-d/--dev name too long\n"); goto end_cpu; } - ifname = (char *)&ifname_buf; - safe_strncpy(ifname, optarg, sizeof(ifname)); - ifindex = if_nametoindex(ifname); + safe_strncpy(ifname_buf, optarg, strlen(ifname_buf)); + ifindex = if_nametoindex(ifname_buf); if (!ifindex) ifindex = strtoul(optarg, NULL, 0); if (!ifindex) { -- 2.30.2