From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88B80C76196 for ; Tue, 11 Apr 2023 21:05:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjDKVFm (ORCPT ); Tue, 11 Apr 2023 17:05:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbjDKVFl (ORCPT ); Tue, 11 Apr 2023 17:05:41 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BED2B30C4; Tue, 11 Apr 2023 14:05:40 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6E8EB21A0A; Tue, 11 Apr 2023 21:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1681247139; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7zctrdNUNIuPRnnH6YSgGlzlhIgOGJy0WVsWJrjpI1c=; b=Bq83Bse4pGHW5O27Qu0LfHWgyaDyZL6tUnd/WlQ/ncGfZVCH24uuqzDPAnJD2lACRNTdOX vBSvpuRp1SZgpl076h2+oZZThD17wMNMnm0oCWSRPWbTFmPe4XHEIYLEoj68Lj2oaOzCO9 l9PcJs6jSbfv28/kDtOkRq6SAl+5niA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1681247139; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7zctrdNUNIuPRnnH6YSgGlzlhIgOGJy0WVsWJrjpI1c=; b=/E60z5FOroRILhpYUhoJQHgQUsxcwyfqqpYb0VVFuwMnFfsRh2Ay/+iiBByGj3Tmj+bx7u /Vzgg3p5FE+tTLBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2EFEF13519; Tue, 11 Apr 2023 21:05:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DOxpCqPLNWRxHgAAMHmgww (envelope-from ); Tue, 11 Apr 2023 21:05:39 +0000 Date: Tue, 11 Apr 2023 23:05:37 +0200 From: Petr Vorel To: Kevin Brodsky Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Masahiro Yamada , Sam Ravnborg , Petr Vorel , Andrew Morton , Ruben Ayrapetyan Subject: Re: [PATCH RESEND] uapi/linux/const.h: Prefer ISO-friendly __typeof__ Message-ID: <20230411210537.GA1800481@pevik> Reply-To: Petr Vorel References: <20230411092747.3759032-1-kevin.brodsky@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230411092747.3759032-1-kevin.brodsky@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 Tested-by: Petr Vorel 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 > Tested-by: Ruben Ayrapetyan > Signed-off-by: Kevin Brodsky > --- > 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))