http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54495
Bug #: 54495 Summary: gcc gives a false warning in kernel/trace/trace_events_filter.c Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: toralf.foers...@gmx.de The current git tree of linux gave with gcc-4.6.3 : kernel/trace/trace_events_filter.c: In function ‘ftrace_function_set_filter_cb’: kernel/trace/trace_events_filter.c:2074:8: warning: ‘ret’ may be used uninitialized in this function [-Wuninitialized] which refers to this piece of code: 2002 static int __ftrace_function_set_filter(int filter, char *buf, int len, 2003 struct function_filter_data *data) 2004 { 2005 int i, re_cnt, ret; 2006 int *reset; 2007 char **re; 2008 2009 reset = filter ? &data->first_filter : &data->first_notrace; 2010 2011 /* 2012 * The 'ip' field could have multiple filters set, separated 2013 * either by space or comma. We first cut the filter and apply 2014 * all pieces separatelly. 2015 */ 2016 re = ftrace_function_filter_re(buf, len, &re_cnt); 2017 if (!re) 2018 return -EINVAL; 2019 2020 for (i = 0; i < re_cnt; i++) { 2021 ret = ftrace_function_set_regexp(data->ops, filter, *reset, 2022 re[i], strlen(re[i])); 2023 if (ret) 2024 break; 2025 2026 if (*reset) 2027 *reset = 0; 2028 } 2029 2030 argv_free(re); 2031 return ret; 2032 } ... 2061 static int ftrace_function_set_filter_cb(enum move_type move, 2062 struct filter_pred *pred, 2063 int *err, void *data) 2064 { 2065 /* Checking the node is valid for function trace. */ 2066 if ((move != MOVE_DOWN) || 2067 (pred->left != FILTER_PRED_INVALID)) { 2068 *err = ftrace_function_check_pred(pred, 0); 2069 } else { 2070 *err = ftrace_function_check_pred(pred, 1); 2071 if (*err) 2072 return WALK_PRED_ABORT; 2073 2074 *err = __ftrace_function_set_filter(pred->op == OP_EQ, 2075 pred->regex.pattern, 2076 pred->regex.len, 2077 data); 2078 } 2079 2080 return (*err) ? WALK_PRED_ABORT : WALK_PRED_DEFAULT; 2081 } 2082 Both a kernel dev : >Strange, as ret is initialized to 'ret = -EINVAL;' in >__ftrace_function_set_filter(). I'm thinking that gcc got confused here. and a Gentoo Linux User points me to file a bug about this. I'm running an almost stable Gentoo linux : $ gcc -v Using built-in specs. COLLECT_GCC=/usr/i686-pc-linux-gnu/gcc-bin/4.6.3/gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.6.3/lto-wrapper Target: i686-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.6.3/work/gcc-4.6.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.6.3 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.6.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.3/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.6.3/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.6.3/python --enable-checking=release --disable-libgcj --with-arch=i686 --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.3 p1.6, pie-0.5.2' Thread model: posix gcc version 4.6.3 (Gentoo 4.6.3 p1.6, pie-0.5.2)