[bpf-next,v2] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym
Message ID | 20221203010847.2191265-1-james.hilliard1@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1159151wrr; Fri, 2 Dec 2022 17:36:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6e1e2sMCekEMrw8zBixvHtwkO0/8ux7JMu/u1BTliJT7HWKFdrNKvD9EASth6MIF00YBkA X-Received: by 2002:a17:906:5a8b:b0:7c0:bf7c:a56b with SMTP id l11-20020a1709065a8b00b007c0bf7ca56bmr5225936ejq.306.1670031368206; Fri, 02 Dec 2022 17:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670031368; cv=none; d=google.com; s=arc-20160816; b=x6AnepPDPxYOurqCyxU/TnlY5NjhJ/N9Zzi/vOdKnABRb9fvn+zdPxXDS6YKtPjpVb 4XDa8CGX/n8dm474VcT2VMMKAQwSpwLIJAhwztJ8P+grNR/w9DckTw3lz72Kg4M7knvR I28avBbsoBwYttZxlkIAQfT5Zcb0WyNkyfEI5qw3p5QDg/UcCc7UucVXOni3lA27BsiP VJREYSFol7JKZtmr9uYgzd1CrUxi5VOaSS+vSb9I66tHl1Xx/+ihLEPMnmcFyR1zqNMC emKVy4RweipeD5A7r692Hqz6GN5cLteDPm784qESh8SfOyzlYmGOoGARAu/RQIfvRIXh dIBg== 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=k515FecbjI08DAyTf4c8VtdjGdTjE71XYVDsJ0hdO0g=; b=JGpiYxF/LtQqdSCSRRCvEfpzDXN3rHsBS7tB+znPQwr9hH2G8up00P3UIm+bNfyFZR U3EApiNJEvoRaBLklBHa09XPK0VzyEi0A8rapIllUIYjT1vOlNjf/pFdcn8SrDxhFObS RDmhMXACw7s1AVdS+lre8tV/5L161pQbIJQ2wbzgD9BViEmS8TgpfABAjrUibk0sfXC8 UbidVbkWJOYzX4A8CFfpRyo3g2HQ3AedzDjwe+fwrLCrcme+71wptnI5nTLpzn4SscVj 0jm3rbN9jIP0KFUdACLKFDeECgehMR94Tx4mEuFtSGddsiAtVuwRZJGzQEsj3ywJ2T1E lvjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ChioXhnb; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d14-20020aa7d5ce000000b0046af5c0f32asi7396688eds.37.2022.12.02.17.35.43; Fri, 02 Dec 2022 17:36:08 -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=@gmail.com header.s=20210112 header.b=ChioXhnb; 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 S235149AbiLCBJT (ORCPT <rfc822;lhua1029@gmail.com> + 99 others); Fri, 2 Dec 2022 20:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235054AbiLCBJR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Dec 2022 20:09:17 -0500 Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9976398EB1; Fri, 2 Dec 2022 17:09:16 -0800 (PST) Received: by mail-io1-xd31.google.com with SMTP id e189so4192514iof.1; Fri, 02 Dec 2022 17:09:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=k515FecbjI08DAyTf4c8VtdjGdTjE71XYVDsJ0hdO0g=; b=ChioXhnbIHyu9u/s1gWmLLEN943wPZCRReMjzOzlQx2IkbVO6AgiHfd9l7iDWHUEP4 wQs4+HsCMHiDvxF5bQDHBhV6FOIQMIkwVVhdKF2UUGGm/wuAKFrq6L0mmpPhhVI4vCZB zr77/IoqV1hGK/zRS9hhZ+28ZJtXiR16EmbSoL0jbWALV+QSRKKux/hKZF6nlTocZOVm x4vsxsPtogzAXlj5/PSftOmPwu4FXLIyMnTF9k2bQ7KRkrCb2AK1MuEgEPLcpjXNIYe/ DJBPfHrU9RYlRf1vQIE3CShOtzx9AI8NTBlEmFpEPqO3m7QmuZA3IZaw5zeHak9SDJUQ EKHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k515FecbjI08DAyTf4c8VtdjGdTjE71XYVDsJ0hdO0g=; b=U5oHO62mETxjlZjmDqlogtoiFVgKDgIYOFtoylafChf5Jw+11Vl38G8NUACsHPLEod slRK7yZa8S0svobRP9u/+E4TSVK5LHu2LHD982wRz5d4g3OriWD6n0x78MKuXVCiw0NF Ctes9AJ92W+J8WkL/8qPh5baqs9+NW6H1HECV0IAmcE8dwDvB5cPdmSEvwYvr3hS2oti MCxYdX1zcgVj6DnkVN59CCZ6paFmYExCGaB/3uv4n/BhRhTrlt+cO1lMMAX6Jx+Nz9FH XT/akffO4TgyC/hgT5MD9DRxqc6ke8sv8MoLsZnHI24P3C9rrShpKfNP1YhgSpQDYKQO cnWQ== X-Gm-Message-State: ANoB5plNzdnJeNewBxOUIoYHr+PW1LXAetFpHkB8m7z86XFtbn2m40e9 78PQEq9Xt/7gEQLMT7jo3saBYBjWMOXOzuFt0jo= X-Received: by 2002:a05:6602:220c:b0:6df:3e12:b640 with SMTP id n12-20020a056602220c00b006df3e12b640mr18142155ion.124.1670029755746; Fri, 02 Dec 2022 17:09:15 -0800 (PST) Received: from james-x399.localdomain (71-33-132-231.hlrn.qwest.net. [71.33.132.231]) by smtp.gmail.com with ESMTPSA id k17-20020a0566022d9100b006a129b10229sm3252210iow.31.2022.12.02.17.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 17:09:15 -0800 (PST) From: James Hilliard <james.hilliard1@gmail.com> To: bpf@vger.kernel.org Cc: James Hilliard <james.hilliard1@gmail.com>, Andrii Nakryiko <andrii@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>, Alan Maguire <alan.maguire@oracle.com>, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym Date: Fri, 2 Dec 2022 18:08:44 -0700 Message-Id: <20221203010847.2191265-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751154812003832785?= X-GMAIL-MSGID: =?utf-8?q?1751154812003832785?= |
Series |
[bpf-next,v2] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym
|
|
Commit Message
James Hilliard
Dec. 3, 2022, 1:08 a.m. UTC
Both tolower and toupper are built in c functions, we should not redefine them as this can result in a build error. Fixes the following errors: progs/bpf_iter_ksym.c:10:20: error: conflicting types for built-in function 'tolower'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] 10 | static inline char tolower(char c) | ^~~~~~~ progs/bpf_iter_ksym.c:5:1: note: 'tolower' is declared in header '<ctype.h>' 4 | #include <bpf/bpf_helpers.h> +++ |+#include <ctype.h> 5 | progs/bpf_iter_ksym.c:17:20: error: conflicting types for built-in function 'toupper'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] 17 | static inline char toupper(char c) | ^~~~~~~ progs/bpf_iter_ksym.c:17:20: note: 'toupper' is declared in header '<ctype.h>' See background on this sort of issue: https://stackoverflow.com/a/20582607 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12213 (C99, 7.1.3p1) "All identifiers with external linkage in any of the following subclauses (including the future library directions) are always reserved for use as identifiers with external linkage." This is documented behavior in GCC: https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-std-2 Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Acked-by: Andrii Nakryiko <andrii@kernel.org> --- Changes v1 -> v2: - add more details --- tools/testing/selftests/bpf/progs/bpf_iter_ksym.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
Hello: This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Fri, 2 Dec 2022 18:08:44 -0700 you wrote: > Both tolower and toupper are built in c functions, we should not > redefine them as this can result in a build error. > > Fixes the following errors: > progs/bpf_iter_ksym.c:10:20: error: conflicting types for built-in function 'tolower'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] > 10 | static inline char tolower(char c) > | ^~~~~~~ > progs/bpf_iter_ksym.c:5:1: note: 'tolower' is declared in header '<ctype.h>' > 4 | #include <bpf/bpf_helpers.h> > +++ |+#include <ctype.h> > 5 | > progs/bpf_iter_ksym.c:17:20: error: conflicting types for built-in function 'toupper'; expected 'int(int)' [-Werror=builtin-declaration-mismatch] > 17 | static inline char toupper(char c) > | ^~~~~~~ > progs/bpf_iter_ksym.c:17:20: note: 'toupper' is declared in header '<ctype.h>' > > [...] Here is the summary with links: - [bpf-next,v2] selftests/bpf: Fix conflicts with built-in functions in bpf_iter_ksym https://git.kernel.org/bpf/bpf-next/c/ab0350c743d5 You are awesome, thank you!
diff --git a/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c b/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c index 285c008cbf9c..9ba14c37bbcc 100644 --- a/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c +++ b/tools/testing/selftests/bpf/progs/bpf_iter_ksym.c @@ -7,14 +7,14 @@ char _license[] SEC("license") = "GPL"; unsigned long last_sym_value = 0; -static inline char tolower(char c) +static inline char to_lower(char c) { if (c >= 'A' && c <= 'Z') c += ('a' - 'A'); return c; } -static inline char toupper(char c) +static inline char to_upper(char c) { if (c >= 'a' && c <= 'z') c -= ('a' - 'A'); @@ -54,7 +54,7 @@ int dump_ksym(struct bpf_iter__ksym *ctx) type = iter->type; if (iter->module_name[0]) { - type = iter->exported ? toupper(type) : tolower(type); + type = iter->exported ? to_upper(type) : to_lower(type); BPF_SEQ_PRINTF(seq, "0x%llx %c %s [ %s ] ", value, type, iter->name, iter->module_name); } else {