Re: [RFC] 3.16-rc6 -- fs/direct-io.c:1011 from and to uninitialized.

From: Richard Weinberger
Date: Tue Jul 22 2014 - 15:12:46 EST


On Tue, Jul 22, 2014 at 9:03 PM, Ian Kumlien <ian.kumlien@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/