From: Petr Vorel <pvorel@suse.cz>
To: Kevin Brodsky <kevin.brodsky@arm.com>
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>,
Sam Ravnborg <sam@ravnborg.org>,
Petr Vorel <petr.vorel@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ruben Ayrapetyan <ruben.ayrapetyan@arm.com>
Subject: Re: [PATCH RESEND] uapi/linux/const.h: Prefer ISO-friendly __typeof__
Date: Tue, 11 Apr 2023 23:05:37 +0200 [thread overview]
Message-ID: <20230411210537.GA1800481@pevik> (raw)
In-Reply-To: <20230411092747.3759032-1-kevin.brodsky@arm.com>
Hi Kevin,
> typeof is (still) a GNU extension, which means that it cannot be
> used when building ISO C (e.g. -std=c99). It should therefore be
> avoided in uapi headers in favour of the ISO-friendly __typeof__.
IMHO UAPI are built with -std=c90 -Wall -Werror=implicit-function-declaration
(see usr/include/Makefile).
But one or the other, you're right both require __typeof__.
"If you are writing a header file that must work when included in ISO C
programs, write __typeof__ instead of typeof."
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Typeof.html
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Tested-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
> Unfortunately this issue could not be detected by
> CONFIG_UAPI_HEADER_TEST=y as the __ALIGN_KERNEL() macro is not
> expanded in any uapi header.
> Reported-by: Ruben Ayrapetyan <ruben.ayrapetyan@arm.com>
> Tested-by: Ruben Ayrapetyan <ruben.ayrapetyan@arm.com>
> Signed-off-by: Kevin Brodsky <kevin.brodsky@arm.com>
> ---
> include/uapi/linux/const.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
> index af2a44c08683..a429381e7ca5 100644
> --- a/include/uapi/linux/const.h
> +++ b/include/uapi/linux/const.h
> @@ -28,7 +28,7 @@
> #define _BITUL(x) (_UL(1) << (x))
> #define _BITULL(x) (_ULL(1) << (x))
> -#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
> +#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
> #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
next prev parent reply other threads:[~2023-04-11 21:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 9:27 [PATCH RESEND] uapi/linux/const.h: Prefer ISO-friendly __typeof__ Kevin Brodsky
2023-04-11 21:05 ` Petr Vorel [this message]
2023-04-11 21:39 ` Petr Vorel
2023-04-12 0:24 ` Andrew Morton
2023-04-12 13:01 ` Kevin Brodsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230411210537.GA1800481@pevik \
--to=pvorel@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=kevin.brodsky@arm.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=petr.vorel@gmail.com \
--cc=ruben.ayrapetyan@arm.com \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox