Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4724122rwb; Tue, 6 Sep 2022 11:37:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR4w8H89hyCQlZcceYmGV5/A69m7VuXB/wuKw8bp63v6lIXcuDYUmAkkb2B/YIqSErKHxcfm X-Received: by 2002:a05:6a00:15cb:b0:52e:6100:e7a7 with SMTP id o11-20020a056a0015cb00b0052e6100e7a7mr55550797pfu.23.1662489428516; Tue, 06 Sep 2022 11:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662489428; cv=none; d=google.com; s=arc-20160816; b=qAv+GARxeuW/h10wyZAJharXw0tJbwoSCN92RHR0vYkiJYd/K86EYvSDZ7/VZIBw1K z7k7NfuSIoFVItuBSmkLr7yI9TnqsnA/CkIxxJ/PLRG5SvIm96LEi2V5s5fAAiOnZzXk +W7+c6/XxwXbgRCPWqfsNACqSshoBdUInldglilwxhmxIk87nN8mpzIwRKUo6QS2Gyfe cdtyQf0IWca6+jmjqptLvMXZNYNJEJ/jDz9P4xUWsy3JCjUNso56orw7ukG0/gyToL2X SbG41xTHoz7OmTf2fjxEf1oP2l2QizVvAENwYffi8G/In4o4oMGtqjHDTGst/1PFNv3Y J+jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nnW0gh4/5RbElboZnDeZlyzS1e6LNOQ80svTWGcDjDo=; b=CpnWm94eeCYbOZGcOlc2pgsXi4Rzl/rVwcFG+z4oVbKA+mw6qk8EM07Tx4DQR3fpXf x0FSd7q/DWpSH6MLtYb5/Zyb73gp1Yg4etfsR4gMviq8zoSFKXGpEW2fCvPmaKQLIPD/ PUB9WcVjBpFuNcoXJTUhy90sQkD1L+K0ynV4S0Q81RLuzXGwmFvVkeO4S/EFnwu6oRui FUBs4WWg5mopAjfQ/07/x7bzNU388sSlFUZEkdUtCY2jLkoelwiaA3U3X/0tYUAAWhKi VwWsgYxNH9sPXXLIk/1+aviO0SSQTYECy93qcb0sP8XG59vkkRbSiGcCP+PdxtXeYPz8 NDtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qe+vUnlQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a632113000000b0042b6b681286si14905551pgh.84.2022.09.06.11.36.56; Tue, 06 Sep 2022 11:37:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qe+vUnlQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229816AbiIFS3y (ORCPT + 99 others); Tue, 6 Sep 2022 14:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbiIFS3x (ORCPT ); Tue, 6 Sep 2022 14:29:53 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADDA64D253; Tue, 6 Sep 2022 11:29:51 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id 29so11219659edv.2; Tue, 06 Sep 2022 11:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=nnW0gh4/5RbElboZnDeZlyzS1e6LNOQ80svTWGcDjDo=; b=Qe+vUnlQNcxNOXltmkpjWbPqfsi1WAYaUaKTSmIpEUgzBt2Iyw+UgHMTwaIbwMfVa6 7T5SH0nEkcAt0NPEuJ4G45WjTDAuRCFwUmWFPqDjx7NaPIMEebV6KBVGWSU9H9N4hf/3 d/xVA5SaMOMZ9pzEmxF9qXCASQUYSf6WQ7raxslLgXRcbGtI+tG2HUvA3e+3rrsv4Ox8 QYo57B0UBTrQ1lVOa1K4FeXOTy3zKJoEmRnbqCXN/MLg5u1cxWNcQgctJYCT+i3p93p8 dY9Nm91Cv0enJUuPePggqO6DAUtapN1BZKEdeWhiChApbsrQaHnZeBr3so7nhMbOfPif 31iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=nnW0gh4/5RbElboZnDeZlyzS1e6LNOQ80svTWGcDjDo=; b=VXfsYO7MumH3j67zfNy4HKqvEHXd1xOFFdcxLwicoiQ/m+izJxleeRQBNRwxzZcUpB dReLqEVy5fxHdDESbPWIdFtPBVnWX/foopSUYZ8vIS9zyDPMkTLFt94tQjNd1wfAvZfm swAI62Qk8uGdcGG1yl/4QTaPNqYo8GlDexg0ImkAZO9kfBvgAn9MUAgsc82tR9i/IaNN XqDnt021l8yPfdy9lCtzDCRzAI0K2Xv7SRAQTesP1lvAKr9QRKzwo8RK3Otpv5xKJA7G Vs1iiVY0Patp3MH8XTlLb9fEAfCDurJ7mViPPOadcOHigwWlO9ZLOtmf6UVIkJ3Qg5lJ 1B4g== X-Gm-Message-State: ACgBeo1V8BkZ+n5sJgETyrjaY9tku4lgbVCmLaRJbtRG5WDc+rragwX2 ndtlxaKtNDc3bGdIg55ugnXPFvUqgK9B3KSFb0g= X-Received: by 2002:a05:6402:28cb:b0:43b:c6d7:ef92 with SMTP id ef11-20020a05640228cb00b0043bc6d7ef92mr48859651edb.333.1662488990119; Tue, 06 Sep 2022 11:29:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Alexei Starovoitov Date: Tue, 6 Sep 2022 11:29:38 -0700 Message-ID: Subject: Re: [PATCH 2/2] bpf: Fix warning of incorrect type in return expression To: Jules Irenge Cc: Martin KaFai Lau , Elana.Copperman@mobileye.com, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Yonghong Song , John Fastabend , KP Singh , LKML , bpf , Stanislav Fomichev , Hao Luo Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 3, 2022 at 12:02 PM Jules Irenge wrote: > > Sparse reports a warning at bpf_array_map_seq_start() > > "warning: incorrect type in return expression (different address spaces)" > > The root cause is the function expect a return of type void * > but instead got a percpu value in one of the return. > > To fix this a variable of type void * is created > and the complainining return value is saved into the variable and return. > > Fix incorrect type in return expression > > Signed-off-by: Jules Irenge > --- > kernel/bpf/arraymap.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c > index 624527401d4d..b1914168c23a 100644 > --- a/kernel/bpf/arraymap.c > +++ b/kernel/bpf/arraymap.c > @@ -548,6 +548,7 @@ static void *bpf_array_map_seq_start(struct seq_file *seq, loff_t *pos) > struct bpf_map *map = info->map; > struct bpf_array *array; > u32 index; > + void *pptrs; > > if (info->index >= map->max_entries) > return NULL; > @@ -556,8 +557,10 @@ static void *bpf_array_map_seq_start(struct seq_file *seq, loff_t *pos) > ++*pos; > array = container_of(map, struct bpf_array, map); > index = info->index & array->index_mask; > - if (info->percpu_value_buf) > - return array->pptrs[index]; > + if (info->percpu_value_buf) { > + pptrs = &array->pptrs[index]; > + return pptrs; > + } Somebody will surely send a patch to optimize above back to original code. Please find a different way to shut up sparse or just ignore it.