3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
RFC 1/1 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.
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:
fs/direct-io.c +0 -0
@@ -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)
commit f94d05ce10d869c418d3271bd028fc33bfd25e6f
Author: Ian Kumlien <[email protected]> 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.
fs/direct-io.c +1 -1
@@ -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);
Quoted 1 line · Ian Kumlien
This is a resend, try two...
Please see "[PATCH v3] direct-io: fix uninitialized warning in do_direct_IO()".
Quoted 44 lines
---
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 heresize_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:
fs/direct-io.c +0
-0@@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
dio_submit*sdiwhile (sdio->block_in_file < sdio->final_block_in_request) { struct page *page;fs/direct-io.c +1
-2-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)
Signature · 2 lines
Thanks, //richard
Quoted 4 lines · Richard Weinberger
Quoted 1 line · Ian Kumlien
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.. ;)
Quoted 47 lines
Quoted 44 lines
---
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 heresize_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:
fs/direct-io.c +0
-0@@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
dio_submit*sdiwhile (sdio->block_in_file < sdio->final_block_in_request) { struct page *page;fs/direct-io.c +1
-2-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)
Quoted 41 lines · Ian Kumlien
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 heresize_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:
fs/direct-io.c +0
-0@@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
dio_submit*sdiwhile (sdio->block_in_file < sdio->final_block_in_request) { struct page *page;fs/direct-io.c +1
-2-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); ---
Quoted 2 lines
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'?
Signature · 1 line
~Randy
Quoted 20 lines · Randy Dunlap
Quoted 19 lines · Ian Kumlien
This is a resend, try two...
And while the fix is simple, something along the lines of:
fs/direct-io.c +0
-0@@ -910,7 +910,7 @@ static int do_direct_IO(struct dio *dio, struct
dio_submit*sdiwhile (sdio->block_in_file < sdio->final_block_in_request) { struct page *page;fs/direct-io.c +1
-2-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); ---
Quoted 4 lines
Quoted 2 lines
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.
Quoted 1 line
Why the braces around the 0?
Because it's special
Quoted 1 line
Why do you initialize 'to' but not 'from'?
The magic of {0} is that it will initialize all your values.