From: Nathan Chancellor <nathan@kernel.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Tom Rix <trix@redhat.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] drivers: lkdtm: fix clang -Wformat warning
Date: Thu, 21 Jul 2022 14:34:52 -0700 [thread overview]
Message-ID: <YtnGfFuYhQrbed76@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20220721212012.4060328-1-justinstitt@google.com>
On Thu, Jul 21, 2022 at 02:20:12PM -0700, Justin Stitt wrote:
> When building with Clang we encounter the following warning
> (ARCH=hexagon + CONFIG_FRAME_WARN=0):
> | ../drivers/misc/lkdtm/bugs.c:107:3: error: format specifies type
> | 'unsigned long' but the argument has type 'int' [-Werror,-Wformat]
> | REC_STACK_SIZE, recur_count);
> | ^~~~~~~~~~~~~~
>
> Cast REC_STACK_SIZE to `unsigned long` to match format specifier `%lu`.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Suggested-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Justin Stitt <justinstitt@google.com>
I think this is the right fix, as REC_STACK_SIZE will be 'unsigned long'
when CONFIG_FRAME_WARN is greater than 0 due to the _AC(..., UL) macro,
so the other one should match too. THREAD_SIZE might not be an unsigned
long; I see at least hexagon, microblaze, m68k, powerpc, and sh that
define it as either a regular integer literal with no suffix or
'1 << THREAD_SHIFT', which will both be of type 'int'.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> Reported by Nathan here:
> https://lore.kernel.org/all/YtmrCJjQrSbv8Aj1@dev-arch.thelio-3990X/
>
> drivers/misc/lkdtm/bugs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c
> index 009239ad1d8a..6381255aaecc 100644
> --- a/drivers/misc/lkdtm/bugs.c
> +++ b/drivers/misc/lkdtm/bugs.c
> @@ -29,7 +29,7 @@ struct lkdtm_list {
> #if defined(CONFIG_FRAME_WARN) && (CONFIG_FRAME_WARN > 0)
> #define REC_STACK_SIZE (_AC(CONFIG_FRAME_WARN, UL) / 2)
> #else
> -#define REC_STACK_SIZE (THREAD_SIZE / 8)
> +#define REC_STACK_SIZE ((unsigned long)(THREAD_SIZE / 8))
> #endif
> #define REC_NUM_DEFAULT ((THREAD_SIZE / REC_STACK_SIZE) * 2)
>
> --
> 2.37.1.359.gd136c6c3e2-goog
>
next prev parent reply other threads:[~2022-07-21 21:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 21:20 Justin Stitt
2022-07-21 21:34 ` Nathan Chancellor [this message]
2022-07-21 21:42 ` Nick Desaulniers
2022-07-21 21:57 ` [PATCH v2] " Justin Stitt
2022-07-21 22:05 ` Nathan Chancellor
2022-07-23 13:42 ` Kees Cook
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=YtnGfFuYhQrbed76@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=justinstitt@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=ndesaulniers@google.com \
--cc=trix@redhat.com \
/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
all inboxes | Powered by JetHome®