From patchwork Mon Oct 26 21:03:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 1388106 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=zPARCHdA; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CKnPY1jTHz9sT6 for ; Tue, 27 Oct 2020 08:03:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729569AbgJZVDm (ORCPT ); Mon, 26 Oct 2020 17:03:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:57738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729508AbgJZVDm (ORCPT ); Mon, 26 Oct 2020 17:03:42 -0400 Received: from localhost.localdomain (unknown [192.30.34.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18EE72076D; Mon, 26 Oct 2020 21:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603746221; bh=OZnv8+PjDr0EFxf38kgdpGPhhv077FnV6tC8I5FI3EI=; h=From:To:Cc:Subject:Date:From; b=zPARCHdA9ue578l2WNv3HF5JQC66D+2G1czAaiUWHuljt43wVHu9Ag64RWvezDW5S 96QhQmAsHFlZfscCcGj7/BKu6q28YWewp7nWSScDPjVBtaxMkKtwKLm6knI2CKKcAt nMNlKljZpXWPhqWmn7Ho1uzZPEqQmeLNMj50ILXk= From: Arnd Bergmann To: Alexei Starovoitov , Daniel Borkmann Cc: Arnd Bergmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , David Miller , Thomas Gleixner , Jakub Sitnicki , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , =?utf-8?q?Toke_H?= =?utf-8?q?=C3=B8iland-J=C3=B8rgensen?= , Jiri Olsa , Pankaj Bharadiya , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bpf: suppress -Wcast-function-type warning Date: Mon, 26 Oct 2020 22:03:20 +0100 Message-Id: <20201026210332.3885166-1-arnd@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann Building with -Wextra shows lots of warnings in the bpf code such as kernel/bpf/verifier.c: In function ‘jit_subprogs’: include/linux/filter.h:345:4: warning: cast between incompatible function types from ‘unsigned int (*)(const void *, const struct bpf_insn *)’ to ‘u64 (*)(u64, u64, u64, u64, u64)’ {aka ‘long long unsigned int (*)(long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int, long long unsigned int)’} [-Wcast-function-type] 345 | ((u64 (*)(u64, u64, u64, u64, u64))(x)) | ^ kernel/bpf/verifier.c:10706:16: note: in expansion of macro ‘BPF_CAST_CALL’ 10706 | insn->imm = BPF_CAST_CALL(func[subprog]->bpf_func) - | ^~~~~~~~~~~~~ This appears to be intentional, so change the cast in a way that suppresses the warning. Signed-off-by: Arnd Bergmann Acked-by: Andrii Nakryiko --- include/linux/filter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 1b62397bd124..20ba04583eaa 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -342,7 +342,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) /* Function call */ #define BPF_CAST_CALL(x) \ - ((u64 (*)(u64, u64, u64, u64, u64))(x)) + ((u64 (*)(u64, u64, u64, u64, u64))(uintptr_t)(x)) #define BPF_EMIT_CALL(FUNC) \ ((struct bpf_insn) { \