All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
@ 2014-07-22 19:03 Ian Kumlien
  2014-07-22 19:12 ` Richard Weinberger
  2014-07-22 19:20 ` Randy Dunlap
  0 siblings, 2 replies; 5+ messages in thread
From: Ian Kumlien @ 2014-07-22 19:03 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

This is a resend, try two... 

---
Hi,

While playing around compiling the kernel i noticed the following:
fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
fs/direct-io.c:1022:29: warning: ‘from’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
    ret = submit_page_section(dio, sdio, page,
                             ^
fs/direct-io.c:913:10: note: ‘from’ was declared here
   size_t from, to;
          ^
fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
    u = (to - from) >> blkbits;
            ^
fs/direct-io.c:913:16: note: ‘to’ was declared here
   size_t from, to;
                ^
---


And while the fix is simple, something along the lines of:
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 98040ba..64a8286 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
dio_submit *sdi
 
        while (sdio->block_in_file < sdio->final_block_in_request) {
                struct page *page;
-               size_t from, to;
+               size_t from, to = {0};
                page = dio_get_page(dio, sdio, &from, &to);
                if (IS_ERR(page)) {
                        ret = PTR_ERR(page);
---

I however don't know if it's in the correct C standard, it compiles fine
though... (or if this is more gcc speific)




[-- Attachment #2: direct-io-init.patch --]
[-- Type: text/x-patch, Size: 1528 bytes --]

commit f94d05ce10d869c418d3271bd028fc33bfd25e6f
Author: Ian Kumlien <ian.kumlien@gmail.com>
Date:   Tue Jul 22 20:57:50 2014 +0200

    Initialize the to and from fields
    
    While compliling the 3.16-rc6 kernel I saw this:
    fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
    fs/direct-io.c:1022:29: warning: ‘from’ may be used uninitialized in this function [-Wmaybe-uninitialized]
        ret = submit_page_section(dio, sdio, page,
                                 ^
    fs/direct-io.c:913:10: note: ‘from’ was declared here
       size_t from, to;
              ^
    fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this function [-Wmaybe-uninitialized]
        u = (to - from) >> blkbits;
                ^
    fs/direct-io.c:913:16: note: ‘to’ was declared here
       size_t from, to;
                    ^
    ---
    
    This small changes makes sure that the values are initialized.
    
    Signed-off-by: Ian Kumlien <ian.kumlien@gmail.com>

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 98040ba..64a8286 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -910,7 +910,7 @@ 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, to = {0};
                page = dio_get_page(dio, sdio, &from, &to);
                if (IS_ERR(page)) {
                        ret = PTR_ERR(page);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
  2014-07-22 19:03 [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized Ian Kumlien
@ 2014-07-22 19:12 ` Richard Weinberger
  2014-07-22 19:18   ` Ian Kumlien
  2014-07-22 19:20 ` Randy Dunlap
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2014-07-22 19:12 UTC (permalink / raw)
  To: Ian Kumlien; +Cc: linux-kernel

On Tue, Jul 22, 2014 at 9:03 PM, Ian Kumlien <ian.kumlien@gmail.com> wrote:
> This is a resend, try two...

Please see "[PATCH v3] direct-io: fix uninitialized warning in do_direct_IO()".

> ---
> Hi,
>
> While playing around compiling the kernel i noticed the following:
> fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
> fs/direct-io.c:1022:29: warning: ‘from’ may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>     ret = submit_page_section(dio, sdio, page,
>                              ^
> fs/direct-io.c:913:10: note: ‘from’ was declared here
>    size_t from, to;
>           ^
> fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this
> function [-Wmaybe-uninitialized]
>     u = (to - from) >> blkbits;
>             ^
> fs/direct-io.c:913:16: note: ‘to’ was declared here
>    size_t from, to;
>                 ^
> ---
>
>
> And while the fix is simple, something along the lines of:
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index 98040ba..64a8286 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
> dio_submit *sdi
>
>         while (sdio->block_in_file < sdio->final_block_in_request) {
>                 struct page *page;
> -               size_t from, to;
> +               size_t from, to = {0};
>                 page = dio_get_page(dio, sdio, &from, &to);
>                 if (IS_ERR(page)) {
>                         ret = PTR_ERR(page);
> ---
>
> I however don't know if it's in the correct C standard, it compiles fine
> though... (or if this is more gcc speific)
>
>
>



-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
  2014-07-22 19:12 ` Richard Weinberger
@ 2014-07-22 19:18   ` Ian Kumlien
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Kumlien @ 2014-07-22 19:18 UTC (permalink / raw)
  To: Richard Weinberger; +Cc: linux-kernel

On tis, 2014-07-22 at 21:12 +0200, Richard Weinberger wrote:
> On Tue, Jul 22, 2014 at 9:03 PM, Ian Kumlien <ian.kumlien@gmail.com> wrote:
> > This is a resend, try two...
> 
> Please see "[PATCH v3] direct-io: fix uninitialized warning in do_direct_IO()".

That looks like a better approach, couldn't find it before i started
sending this and my emails are autofiltered if you send via the web
ui.. ;)

> > ---
> > Hi,
> >
> > While playing around compiling the kernel i noticed the following:
> > fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
> > fs/direct-io.c:1022:29: warning: ‘from’ may be used uninitialized in
> > this function [-Wmaybe-uninitialized]
> >     ret = submit_page_section(dio, sdio, page,
> >                              ^
> > fs/direct-io.c:913:10: note: ‘from’ was declared here
> >    size_t from, to;
> >           ^
> > fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this
> > function [-Wmaybe-uninitialized]
> >     u = (to - from) >> blkbits;
> >             ^
> > fs/direct-io.c:913:16: note: ‘to’ was declared here
> >    size_t from, to;
> >                 ^
> > ---
> >
> >
> > And while the fix is simple, something along the lines of:
> > diff --git a/fs/direct-io.c b/fs/direct-io.c
> > index 98040ba..64a8286 100644
> > --- a/fs/direct-io.c
> > +++ b/fs/direct-io.c
> > @@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
> > dio_submit *sdi
> >
> >         while (sdio->block_in_file < sdio->final_block_in_request) {
> >                 struct page *page;
> > -               size_t from, to;
> > +               size_t from, to = {0};
> >                 page = dio_get_page(dio, sdio, &from, &to);
> >                 if (IS_ERR(page)) {
> >                         ret = PTR_ERR(page);
> > ---
> >
> > I however don't know if it's in the correct C standard, it compiles fine
> > though... (or if this is more gcc speific)
> >
> >
> >
> 
> 
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
  2014-07-22 19:03 [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized Ian Kumlien
  2014-07-22 19:12 ` Richard Weinberger
@ 2014-07-22 19:20 ` Randy Dunlap
  2014-07-22 19:23   ` Ian Kumlien
  1 sibling, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2014-07-22 19:20 UTC (permalink / raw)
  To: Ian Kumlien, linux-kernel

On 07/22/2014 12:03 PM, Ian Kumlien wrote:
> This is a resend, try two... 
> 
> ---
> Hi,
> 
> While playing around compiling the kernel i noticed the following:
> fs/direct-io.c: In function ‘do_blockdev_direct_IO’:
> fs/direct-io.c:1022:29: warning: ‘from’ may be used uninitialized in
> this function [-Wmaybe-uninitialized]
>     ret = submit_page_section(dio, sdio, page,
>                              ^
> fs/direct-io.c:913:10: note: ‘from’ was declared here
>    size_t from, to;
>           ^
> fs/direct-io.c:1011:12: warning: ‘to’ may be used uninitialized in this
> function [-Wmaybe-uninitialized]
>     u = (to - from) >> blkbits;
>             ^
> fs/direct-io.c:913:16: note: ‘to’ was declared here
>    size_t from, to;
>                 ^
> ---
> 
> 
> And while the fix is simple, something along the lines of:
> diff --git a/fs/direct-io.c b/fs/direct-io.c
> index 98040ba..64a8286 100644
> --- a/fs/direct-io.c
> +++ b/fs/direct-io.c
> @@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
> dio_submit *sdi
>  
>         while (sdio->block_in_file < sdio->final_block_in_request) {
>                 struct page *page;
> -               size_t from, to;
> +               size_t from, to = {0};
>                 page = dio_get_page(dio, sdio, &from, &to);
>                 if (IS_ERR(page)) {
>                         ret = PTR_ERR(page);
> ---
> 
> I however don't know if it's in the correct C standard, it compiles fine
> though... (or if this is more gcc speific)

so... do you know C or not?

Why the braces around the 0?

Why do you initialize 'to' but not 'from'?


-- 
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
  2014-07-22 19:20 ` Randy Dunlap
@ 2014-07-22 19:23   ` Ian Kumlien
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Kumlien @ 2014-07-22 19:23 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel

On tis, 2014-07-22 at 12:20 -0700, Randy Dunlap wrote:
> On 07/22/2014 12:03 PM, Ian Kumlien wrote:
> > This is a resend, try two... 
> > 
> > And while the fix is simple, something along the lines of:
> > diff --git a/fs/direct-io.c b/fs/direct-io.c
> > index 98040ba..64a8286 100644
> > --- a/fs/direct-io.c
> > +++ b/fs/direct-io.c
> > @@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
> > dio_submit *sdi
> >  
> >         while (sdio->block_in_file < sdio->final_block_in_request) {
> >                 struct page *page;
> > -               size_t from, to;
> > +               size_t from, to = {0};
> >                 page = dio_get_page(dio, sdio, &from, &to);
> >                 if (IS_ERR(page)) {
> >                         ret = PTR_ERR(page);
> > ---
> > 
> > I however don't know if it's in the correct C standard, it compiles fine
> > though... (or if this is more gcc speific)
> 
> so... do you know C or not?

I know C but i don't know if this got added in C99 or C11 or how they
denote it.

> Why the braces around the 0?

Because it's special

> Why do you initialize 'to' but not 'from'?

The magic of {0} is that it will initialize all your values.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-07-22 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-22 19:03 [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized Ian Kumlien
2014-07-22 19:12 ` Richard Weinberger
2014-07-22 19:18   ` Ian Kumlien
2014-07-22 19:20 ` Randy Dunlap
2014-07-22 19:23   ` Ian Kumlien

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.