Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp114652pxb; Wed, 20 Oct 2021 17:51:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa39eT/Iukr/h6MXtxUKJfeEFI+q+Fh6nJzHBl35+B4nwHrtzlT9IWcb5Ak4yvtDJvvuaP X-Received: by 2002:a62:5585:0:b0:44d:e30f:fa7c with SMTP id j127-20020a625585000000b0044de30ffa7cmr2231495pfb.53.1634777499593; Wed, 20 Oct 2021 17:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634777499; cv=none; d=google.com; s=arc-20160816; b=jHq09NevLeEnONRkI5fdDAHSWxx88x15V6vlva0vc9b9Ld0kkP3GsrYTspo0ja6U9c ZISohuGogOidbq4X0P1nyNw2LAuic67btWSZC4sbbCGcRRA0fh2irvJ4AIKA1sMCzo+2 Ulo9/0h/cYU5MPQVmDHfZpHkyPDciRw3NPrwPkenMB/wIVJqJIcj3JXSAh235XahsYDY L50AaWIsA0im3YLy0Wjwus9axbymxOkpYj4feHn5Usap/5oYlMa8apoulmPaMl+bzYUH oUO6p4OP6A2LPMOnfDfsHcAib7aVlR6WPufJco0/gF/H8fIHIwyB9bvA9OeuPegL4pJr LaLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LBP5Fct0djt6mKAEsqcCGlc9cav1Q45SnSe6amQOB6w=; b=Yt74Oj845H25BOm7gDcRM1PQCaTmZoixMx8yBqG8q8sdT/Gn3b9+5Gz18HrylGKsVz ZXVWBaQiSp6VYR5obuLMqulDYHF5+PbRiSm6YokTRIYrxu0haF8sP2qBKmpZDIkxB9Qi GNTIcwNe2P8h+CO6vd++dpsclS1t8uEDEhPB05AuWAMBqrig/7ifwHHyXHL/IdXrP9vs GO7wDaNc3t9nAxccdsXhz8pZVZ21HRJLRI84Kn9SvP21Vsmha4DbsQ+8bnaFb8ZJ/DaT T6NpgJjKV5KPqeb9CPLJn1FN0EH5ICk9jakZSJbpHzjQfKnQMPTicIEmtz9Nr5CFU3Hd Ygmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D8p1eYu7; 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 a11si7104565plh.292.2021.10.20.17.51.25; Wed, 20 Oct 2021 17:51:39 -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=D8p1eYu7; 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 S230478AbhJUAwl (ORCPT + 99 others); Wed, 20 Oct 2021 20:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhJUAwk (ORCPT ); Wed, 20 Oct 2021 20:52:40 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04510C06161C; Wed, 20 Oct 2021 17:50:26 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id v20so17312196plo.7; Wed, 20 Oct 2021 17:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LBP5Fct0djt6mKAEsqcCGlc9cav1Q45SnSe6amQOB6w=; b=D8p1eYu7WKL5aIY3QZokqwN22izeZJ4rqn010YaHFupnD+2WIt/2bcobqw20XT4OVt lg7YFwFdiumPIYDF9Fvjh9eIDzU8QB4jPmoi/GsLYTPrQ60BA/t+3E5PIijAzfkupVOP TN+8EUcNpk7Kdjrx99Iydrw3At6KfgJ9OmK1hahJUl4uiTOu3ErDPqmLY+mtcocpQEPH ISbTjbozQuHMOa269P/uaBYYO3YjAZZc188CPfjJfpSFXi8aJJJQAb/eP57N+Qr8uK6Q 9SHyLATS22oLm+yTdGgRygP8e8P4WkEmy2iaD/GrAGTRj+bOuw+zeLGFZe9aN9RDBNUT 0pCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LBP5Fct0djt6mKAEsqcCGlc9cav1Q45SnSe6amQOB6w=; b=FJez0v6+RKAMLTeBpIhOv5c1LyFxOWy6KvNG6BHlPD50fTa8SyLWGlhHdKWaUJYoDT wcspnSSPa36TxMaVm30knFNhJnzhXEmZJ7cxzAzA5WKaXCvwInTDMhRdWgBfxNaBREuv ccFDgZYWq4K7+8qSF+Uh4s8cfPqtbLZXFC6woAACgWldQL6AlVv/Fyo4zIT82BYmIM0I X3ZNN1LBiLvPxESsekna2jDt2LRsps/CpVjW9HhXlKNNKrIJkxFYaHQjDF/0M1v1Q3/h 7Qars0rCaRm+2BGVGo4l4/pAN+LeoYQLI24kJvJykievIWCW8os+juB46+U6zlrq0qld 1EfA== X-Gm-Message-State: AOAM533Pbn/TZgaexEtYtpwL1xKrR4AylrGDylU7vl772hsXqV6B+68Y 5b0X6U+XllgmbccPUUNCww0= X-Received: by 2002:a17:902:7783:b0:13d:fee6:8095 with SMTP id o3-20020a170902778300b0013dfee68095mr2293640pll.7.1634777424113; Wed, 20 Oct 2021 17:50:24 -0700 (PDT) Received: from postoffice.intern (192.243.120.180.16clouds.com. [192.243.120.180]) by smtp.gmail.com with ESMTPSA id d137sm4001604pfd.72.2021.10.20.17.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 17:50:23 -0700 (PDT) Date: Thu, 21 Oct 2021 08:50:13 +0800 From: David Yang To: Andrii Nakryiko Cc: Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , john fastabend , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , KP Singh , Networking , bpf , open list , Zeal Robot Subject: Re: [PATCH] Fix application of sizeof to pointer Message-ID: References: <20211012111649.983253-1-davidcomponentone@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OK, Thanks. On Wed, Oct 20, 2021 at 10:55:27AM -0700, Andrii Nakryiko wrote: > On Tue, Oct 12, 2021 at 4:17 AM wrote: > > > > 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 > > --- > > For future submissions, please use [PATCH bpf-next] subject prefix. > For changes that are targeted against BPF samples, please use > samples/bpf: prefix as well. So in this case the patch subject should > have been something like: > > [PATCH bpf-next] samples/bpf: Fix application of sizeof to pointer > > I've fixed it up and applied to bpf-next, thanks. > > > 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 > >