Bug 20653 - string_to_explicit_location has some weird code
Summary: string_to_explicit_location has some weird code
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: breakpoints (show other bugs)
Version: unknown
: P2 normal
Target Milestone: 7.12.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 20613
  Show dependency treegraph
 
Reported: 2016-09-29 22:02 UTC by Tom Tromey
Modified: 2016-10-24 11:12 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2016-09-29 22:02:04 UTC
This comes from bug 20613 and http://www.viva64.com/en/b/0430/

string_to_explicit_location compares a char* against '\0':

  if (argp == NULL
      || *argp == '\0'

That second comparison should probably be == NULL
Comment 1 Sourceware Commits 2016-10-05 16:32:57 UTC
The master branch has been updated by Tom Tromey <tromey@sourceware.org>:

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

commit e742d386c480efa5229bc8b1887a7718f840a457
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Sep 30 15:43:40 2016 -0600

    PR gdb/20653 - small cleanup in string_to_explicit_location
    
    This bug points out that string_to_explicit_location compares a char*
    against '\0'; whereas comparing against NULL is more normal.
    
    2016-10-05  Tom Tromey  <tom@tromey.com>
    
    	PR breakpoints/20653:
    	* location.c (string_to_explicit_location): Use NULL, not '\0'.
Comment 2 Tom Tromey 2016-10-05 16:35:32 UTC
Fixed.
Comment 3 Sourceware Commits 2016-10-24 11:08:05 UTC
The gdb-7.12-branch branch has been updated by Yao Qi <qiyao@sourceware.org>:

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

commit 909de2c5cc91b815d671f7018da2a925fbd19aaf
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Oct 24 12:06:39 2016 +0100

    PR gdb/20653 - small cleanup in string_to_explicit_location
    
    This bug points out that string_to_explicit_location compares a char*
    against '\0'; whereas comparing against NULL is more normal.
    
    2016-10-24  Tom Tromey  <tom@tromey.com>
    
    	PR breakpoints/20653:
    	* location.c (string_to_explicit_location): Use NULL, not '\0'.
Comment 4 Yao Qi 2016-10-24 11:12:12 UTC
I backport it to 7.12 branch, otherwise, 7.12 failed to compile with recent gcc,

../../binutils-gdb/gdb/location.c: In function ‘event_location*
string_to_explicit_location(const char**, const language_defn*, int)’:
../../binutils-gdb/gdb/location.c:527:19: error: ISO C++ forbids
comparison between pointer and integer [-fpermissive]
       || *argp == '\0'
                   ^~~~
make[2]: *** [location.o] Error 1