Bug 149865 - local variable used before set
Summary: local variable used before set
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: logjam
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-02-28 14:48 UTC by David Binderman
Modified: 2007-11-30 22:11 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-03-14 00:30:58 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
gcc -Wall warnings cleaned up (1.91 KB, patch)
2005-03-14 00:19 UTC, Tom "spot" Callaway
no flags Details | Diff

Description David Binderman 2005-02-28 14:48:25 UTC
Description of problem:

I just tried to compile package logjam-4.4.1-3 from 
Redhat Fedora Extras development tree.

The compiler said

tools.c(217): remark #592: variable "encoding" is used before its
value is set

The source code is

        const gchar *encoding;
        GError *err = NULL;

        command = gtk_entry_get_text(GTK_ENTRY(entry));
        if (!jam_doc_insert_command_output(doc,
                command, encoding, &err, win) && (err)) {

Suggest initialise local variable "encoding" before first use.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Tom "spot" Callaway 2005-02-28 15:19:57 UTC
Gcc spit this out? I don't recognize that as a gcc error, it sounds
like ICC being too sensitive.

If gcc wasn't used to compile this, you need to take that bug back to
the upstream maintainer, which, in the case of logjam, is Evan Martin
(http://logjam.danga.com).

If gcc was used, feel free to reopen this bug.



Comment 2 David Binderman 2005-02-28 16:07:04 UTC
>Gcc spit this out? 

Nope, Intel 8.1, but gcc will complain about the line
by adding "-O2 -Wall" to gcc command line.

>it sounds like ICC being too sensitive.

Good comedy. 

In fact, reading definately un-init memory is one of the oldest
mistakes that C programmers.

>If gcc was used, feel free to reopen this bug.

See above - gcc can complain about this bug.


Comment 3 Tom "spot" Callaway 2005-03-14 00:19:00 UTC
Created attachment 111958 [details]
gcc -Wall warnings cleaned up

OK, taking the time to look at this one.

Recompiled logjam 4.4.1 with -O2 -Wall.

The following errors were thrown by the compiler:
cmdline.c: In function `command_dispatch':
cmdline.c:667: warning: 'acc' might be used uninitialized in this function
checkfriends-gtk.c: In function `cf_float_destroy':
checkfriends-gtk.c:258: warning: unused variable `cfm'
checkfriends-gtk.c: In function `cf_dock_destroy':
checkfriends-gtk.c:280: warning: unused variable `cfm'
checkfriends-gtk.c: At top level:
checkfriends-gtk.c:295: warning: 'cf_dock_setup' defined but not used
menu.c: In function `menu_make_bar':
menu.c:443: warning: unused variable `i'
tools.c: In function `tools_insert_command_output':
tools.c:212: warning: 'encoding' might be used uninitialized in this function

All of these errors are fixed in the attached patch.

Comment 4 Tom "spot" Callaway 2005-03-14 00:30:32 UTC
Changes committed to devel branch of CVS.


Note You need to log in before you can comment on or make changes to this bug.