From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60F02C433B4 for ; Fri, 14 May 2021 14:18:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CED7A61457 for ; Fri, 14 May 2021 14:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CED7A61457 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 540066B0036; Fri, 14 May 2021 10:18:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F0876B006E; Fri, 14 May 2021 10:18:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B8096B0070; Fri, 14 May 2021 10:18:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 08F136B0036 for ; Fri, 14 May 2021 10:18:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A41E28249980 for ; Fri, 14 May 2021 14:18:12 +0000 (UTC) X-FDA: 78140041224.18.CB19EF3 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf04.hostedemail.com (Postfix) with ESMTP id B7ADD3C6 for ; Fri, 14 May 2021 14:18:11 +0000 (UTC) Received: by mail-lj1-f173.google.com with SMTP id y9so38053755ljn.6 for ; Fri, 14 May 2021 07:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zeADjb0+I4ih+f6OTxvqUIidNyxQ51wGxn/eDKNc11c=; b=uvW4QBqNiX55Ndz3ODlT5mPJEiDsHn2hLl8Cpr1bdsr9CIiCSaW2kDNQsH5qfdUi6J ehtqsrBWX/7dy9EN1KUbhqAQb2Zi4OvofJOOkTL8KEzbofM4KtLVLPeNzOUHxDUYLG9p 0r2iff5U1ibL4j0wjqqXZAbRLiTLPBgL6edGJeZY0TEv3tcZHwZisIs6Yl0qEZ8JXG81 NH9uxiClWVBRxdGHhB4xVFBVZZGXG90rGchPIVPVIzxCKUavZf7//A56HRhnU8rs+S4A bfcfCLLScz2hB0BXe5Q+Zutk5NFK6I7gWCXRITAnXOvzYqJLv25I5YpZ+zI+fAmm9jMw u5Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zeADjb0+I4ih+f6OTxvqUIidNyxQ51wGxn/eDKNc11c=; b=kLhxxIxedv2YtPDckCsdFmwgXPIUS7/98jaM94XoF//i+IDsF/IoTOFWslxJhpyHdF irCNbLG3oTfeFEyTow06usqKBkUPeYIBYDzTRGCVfrexh6+1fxmSXutihdhNO8psk7qu nw3cz0MWrdnjQGtc3L7ZBWa1e9DMO//oaxChYl2A3BRLis4ghLO2vJbR++mxnqi+XeZt mmTtDAftod37uAA8bLzXngtLMgd9xL9WpmGHctMgQxXPg65FD2puendM4yHQwJcGL8jc F2X/B+JeRNOoK8NW8MTF6GQj4YkuOn/8lQju4Mej2fdkZvxzMYqpbYLa+7ZCpIqXY6C0 GZHg== X-Gm-Message-State: AOAM533H4PC5YMQZwsOZVDK2agq4dYZOuX8vOhQBxHUhUalFEoQH327I 9cQNZvtgUUAE2lkLtmoYIbzWvakFTvquFFU9NCM= X-Google-Smtp-Source: ABdhPJw1ExEGqWnpMkZ0Pys13bnIP8B1Ecn5XRjcZReJpwN/w1n2e+VmNrFAjtMQHmAYwJ8fzJH9yysmcx0jN9Yb6hA= X-Received: by 2002:a2e:974d:: with SMTP id f13mr38247313ljj.258.1621001890580; Fri, 14 May 2021 07:18:10 -0700 (PDT) MIME-Version: 1.0 References: <20210514063622.GU2687475@shao2-debian> In-Reply-To: From: Alexei Starovoitov Date: Fri, 14 May 2021 07:17:59 -0700 Message-ID: Subject: Re: [linux-next:master 2296/2770] kernel/bpf/helpers.c:713:43: warning: Uninitialized variable: bufs [uninitvar] To: Florent Revest Cc: kernel test robot , kbuild-all@lists.01.org, Linux Memory Management List , Alexei Starovoitov Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=uvW4QBqN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of alexeistarovoitov@gmail.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=alexeistarovoitov@gmail.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B7ADD3C6 X-Stat-Signature: ezt4gch33ma8g3wu8ywdhbowddpyq87b X-HE-Tag: 1621001891-842260 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 14, 2021 at 7:10 AM Florent Revest wrote: > > On Fri, May 14, 2021 at 8:37 AM kernel test robot wrote: > > cppcheck possible warnings: (new ones prefixed by >>, may not real problems) > > > > >> kernel/bpf/helpers.c:713:43: warning: Uninitialized variable: bufs [uninitvar] > > if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(bufs->tmp_bufs))) { > > ^ > > I don't think this is a real problem. bufs is not actually > dereferenced, it is only used to give the type information to a > sizeof. This is only evaluated at compilation time. > > If this matters, I guess we could silent this cppcheck warning with > something like the following patch. Alexei, what do you think ? > > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -697,8 +697,9 @@ static int bpf_trace_copy_string(char *buf, void > *unsafe_ptr, char fmt_ptype, > #define MAX_PRINTF_BUF_LEN 512 > > /* Support executing three nested bprintf helper calls on a given CPU */ > +#define MAX_PRINTF_NEST_LEVEL 3 > struct bpf_bprintf_buffers { > - char tmp_bufs[3][MAX_PRINTF_BUF_LEN]; > + char tmp_bufs[MAX_PRINTF_NEST_LEVEL][MAX_PRINTF_BUF_LEN]; > }; > static DEFINE_PER_CPU(struct bpf_bprintf_buffers, bpf_bprintf_bufs); > static DEFINE_PER_CPU(int, bpf_bprintf_nest_level); > @@ -710,7 +711,7 @@ static int try_get_fmt_tmp_buf(char **tmp_buf) > > preempt_disable(); > nest_level = this_cpu_inc_return(bpf_bprintf_nest_level); > - if (WARN_ON_ONCE(nest_level > ARRAY_SIZE(bufs->tmp_bufs))) { > + if (WARN_ON_ONCE(nest_level > MAX_PRINTF_NEST_LEVEL)) { Yeah. Why not. I think it's cleaner overall.