Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1325921rwb; Sat, 3 Sep 2022 13:08:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR5frAO6OD4w5aDtWzaXaj7rx2K3VrlYvh9FdUWzvJoupumlpZYgCULKdhbE8u+6Bm+OnMMX X-Received: by 2002:aa7:da83:0:b0:44e:69ba:81c7 with SMTP id q3-20020aa7da83000000b0044e69ba81c7mr169213eds.323.1662235722018; Sat, 03 Sep 2022 13:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662235722; cv=none; d=google.com; s=arc-20160816; b=yZ2UBSrUyGDu9yKIL4Rl2vyphjYRGS6Av7ra9Fa84eycsMUKw6S99E1Al+vmis9+MZ iQu8MVs+sB6pAEZJpJ8D/V3fw3w1PqtKEId9ZYxJWTLdhJQw+urXzW43seNqwC4gVoMA m+2K0pSlfjUqgAHEtKD3pYAzF2tE9vdphqh82JbFDe6e9sOXbu3CnlkdvUCKouQSsMrM ko0NvlPfiphiPO9MhVhzLqXyltbgBKAhwL6921uSbUkiguVRWEIA4xukAveM4oR+mDG0 MO6o04NsPqw3T8rcGAcaMQfQw3aobRGrXRIKdqPH+tdJhTkTtSoreac6dGPmcv86lV8I hv1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=Qf7PXikGCovsdv/2K6jAdSbyiEi6rrfmnYyZf0F4aGk=; b=ecXHE5WVJdQgaZDIw1tk1DOqR7EH/CQp3W0JoLKFMgvHP0kLMuMjlB94Bt2ZLqPjZO kVPBuJghv0VBW3tjh4rN3SD+hbvsMV0vkcblu5fqNAUFdShH9ETBy/a+7MOVVDbb2OKq XMLyFmY0WXk+s8XVA6c68kU8ya30hEwijO9D1zeMPPU1Yjf8ZE/mjplV78fV8hyBLn6C Z0tSWK35GclFldUMpvscSGmbURUncllxeruq496i8QLOzR1wzcTJ21WhE0SwW6fjG0NL iWgbuZ4CI5mevkrBMelo6cnbwFSV3Ope83ZckUlfmbzMvH3AiE8iTNDwwYZe2NcqZvUw nalA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PArMLiFe; 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 q8-20020a170906770800b007306dde08desi3638953ejm.448.2022.09.03.13.08.07; Sat, 03 Sep 2022 13:08:41 -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=PArMLiFe; 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 S231718AbiICTC3 (ORCPT + 99 others); Sat, 3 Sep 2022 15:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbiICTC1 (ORCPT ); Sat, 3 Sep 2022 15:02:27 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 410D6459B7; Sat, 3 Sep 2022 12:02:26 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id w5so6213875wrn.12; Sat, 03 Sep 2022 12:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=Qf7PXikGCovsdv/2K6jAdSbyiEi6rrfmnYyZf0F4aGk=; b=PArMLiFee//94f9H5QNZjUZjFuoq+KvecU3v0RVUxJ3Go0RNuyHUBsggZXC1NuoBXo uvQvbSex10fLw4LMOgDBZQoBmHiCIJli3qPtPq69zkacaxIFT8EldYR5hsuTmOrjcOJK Cg6Qso+q+z3xIpFFqGLEsbqV36YJuTcBO4p9TvQ7SfGxoGCtXkrddaL7jZPgJ97XV+HV MyG5Yhck95bj+0gqLbnaaJCUpSDNDyWaGniBLIImCpeqAiJ1StRaSd3nvByaFHIKlhRW dSTEYvxJ9F26SdLQp/gQC5OjxiAEUfe/9pZB8h2lDfK+mfxMK1k/1/lhq/gBo5nO/a38 /6XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=Qf7PXikGCovsdv/2K6jAdSbyiEi6rrfmnYyZf0F4aGk=; b=eRCW3Y1fehld63zt6v+5/e0zy5z4izaPdivO3sVCQSELAKaU6Q9SyFpDCfOihq5jxi D9QWjHEDnZfTkyKFhfgAxoBo9fRarmqIu+KiwgKLTlM+GLPDOq6zBkAqyM6okGGqYSfY NAeOd/h/6OOHC7qUj1PacGahzYMU2UaH2iJG5l8s9l0VE46H2vTHo/oSNJQG94Xhsxgt CCRpIMvPs4mXeoR+bDbs1jeHRtr3SdJTrK9xz26g6O0MRSAgzYwc4/RFhre25k4EPkZ9 TsNBn8PDuGFhq18XvDC4iYgLHSuMW0YBSYGjTl9GhXQHHctKf+pdPU1Q+efFVKtILAZK ynHw== X-Gm-Message-State: ACgBeo1v2ML/+lib71nMxkNK5+Uy/vdkehc5eoc17Gg3V+kS13o6oLsa W32d22YYt+KU2cdmpB7Bmg== X-Received: by 2002:a5d:59a6:0:b0:226:fdaf:3ece with SMTP id p6-20020a5d59a6000000b00226fdaf3ecemr6121754wrr.444.1662231744731; Sat, 03 Sep 2022 12:02:24 -0700 (PDT) Received: from playground (host-92-29-143-165.as13285.net. [92.29.143.165]) by smtp.gmail.com with ESMTPSA id f15-20020adfb60f000000b00226d1b81b45sm5167315wre.27.2022.09.03.12.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:02:24 -0700 (PDT) Date: Sat, 3 Sep 2022 20:02:15 +0100 From: Jules Irenge To: martin.lau@linux.dev Cc: Elana.Copperman@mobileye.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, sdf@google.com, haoluo@google.com Subject: [PATCH 2/2] bpf: Fix warning of incorrect type in return expression Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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; + } return array_map_elem_ptr(array, index); } -- 2.35.1