public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54495] New: gcc gives a false warning in kernel/trace/trace_events_filter.c
@ 2012-09-05 18:13 toralf.foerster at gmx dot de
  2012-09-05 22:14 ` [Bug c/54495] " hp at gcc dot gnu.org
  2012-09-06 22:22 ` toralf.foerster at gmx dot de
  0 siblings, 2 replies; 3+ messages in thread
From: toralf.foerster at gmx dot de @ 2012-09-05 18:13 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: toralf.foerster@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)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/54495] gcc gives a false warning in kernel/trace/trace_events_filter.c
  2012-09-05 18:13 [Bug c/54495] New: gcc gives a false warning in kernel/trace/trace_events_filter.c toralf.foerster at gmx dot de
@ 2012-09-05 22:14 ` hp at gcc dot gnu.org
  2012-09-06 22:22 ` toralf.foerster at gmx dot de
  1 sibling, 0 replies; 3+ messages in thread
From: hp at gcc dot gnu.org @ 2012-09-05 22:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54495

Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hp at gcc dot gnu.org

--- Comment #1 from Hans-Peter Nilsson <hp at gcc dot gnu.org> 2012-09-05 22:14:00 UTC ---
But if the call to ftrace_function_filter_re sets re_cnt to 0, then ret indeed
will be used uninitialized AFAICT.  What am I missing?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/54495] gcc gives a false warning in kernel/trace/trace_events_filter.c
  2012-09-05 18:13 [Bug c/54495] New: gcc gives a false warning in kernel/trace/trace_events_filter.c toralf.foerster at gmx dot de
  2012-09-05 22:14 ` [Bug c/54495] " hp at gcc dot gnu.org
@ 2012-09-06 22:22 ` toralf.foerster at gmx dot de
  1 sibling, 0 replies; 3+ messages in thread
From: toralf.foerster at gmx dot de @ 2012-09-06 22:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54495

Toralf Förster <toralf.foerster at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #2 from Toralf Förster <toralf.foerster at gmx dot de> 2012-09-06 22:21:57 UTC ---
yep, commit 92d8d4a8b0f "tracing/filter: Add missing initialization" will fix
it


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-06 22:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-05 18:13 [Bug c/54495] New: gcc gives a false warning in kernel/trace/trace_events_filter.c toralf.foerster at gmx dot de
2012-09-05 22:14 ` [Bug c/54495] " hp at gcc dot gnu.org
2012-09-06 22:22 ` toralf.foerster at gmx dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).