LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Joe Perches <joe@perches.com>
To: Louis Taylor <louis@kragniz.eu>,
	dhowells@redhat.com,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH] afs: use correct format characters
Date: Wed, 10 Apr 2019 16:00:56 -0700
Message-ID: <c8e4bd0958e7c58465a2535cb10b2ee994334045.camel@perches.com> (raw)
In-Reply-To: <20190410220301.2332-1-louis@kragniz.eu>

On Wed, 2019-04-10 at 23:03 +0100, Louis Taylor wrote:
> When compiling with -Wformat, clang warns:
> 
> fs/afs/flock.c:632:29: warning: format specifies type 'short' but the argument has type
>       'unsigned char' [-Wformat]
>         _leave(" = %d [%hd]", ret, fl->fl_type);

I really think this clang message should be ignored.

It's really unnecessary as every vararg argument smaller
than int size is already promoted to int.

This particular error is pedantic and has no effect
_at all_ on output or runtime.

If there was some actual mismatch between the signedness
of the argument and the format type, it could make sense.

ie:

	signed char foo = (signed char)-1;
	printk("mismatched %%d emitted as %%u: %u\n", foo);

where the output is a somewhat unexpected 4294967295

> fl_type is declared as an unsigned char unconditionally in
> include/linux/fs.h, so use the correct format characters.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/378
> Signed-off-by: Louis Taylor <louis@kragniz.eu>
> ---
>  fs/afs/flock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/afs/flock.c b/fs/afs/flock.c
> index 6a0174258382..be4c3f6a3178 100644
> --- a/fs/afs/flock.c
> +++ b/fs/afs/flock.c
> @@ -629,7 +629,7 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl)
>  
>  	ret = 0;
>  error:
> -	_leave(" = %d [%hd]", ret, fl->fl_type);
> +	_leave(" = %d [%hhu]", ret, fl->fl_type);
>  	return ret;
>  }
>  


  parent reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-10 22:03 Louis Taylor
2019-04-10 22:27 ` Nick Desaulniers
2019-04-10 22:41 ` [PATCH v2] " Louis Taylor
2019-04-10 22:52   ` Nick Desaulniers
2019-04-12 15:48     ` David Laight
2019-04-10 23:00 ` Joe Perches [this message]
2019-04-11 16:31   ` [PATCH] " Linus Torvalds
2019-04-11 17:41     ` Nick Desaulniers

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=c8e4bd0958e7c58465a2535cb10b2ee994334045.camel@perches.com \
    --to=joe@perches.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=louis@kragniz.eu \
    --cc=torvalds@linux-foundation.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git