[PATCH] kernel: fix a compile error
OGAWA Hirofumi
hirofumi at mail.parknet.co.jp
Wed May 8 05:38:45 PDT 2013
Liu Yuan <namei.unix at gmail.com> writes:
> oops, I pasted the wrong output. The error output is:
>
> make -C /lib/modules/`uname -r`/build/ M=`pwd` CONFIG_TUX3=m modules
> make[1]: Entering directory `/home/yliu/linux-src'
> make[1]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
> CC [M] /home/yliu/tux3/user/kernel/dir.o
> /home/yliu/tux3/user/kernel/dir.c: In function ‘tux_create_entry’:
> /home/yliu/tux3/user/kernel/dir.c:46:9: error: ‘name_len’ may be used uninitialized in this function [-Werror=uninitialized]
> /home/yliu/tux3/user/kernel/dir.c:130:47: note: ‘name_len’ was declared here
>
>>> - unsigned reclen = TUX_REC_LEN(len), rec_len, name_len, offset;
>>> + unsigned reclen = TUX_REC_LEN(len), name_len = 0, rec_len, offset;
>>
>> And this changes about name_len. BTW, what version of gcc is using?
>>
>
> I am using 4.6.3.
OK. Looks like the bug of gcc. (BTW, gcc 4.7.2 doesn't warn about it.)
I will fix this by uninitialized_var().
Thanks.
Fix the following warning.
/home/yliu/tux3/user/kernel/dir.c: In function `tux_create_entry':
/home/yliu/tux3/user/kernel/dir.c:46:9: error: `name_len' may be used uninitialized in this function [-Werror=uninitialized]
/home/yliu/tux3/user/kernel/dir.c:130:47: note: `name_len' was declared here
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
[Use uninitialized_var()]
Signed-off-by: OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>
---
user/kernel/dir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff -puN user/kernel/dir.c~gcc-4.6-name_len-warn-fix user/kernel/dir.c
--- tux3/user/kernel/dir.c~gcc-4.6-name_len-warn-fix 2013-05-08 21:33:06.000000000 +0900
+++ tux3-hirofumi/user/kernel/dir.c 2013-05-08 21:33:45.000000000 +0900
@@ -127,7 +127,8 @@ loff_t tux_create_entry(struct inode *di
struct sb *sb = tux_sb(dir->i_sb);
tux_dirent *entry;
struct buffer_head *buffer, *clone;
- unsigned reclen = TUX_REC_LEN(len), rec_len, name_len, offset;
+ unsigned reclen = TUX_REC_LEN(len), rec_len, offset;
+ unsigned uninitialized_var(name_len);
unsigned blocksize = sb->blocksize;
block_t block, blocks = *size >> sb->blockbits;
void *olddata;
_
--
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>
More information about the Tux3
mailing list