Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2176997rwb; Mon, 7 Nov 2022 10:03:14 -0800 (PST) X-Google-Smtp-Source: AMsMyM6/n1bqycfDFaVLeUHf58VoJiHBvs3S0ZR6sg4/IV52bEQAaXlSMUoZRDkkqBATy+l9EsaD X-Received: by 2002:a05:6402:2793:b0:462:39d7:3bbc with SMTP id b19-20020a056402279300b0046239d73bbcmr51540712ede.47.1667844193204; Mon, 07 Nov 2022 10:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667844193; cv=none; d=google.com; s=arc-20160816; b=LBE7BuNBLzBDwAtfqOGX024G85j5O1Q0Ucu99/1383mqr/V9PEHmXvPSJchQ213+Py YUbdZJgor01j3uYWuEhnheSczVsnR95AUEZGPnNgjSckVM7N/eQ0bg8Dt/goupVj1ZaG qN+JalHlkNDekV2T5MRnRAQ3BCUpWku3oDiVRiLW6K9U5E4gNlpa5BgtlhT9glhbztUg hKAJDpjgpF+jllNoxCGxfJumYz7L6NgZxWiZRvOUIIPmgm7OoIYSNhItuSOc98kZJuLn m8REwlnCz8X6tedmsLACzrCcRkVA1wxbVHfjo+Q2GvbmTvI8pFXSkptBG3E8pOroxerU x/gQ== 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=Tv4YwKFem9Tw+BCbpfk9sN62C5KTsVzGonmTid5b9OU=; b=QUjtig9oAN0QhLbqqWUpLotBgZLrGBtSPlJmOffKJhnxdKPnprHdGy3aeH+rDK/wcy NsDggX0g4SaWbOtfZXCZzPcx5Ry3AUBiZOV/CVb1ZP/tLbcL9ZoXZJIdrnISm69WfzIm mo+S6Asf3fdOQq86YNaWde9+Sx0JJ4WeYlIUOT/VBq6DL8M8b9X8TX+hgKvHdDxs29Ue yhmcEAkj+9RCpRAsXHEfzefehMaIlTTe1ENLVh74unJr6BeJr3hpubU4MNlYQKIECa5l QtiDsayBe3NHFAvF39aM8ZsjHP+30oJuyxuqOOy12RzkhpmxJi1wnca4m2irp584kf+x V0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KT+9TnHx; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd18-20020a1709069b9200b007adf558e182si9795683ejc.926.2022.11.07.10.02.50; Mon, 07 Nov 2022 10:03:13 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=KT+9TnHx; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232291AbiKGRHk (ORCPT + 92 others); Mon, 7 Nov 2022 12:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiKGRHh (ORCPT ); Mon, 7 Nov 2022 12:07:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EB461EED1; Mon, 7 Nov 2022 09:07:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 29D8D611B9; Mon, 7 Nov 2022 17:07:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2624C433C1; Mon, 7 Nov 2022 17:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667840855; bh=JhvxwGh6CHd/kos2GLFjcIg4ffzMl1S5afABnifg974=; h=From:To:Cc:Subject:Date:From; b=KT+9TnHx220XRrjPA99dqFGYvbztZkzEPy/Gb6QPRBp3heSpQG85+Xs+KiH3THlxt iJ08hNiBO5837fWdJnWDWUD6bJX3QDaaHGYdy6q4DkPD7kvvMWDrXtpnw3DCmOzCd/ MZ/76QrKnkIYgld5Qgav+c4n3sKg3gsfLjKy8VRWCVYyLtgztWepGUuYS7xJWt4K/n RkdHXCJ6kteVMslBChX2CxdM1VOqxSfgm3qlFLrRWFDfOVH1IF/YA4mig8stoF7i7Z OKsb5t+kpvtiKh4xBogxIAvM9aI/b+fTotVqPmc1hcjLBzLE7fBM4caDdV1BsOtDW2 evw/zwgutMHHw== From: Nathan Chancellor To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: John Fastabend , Jiri Olsa , Peter Zijlstra , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Nick Desaulniers , Tom Rix , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor , kernel test robot , "kernelci.org bot" Subject: [PATCH bpf] bpf: Add explicit cast to 'void *' for __BPF_DISPATCHER_UPDATE() Date: Mon, 7 Nov 2022 10:07:11 -0700 Message-Id: <20221107170711.42409-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 When building with clang: kernel/bpf/dispatcher.c:126:33: error: pointer type mismatch ('void *' and 'unsigned int (*)(const void *, const struct bpf_insn *, bpf_func_t)' (aka 'unsigned int (*)(const void *, const struct bpf_insn *, unsigned int (*)(const void *, const struct bpf_insn *))')) [-Werror,-Wpointer-type-mismatch] __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func); ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/bpf.h:1045:54: note: expanded from macro '__BPF_DISPATCHER_UPDATE' __static_call_update((_d)->sc_key, (_d)->sc_tramp, (_new)) ^~~~ 1 error generated. The warning is pointing out that the type of new ('void *') and &bpf_dispatcher_nop_func are not compatible, which could have side effects coming out of a conditional operator due to promotion rules. Add the explicit cast to 'void *' to make it clear that this is expected, as __BPF_DISPATCHER_UPDATE() expands to a call to __static_call_update(), which expects a 'void *' as its final argument. Fixes: c86df29d11df ("bpf: Convert BPF_DISPATCHER to use static_call() (not ftrace)") Link: https://github.com/ClangBuiltLinux/linux/issues/1755 Reported-by: kernel test robot Reported-by: "kernelci.org bot" Signed-off-by: Nathan Chancellor --- kernel/bpf/dispatcher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c index 7dfb8d0d5202..c19719f48ce0 100644 --- a/kernel/bpf/dispatcher.c +++ b/kernel/bpf/dispatcher.c @@ -123,7 +123,7 @@ static void bpf_dispatcher_update(struct bpf_dispatcher *d, int prev_num_progs) return; } - __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func); + __BPF_DISPATCHER_UPDATE(d, new ?: (void *)&bpf_dispatcher_nop_func); if (new) d->image_off = noff; base-commit: c86df29d11dfba27c0a1f5039cd6fe387fbf4239 -- 2.38.1