Bug 21364 - Dead code due to an unreachable condition in osdata.c
Summary: Dead code due to an unreachable condition in osdata.c
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-09 16:42 UTC by Freddy Mallet
Modified: 2017-04-10 16:47 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Screenshot of the SonarQube UI spotting this bug. (243.05 KB, image/png)
2017-04-09 16:42 UTC, Freddy Mallet
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Freddy Mallet 2017-04-09 16:42:13 UTC
Created attachment 9979 [details]
Screenshot of the SonarQube UI spotting this bug.

The following few lines [1] added recently in osdata.c source file leads to have the overall condition of an 'if' statement being always false (see the attached screenshot).

This bug has been detected by SonarQube.

[1]- https://github.com/bminor/binutils-gdb/blame/6ca30fa5613cfa935834f27114d6db4f3854a13e/gdb/osdata.c#L300
Comment 1 Nick Clifton 2017-04-10 11:53:59 UTC
Hi Freddy,

  This is a bug in the GDB sources, not the binutils sources.  Please could you refile the bug with a Product and Component of GDB ?  That way it will be seen by the right people...

Cheers
  Nick
Comment 2 Andreas Schwab 2017-04-10 13:32:58 UTC
Moving to gdb.
Comment 3 Sourceware Commits 2017-04-10 16:46:38 UTC
The master branch has been updated by Sergio Durigan Junior <sergiodj@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a5bef50fdbfadbc6b8911b458580ee91cbfcdafd

commit a5bef50fdbfadbc6b8911b458580ee91cbfcdafd
Author: Sergio Durigan Junior <sergiodj@redhat.com>
Date:   Mon Apr 10 12:43:44 2017 -0400

    Fix PR gdb/21364: Dead code due to an unreachable condition in osdata.c
    
    Pedro's recent commits enabling -Wwrite-strings has changed a bit the
    logic of info_osdata.  Now, 'type' is always non-NULL, so we have to
    check if it's an empty string instead of NULL.  One of the checks was
    fixed, but there is another that was left behind.  This commit fixes
    it.
    
    gdb/ChangeLog:
    2017-04-10  Sergio Durigan Junior  <sergiodj@redhat.com>
    
    	PR gdb/21364
    	* osdata.c (info_osdata): Check if 'type' is an empty string
    	instead of NULL.
Comment 4 Sergio Durigan Junior 2017-04-10 16:47:24 UTC
Fixed, thanks.