mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Joern Engel <joern@logfs.org>,
	Prasad Joshi <prasadjoshi.linux@gmail.com>,
	linux-kernel@vger.kernel.org, logfs@logfs.org
Subject: Re: [PATCH] logfs: fix build warning
Date: Thu, 1 Oct 2015 16:15:45 -0700	[thread overview]
Message-ID: <20151001161545.0c4d20f029af4985b47b86fe@linux-foundation.org> (raw)
In-Reply-To: <1441879864-17487-1-git-send-email-sudipm.mukherjee@gmail.com>

On Thu, 10 Sep 2015 15:41:04 +0530 Sudip Mukherjee <sudipm.mukherjee@gmail.com> wrote:

> While building we were getting build warning of:
> 
> fs/logfs/dev_bdev.c: In function '__bdev_writeseg':
> include/linux/kernel.h:601:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>   (void) (&_min1 == &_min2);  \
> fs/logfs/dev_bdev.c:84:14: note: in  expansion of macro 'min'
>   max_pages = min(nr_pages, BIO_MAX_PAGES);
> 
> fs/logfs/dev_bdev.c: In function 'do_erase':
> include/linux/kernel.h:601:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>  (void) (&_min1 == &_min2);  \
> fs/logfs/dev_bdev.c:174:14: note: in expansion of macro 'min'
>  max_pages = min(nr_pages, BIO_MAX_PAGES);
> 
> Lets use min_t and mention the type.
> 
> ...
>
> --- a/fs/logfs/dev_bdev.c
> +++ b/fs/logfs/dev_bdev.c
> @@ -81,7 +81,7 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
>  	unsigned int max_pages;
>  	int i;
>  
> -	max_pages = min(nr_pages, BIO_MAX_PAGES);
> +	max_pages = min_t(size_t, nr_pages, BIO_MAX_PAGES);
>  
>  	bio = bio_alloc(GFP_NOFS, max_pages);
>  	BUG_ON(!bio);
> @@ -171,7 +171,7 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index,
>  	unsigned int max_pages;
>  	int i;
>  
> -	max_pages = min(nr_pages, BIO_MAX_PAGES);
> +	max_pages = min_t(size_t, nr_pages, BIO_MAX_PAGES);
>  
>  	bio = bio_alloc(GFP_NOFS, max_pages);
>  	BUG_ON(!bio);

I don't think it's logical for either __bdev_writeseg() or do_erase()
to use size_t for `nr_pages'.  For "number of pagecache pages" we'd
normally use pgoff_t or unsigned long.

But they'd generate warnings as well, because BIO_MAX_PAGES is plain
old `int'.  Ho hum.


      parent reply	other threads:[~2015-10-01 23:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10 10:11 Sudip Mukherjee
2015-09-15  8:03 ` Sudip Mukherjee
2015-09-29 12:48   ` Sudip Mukherjee
2015-10-01 23:15 ` Andrew Morton [this message]

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=20151001161545.0c4d20f029af4985b47b86fe@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=joern@logfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=logfs@logfs.org \
    --cc=prasadjoshi.linux@gmail.com \
    --cc=sudipm.mukherjee@gmail.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

Powered by JetHome