Bug 149865

Summary: local variable used before set
Product: [Fedora] Fedora Reporter: David Binderman <dcb314>
Component: logjamAssignee: Tom "spot" Callaway <tcallawa>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: dcb314
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-03-14 00:30:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
gcc -Wall warnings cleaned up none

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.