Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] strlen(null) in dwarf2read
@ 2007-08-29 21:49 msnyder
  2007-09-04 14:25 ` Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: msnyder @ 2007-08-29 21:49 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 37 bytes --]

Not all strlens can deal with null.


[-- Attachment #2: 68.txt --]
[-- Type: text/plain, Size: 2583 bytes --]

2007-08-29  Michael Snyder  <msnyder@access-company.com>

	* dwarf2read.c (determine_prefix): Do not send NULL to strlen.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.230
diff -p -r1.230 dwarf2read.c
*** dwarf2read.c	23 Aug 2007 18:08:28 -0000	1.230
--- dwarf2read.c	29 Aug 2007 21:45:22 -0000
*************** determine_prefix (struct die_info *die, 
*** 7677,7696 ****
  }
  
  /* Return a newly-allocated string formed by concatenating PREFIX and
!    SUFFIX with appropriate separator.  If PREFIX or SUFFIX is NULL or empty, then
!    simply copy the SUFFIX or PREFIX, respectively.  If OBS is non-null,
!    perform an obconcat, otherwise allocate storage for the result.  The CU argument
!    is used to determine the language and hence, the appropriate separator.  */
  
  #define MAX_SEP_LEN 2  /* sizeof ("::")  */
  
  static char *
! typename_concat (struct obstack *obs, const char *prefix, const char *suffix, 
! 		 struct dwarf2_cu *cu)
  {
    char *sep;
  
!   if (suffix == NULL || suffix[0] == '\0' || prefix == NULL || prefix[0] == '\0')
      sep = "";
    else if (cu->language == language_java)
      sep = ".";
--- 7677,7703 ----
  }
  
  /* Return a newly-allocated string formed by concatenating PREFIX and
!    SUFFIX with appropriate separator.  If PREFIX or SUFFIX is NULL or
!    empty, then simply copy the SUFFIX or PREFIX, respectively.  If OBS
!    is non-null, perform an obconcat, otherwise allocate storage for
!    the result.  The CU argument is used to determine the language and
!    hence, the appropriate separator.  */
  
  #define MAX_SEP_LEN 2  /* sizeof ("::")  */
  
  static char *
! typename_concat (struct obstack *obs, const char *prefix, 
! 		 const char *suffix, struct dwarf2_cu *cu)
  {
    char *sep;
  
!   /* Do not ask strlen to deal with a null pointer!  */
!   if (suffix == NULL)
!     suffix = "";
!   if (prefix == NULL)
!     prefix = "";
! 
!   if (suffix[0] == '\0' || prefix[0] == '\0')
      sep = "";
    else if (cu->language == language_java)
      sep = ".";
*************** typename_concat (struct obstack *obs, co
*** 7699,7705 ****
  
    if (obs == NULL)
      {
!       char *retval = xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
        retval[0] = '\0';
        
        if (prefix)
--- 7706,7713 ----
  
    if (obs == NULL)
      {
!       char *retval = 
! 	xmalloc (strlen (prefix) + MAX_SEP_LEN + strlen (suffix) + 1);
        retval[0] = '\0';
        
        if (prefix)

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

* Re: [patch] strlen(null) in dwarf2read
  2007-08-29 21:49 [patch] strlen(null) in dwarf2read msnyder
@ 2007-09-04 14:25 ` Joel Brobecker
  2007-09-05  0:10   ` msnyder
  0 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2007-09-04 14:25 UTC (permalink / raw)
  To: msnyder; +Cc: gdb-patches

> 2007-08-29  Michael Snyder  <msnyder@access-company.com>
> 
> 	* dwarf2read.c (determine_prefix): Do not send NULL to strlen.

Proofread, and no comment :)

(actually, yes: I'm much better at reading unified diff, not sure
about others - I ended up applying your patch locally and regenerating
the diff)

-- 
Joel


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

* Re: [patch] strlen(null) in dwarf2read
  2007-09-04 14:25 ` Joel Brobecker
@ 2007-09-05  0:10   ` msnyder
  2007-09-05  0:53     ` Daniel Jacobowitz
  2007-09-05  7:26     ` Mark Kettenis
  0 siblings, 2 replies; 6+ messages in thread
From: msnyder @ 2007-09-05  0:10 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: msnyder, gdb-patches

>> 2007-08-29  Michael Snyder  <msnyder@access-company.com>
>>
>> 	* dwarf2read.c (determine_prefix): Do not send NULL to strlen.
>
> Proofread, and no comment :)
>
> (actually, yes: I'm much better at reading unified diff, not sure
> about others - I ended up applying your patch locally and regenerating
> the diff)

All right.  The reason I like -p is because it gives me the
function name for context.  I can see that -u is more concise.

Wonder if there is a way to get the best of both?





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

* Re: [patch] strlen(null) in dwarf2read
  2007-09-05  0:10   ` msnyder
@ 2007-09-05  0:53     ` Daniel Jacobowitz
  2007-09-05  1:11       ` msnyder
  2007-09-05  7:26     ` Mark Kettenis
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2007-09-05  0:53 UTC (permalink / raw)
  To: msnyder; +Cc: Joel Brobecker, gdb-patches

On Tue, Sep 04, 2007 at 05:10:36PM -0700, Michael Snyder wrote:
> All right.  The reason I like -p is because it gives me the
> function name for context.  I can see that -u is more concise.
> 
> Wonder if there is a way to get the best of both?

Indeed there is.  I present to you.... -up!  -p alone implies context,
but -up works.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [patch] strlen(null) in dwarf2read
  2007-09-05  0:53     ` Daniel Jacobowitz
@ 2007-09-05  1:11       ` msnyder
  0 siblings, 0 replies; 6+ messages in thread
From: msnyder @ 2007-09-05  1:11 UTC (permalink / raw)
  To: msnyder, Joel Brobecker, gdb-patches

> On Tue, Sep 04, 2007 at 05:10:36PM -0700, Michael Snyder wrote:
>> All right.  The reason I like -p is because it gives me the
>> function name for context.  I can see that -u is more concise.
>>
>> Wonder if there is a way to get the best of both?
>
> Indeed there is.  I present to you.... -up!  -p alone implies context,
> but -up works.

I love it!  OK, I'm a convert.




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

* Re: [patch] strlen(null) in dwarf2read
  2007-09-05  0:10   ` msnyder
  2007-09-05  0:53     ` Daniel Jacobowitz
@ 2007-09-05  7:26     ` Mark Kettenis
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Kettenis @ 2007-09-05  7:26 UTC (permalink / raw)
  To: msnyder; +Cc: brobecker, msnyder, gdb-patches

> Date: Tue, 4 Sep 2007 17:10:36 -0700 (PDT)
> From: msnyder@sonic.net
> 
> >> 2007-08-29  Michael Snyder  <msnyder@access-company.com>
> >>
> >> 	* dwarf2read.c (determine_prefix): Do not send NULL to strlen.
> >
> > Proofread, and no comment :)
> >
> > (actually, yes: I'm much better at reading unified diff, not sure
> > about others - I ended up applying your patch locally and regenerating
> > the diff)
> 
> All right.  The reason I like -p is because it gives me the
> function name for context.  I can see that -u is more concise.
> 
> Wonder if there is a way to get the best of both?

-up works like a charm ;)


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

end of thread, other threads:[~2007-09-05  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-29 21:49 [patch] strlen(null) in dwarf2read msnyder
2007-09-04 14:25 ` Joel Brobecker
2007-09-05  0:10   ` msnyder
2007-09-05  0:53     ` Daniel Jacobowitz
2007-09-05  1:11       ` msnyder
2007-09-05  7:26     ` Mark Kettenis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox