Message ID | nsxbo6mxu38.fsf@lambda.thunk.org |
---|---|
State | Accepted, archived |
Headers | show |
Hmm I'm getting this compiler warning: fs/ext4/inode.c: In function ‘ext4_writepages’: fs/ext4/inode.c:2219:6: warning: ‘err’ may be used uninitialized in this function [-Wmaybe-uninitialized] and I think the compiler is right to warn. The 'err' variable is set inside a whilte() and an if() statement, and it is not at all obvious that those codepaths are always taken. Maybe that "map->m_len" is always guaranteed to be nonzero, and the "while()" statement could be a "do { } while()" one. But if so, make it so, don't write code as if it might never be executed, when the return value seems to *depend* on it being executed. Or just initialize the variable correctly. This warning may not be new to this pull, I just happened to notice it now. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue 02-07-13 10:18:32, Linus Torvalds wrote: > Hmm I'm getting this compiler warning: > > fs/ext4/inode.c: In function ‘ext4_writepages’: > fs/ext4/inode.c:2219:6: warning: ‘err’ may be used uninitialized in > this function [-Wmaybe-uninitialized] > > and I think the compiler is right to warn. The 'err' variable is set > inside a whilte() and an if() statement, and it is not at all obvious > that those codepaths are always taken. > > Maybe that "map->m_len" is always guaranteed to be nonzero, and the > "while()" statement could be a "do { } while()" one. But if so, make > it so, don't write code as if it might never be executed, when the > return value seems to *depend* on it being executed. That's caused by my patches (only for certain gcc versions). map->m_len is guaranteed to be > 0 in the first iteration (the function is called from under if (map->m_len > 0)). I though Ted silenced that warning but apparently he did not. The cleanest fix is likely to make a do-while loop from that one. I'll send Ted a patch for that. Honza
On Tue, 2 Jul 2013 20:04:47 +0200 Jan Kara <jack@suse.cz> wrote: > > On Tue 02-07-13 10:18:32, Linus Torvalds wrote: > > Hmm I'm getting this compiler warning: > > > > fs/ext4/inode.c: In function ‘ext4_writepages’: > > fs/ext4/inode.c:2219:6: warning: ‘err’ may be used uninitialized in > > this function [-Wmaybe-uninitialized] > > > > and I think the compiler is right to warn. The 'err' variable is set > > inside a whilte() and an if() statement, and it is not at all obvious > > that those codepaths are always taken. > > > > Maybe that "map->m_len" is always guaranteed to be nonzero, and the > > "while()" statement could be a "do { } while()" one. But if so, make > > it so, don't write code as if it might never be executed, when the > > return value seems to *depend* on it being executed. > That's caused by my patches (only for certain gcc versions). map->m_len > is guaranteed to be > 0 in the first iteration (the function is called from > under if (map->m_len > 0)). I though Ted silenced that warning but > apparently he did not. The cleanest fix is likely to make a do-while loop > from that one. I'll send Ted a patch for that. I did report that warning about 4 weeks ago ... and provided a fix that was way over the top (but pointed out another problem that was fixed).
On Tue, Jul 02, 2013 at 08:04:47PM +0200, Jan Kara wrote: > That's caused by my patches (only for certain gcc versions). map->m_len > is guaranteed to be > 0 in the first iteration (the function is called from > under if (map->m_len > 0)). I though Ted silenced that warning but > apparently he did not. The cleanest fix is likely to make a do-while loop > from that one. I'll send Ted a patch for that. Sorry, I fixed it with a code simplification (I thought the while loop wasn't needed at all), but when you explained why in fact we still needed it, I dropped my commit, and forgot that this also dropped the fix which silenced the warning. I'll grab your patch and included with any other fixes that we might need for this merge window. Linus, are you in a hurry to get this fixed up? It's a false warning on gcc's part, so it's not actually causing any actual problems. If not, I can wait until a week or so to see if there are any other bug fixes that are required and push the fix to you towards the end of the merge window. - Ted -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jul 3, 2013 at 4:35 AM, Theodore Ts'o <tytso@mit.edu> wrote: > > Linus, are you in a hurry to get this fixed up? I No, I just hate seeing warnings in my (simplified) standard build. I'm used to them in the "allmodconfig" builds I do, but prefer to not see them when I just build a localized kernel. But it's not critical. Just as long as I know it will get fixed, I'm happy. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html