All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <openosd@gmail.com>
To: Christoph Hellwig <hch@infradead.org>,
	pramod.gurav.etc@gmail.com, viro@zeniv.linux.org.uk,
	Jason Cooper <jason@lakedaemon.net>,
	Markus Mayer <markus.mayer@linaro.org>,
	Paul Bolle <pebolle@tiscali.nl>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/direct-io.c: Fix compilation warning for uninitialized variables
Date: Wed, 16 Jul 2014 20:08:41 +0300	[thread overview]
Message-ID: <53C6B199.2070606@gmail.com> (raw)
In-Reply-To: <20140713115022.GA6054@infradead.org>

On 07/13/2014 02:50 PM, Christoph Hellwig wrote:
> pramod.gurav.etc@gmail.com wrote ...
>> diff --git a/fs/direct-io.c b/fs/direct-io.c
>> index 98040ba388ac..c0a9854d2bc7 100644
>> --- a/fs/direct-io.c
>> +++ b/fs/direct-io.c
>> @@ -910,7 +910,8 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>>  
>>  	while (sdio->block_in_file < sdio->final_block_in_request) {
>>  		struct page *page;
>> -		size_t from, to;
>> +		size_t from = 0;
>> +		size_t to = 0;
>>  		page = dio_get_page(dio, sdio, &from, &to);
>>  		if (IS_ERR(page)) {
>>  			ret = PTR_ERR(page);
> Looks good to me,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Al, can you pick this up?  It's the only warnings in many of my usual
> kernel builds at the moment.
> 
<>

Paul Bolle <pebolle@tiscali.nl> wrote ...
<>
> @@ -911,11 +907,15 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>  	while (sdio->block_in_file < sdio->final_block_in_request) {
>  		struct page *page;
>  		size_t from, to;
> -		page = dio_get_page(dio, sdio, &from, &to);
> +
> +		page = dio_get_page(dio, sdio);
>  		if (IS_ERR(page)) {
>  			ret = PTR_ERR(page);
>  			goto out;
>  		}
> +		from = sdio->head ? 0 : sdio->from;
> +		to = (sdio->head == sdio->tail - 1) ? sdio->to : PAGE_SIZE;
> +		sdio->head++;
>  
>  		while (from < to) {
>  			unsigned this_chunk_bytes;	/* # of bytes mapped */
<>

This is the wrong fix. GCC is wrong here. As shown by Paul Bolle if
you move the from / to set from dio_get_page() to here the warning goes away.

The minimal fix must use uninitialized_var() in this case. See patch below

But I think the proper fix Is the one Paul Bolle <pebolle@tiscali.nl> sent (above)


----
From: Boaz Harrosh <boaz@plexistor.com>
Date: Wed, 16 Jul 2014 20:02:29 +0300
Subject: [PATCH] do_direct_IO: Fix compiler warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fixes
../fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
../fs/direct-io.c:1011:12: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    u = (to - from) >> blkbits;
            ^
../fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    u = (to - from) >> blkbits;

I use: gcc version 4.8.3 20140624 (Red Hat 4.8.3-1)

GCC is wrong here so we should use the uninitialized_var() macro
and not silence it with = 0;

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 fs/direct-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 98040ba..156e6f0 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -910,7 +910,8 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
 
 	while (sdio->block_in_file < sdio->final_block_in_request) {
 		struct page *page;
-		size_t from, to;
+		size_t uninitialized_var(from), uninitialized_var(to);
+
 		page = dio_get_page(dio, sdio, &from, &to);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Boaz Harrosh <openosd@gmail.com>
To: Christoph Hellwig <hch@infradead.org>,
	pramod.gurav.etc@gmail.com, viro@zeniv.linux.org.uk,
	Jason Cooper <jason@lakedaemon.net>,
	Markus Mayer <markus.mayer@linaro.org>,
	Paul Bolle <pebolle@tiscali.nl>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/direct-io.c: Fix compilation warning for uninitialized variables
Date: Wed, 16 Jul 2014 20:08:41 +0300	[thread overview]
Message-ID: <53C6B199.2070606@gmail.com> (raw)
In-Reply-To: <20140713115022.GA6054@infradead.org>

On 07/13/2014 02:50 PM, Christoph Hellwig wrote:
> pramod.gurav.etc@gmail.com wrote ...
>> diff --git a/fs/direct-io.c b/fs/direct-io.c
>> index 98040ba388ac..c0a9854d2bc7 100644
>> --- a/fs/direct-io.c
>> +++ b/fs/direct-io.c
>> @@ -910,7 +910,8 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>>  
>>  	while (sdio->block_in_file < sdio->final_block_in_request) {
>>  		struct page *page;
>> -		size_t from, to;
>> +		size_t from = 0;
>> +		size_t to = 0;
>>  		page = dio_get_page(dio, sdio, &from, &to);
>>  		if (IS_ERR(page)) {
>>  			ret = PTR_ERR(page);
> Looks good to me,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> Al, can you pick this up?  It's the only warnings in many of my usual
> kernel builds at the moment.
> 
<>

Paul Bolle <pebolle@tiscali.nl> wrote ...
<>
> @@ -911,11 +907,15 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
>  	while (sdio->block_in_file < sdio->final_block_in_request) {
>  		struct page *page;
>  		size_t from, to;
> -		page = dio_get_page(dio, sdio, &from, &to);
> +
> +		page = dio_get_page(dio, sdio);
>  		if (IS_ERR(page)) {
>  			ret = PTR_ERR(page);
>  			goto out;
>  		}
> +		from = sdio->head ? 0 : sdio->from;
> +		to = (sdio->head == sdio->tail - 1) ? sdio->to : PAGE_SIZE;
> +		sdio->head++;
>  
>  		while (from < to) {
>  			unsigned this_chunk_bytes;	/* # of bytes mapped */
<>

This is the wrong fix. GCC is wrong here. As shown by Paul Bolle if
you move the from / to set from dio_get_page() to here the warning goes away.

The minimal fix must use uninitialized_var() in this case. See patch below

But I think the proper fix Is the one Paul Bolle <pebolle@tiscali.nl> sent (above)


----
From: Boaz Harrosh <boaz@plexistor.com>
Date: Wed, 16 Jul 2014 20:02:29 +0300
Subject: [PATCH] do_direct_IO: Fix compiler warning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This fixes
../fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
../fs/direct-io.c:1011:12: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    u = (to - from) >> blkbits;
            ^
../fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    u = (to - from) >> blkbits;

I use: gcc version 4.8.3 20140624 (Red Hat 4.8.3-1)

GCC is wrong here so we should use the uninitialized_var() macro
and not silence it with = 0;

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 fs/direct-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 98040ba..156e6f0 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -910,7 +910,8 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
 
 	while (sdio->block_in_file < sdio->final_block_in_request) {
 		struct page *page;
-		size_t from, to;
+		size_t uninitialized_var(from), uninitialized_var(to);
+
 		page = dio_get_page(dio, sdio, &from, &to);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
-- 
1.9.3


  parent reply	other threads:[~2014-07-16 17:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04  5:43 [PATCH] fs/direct-io.c: Fix compilation warning for uninitialized variables pramod.gurav.etc
2014-07-04  5:43 ` pramod.gurav.etc
2014-07-13 11:50 ` Christoph Hellwig
2014-07-14  7:04   ` pramod gurav
2014-07-16 17:08   ` Boaz Harrosh [this message]
2014-07-16 17:08     ` Boaz Harrosh
2014-07-16 17:56     ` Jason Cooper
2014-07-16 17:58     ` Christoph Hellwig
2014-07-16 18:42       ` Paul Bolle
2014-07-17  9:37         ` direct-io: squelch maybe-uninitialized warning in do_direct_IO() Boaz Harrosh
2014-07-17  9:40           ` Boaz Harrosh
2014-07-17  9:54             ` Paul Bolle
2014-07-17  9:48           ` Paul Bolle
2014-07-17 11:00             ` Boaz Harrosh
2014-07-17 11:00               ` Boaz Harrosh
2014-07-17 11:11           ` [PATCH v2] " Boaz Harrosh
2014-07-17 11:11             ` Boaz Harrosh
2014-07-17 11:29             ` Paul Bolle
2014-07-20  9:09               ` [PATCH v3] direct-io: fix uninitialized " Boaz Harrosh
2014-07-20  9:09                 ` Boaz Harrosh
2014-07-21 11:36                 ` Christoph Hellwig
2014-07-22  9:03                   ` Boaz Harrosh

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=53C6B199.2070606@gmail.com \
    --to=openosd@gmail.com \
    --cc=hch@infradead.org \
    --cc=jason@lakedaemon.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.mayer@linaro.org \
    --cc=pebolle@tiscali.nl \
    --cc=pramod.gurav.etc@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.