Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2178663rwb; Mon, 7 Nov 2022 10:04:18 -0800 (PST) X-Google-Smtp-Source: AMsMyM62UUiIiIAIdPsILWBcCXhlNzrcFjic3zejWM772QFh9lxQw9Ixx+E0uvFg+NCY6TXeVLRq X-Received: by 2002:a05:6402:31f6:b0:461:b9d5:9531 with SMTP id dy22-20020a05640231f600b00461b9d59531mr835753edb.268.1667844257895; Mon, 07 Nov 2022 10:04:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667844257; cv=none; d=google.com; s=arc-20160816; b=bWI97LnoNKaAXYws8xQCh43qY9Vjo7mDg22lJ4DcgE+9b+vbgsOM/GH6yZ5EP0SiZx s0bwQ0FPqtdTha+wt2pJL2BDNdoBpk4/+oJmmtn2Hy1xqOcNDXiNT4bH53mC4Ay0Fp6x mRY4AojCknnIPUIQv4GGPoxj2zqD/e2KCz1b8YxV6edX6wGeNRXxPFhRJQ2pYaJyaYR+ pioRDQ+lyw4cfN+JZ0uwzdbqYALaYjl+kWeGdiy0UoNPRo7C+SeqHgX+uVTXo76MV7lk Y8tU8CI2J2IpBctRwyEBZS89+h4+XX/H1MQxvXkGfRNbjXxMko+EpCDmD8dqST8i/t9x Ox8A== 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:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=SjdPjkOAkY5ArDR/TaGeq5oVuZj65MPrkDu6cufNh20=; b=WebwukusqTCSSEb8n0aK1MB/AbNXOCE7OQr3G9dP3Jsgm8D+jQK8igOMDui6GGD1tI 4uWnyP7AUW7W5jx7+FOuesZKHIYH++N2O8vG8QcaWUHLmo5vHFrrAl2snbR4vcycAER7 ATLa6ely/st4oN+TR19Y8okH7ZuJkdIcI9tj2vi1dr3YnPwZBmrspnGvqXYwQXz9D/Et 6ZDB7aLMp6/3CvEuWjlB3PALl/oGdBwMf7c5pINeGQ4ql8I0zmIMQzZ8GPlfz9GTY6WE ctve07u8pkSmdafjWCitfVq8p66iUBn33k+ZLZ+pHIKB9xu0/0VyG/qTgX45ldSfLoa/ mhaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jJlluNNX; 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 m10-20020a056402510a00b00462ab8923ccsi9277153edd.600.2022.11.07.10.03.55; Mon, 07 Nov 2022 10:04:17 -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=jJlluNNX; 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 S231959AbiKGRvV (ORCPT + 92 others); Mon, 7 Nov 2022 12:51:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbiKGRvR (ORCPT ); Mon, 7 Nov 2022 12:51:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DCD01FCCF; Mon, 7 Nov 2022 09:51:17 -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 AD8A760EC0; Mon, 7 Nov 2022 17:51:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7F91C433C1; Mon, 7 Nov 2022 17:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667843476; bh=4LXa6C3utC5hFi7jr0THCrMlopaxq6gu+qTu+NmrJCM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jJlluNNXko3tP2Eo+4YJypIwk3mj/SodclE1XNIHkXVsuzOUcxg5+jXHiXkQuFc1S s2pJ8mV7X8iTn8DkPX5ru3MXu7I0nA05mM36EwS/y0+qt4EnXca+Wy2Qjy/l+00P39 11NtPIN1/XDFx+yvDV9sOnnVQ8wVfMXHwFRM7aPcP4KNDCZOC240INegZ08MEM6cSS 8M9NWBZRYZkNlxQUUkMCP6sXSbFw/k5WEnR77BiqvkrtKIDmVrvX6XmGQsKCsYr4Qg E0ouXkti4JM0e0emoFLab5Oa/3WnGKChKZ4M+m0EYY7iylGmK3urOdBaNj0SXXVwj4 Zoks3C5oU1Bvw== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Nathan Chancellor , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: John Fastabend , Jiri Olsa , Peter Zijlstra , 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: Re: [PATCH bpf] bpf: Add explicit cast to 'void *' for __BPF_DISPATCHER_UPDATE() In-Reply-To: <20221107170711.42409-1-nathan@kernel.org> References: <20221107170711.42409-1-nathan@kernel.org> Date: Mon, 07 Nov 2022 18:51:12 +0100 Message-ID: <87wn86d567.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 Nathan Chancellor writes: > 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-misma= tch] > __BPF_DISPATCHER_UPDATE(d, new ?: &bpf_dispatcher_nop_func); > ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~ > ./include/linux/bpf.h:1045:54: note: expanded from macro '__BPF_DISPATC= HER_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() (n= ot ftrace)") > Link: https://github.com/ClangBuiltLinux/linux/issues/1755 > Reported-by: kernel test robot > Reported-by: "kernelci.org bot" > Signed-off-by: Nathan Chancellor Acked-by: Bj=C3=B6rn T=C3=B6pel