Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [commit] Fix "show prompt"
@ 2005-05-28 18:40 Daniel Jacobowitz
  2005-05-29  7:41 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-05-28 18:40 UTC (permalink / raw)
  To: gdb-patches

One of the gcc4 warnings patches incorrectly converted the var_string
case; it's a char **, not a char *.  Committed as obvious, fixes two
testcases on i686-pc-linux-gnu.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-05-28  Daniel Jacobowitz  <dan@codesourcery.com>

	* cli/cli-setshow.c (do_setshow_command): Partially revert previous
	change.  Cast to "char **" for var_string.

Index: cli/cli-setshow.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-setshow.c,v
retrieving revision 1.25
diff -u -p -r1.25 cli-setshow.c
--- cli/cli-setshow.c	26 May 2005 20:49:03 -0000	1.25
+++ cli/cli-setshow.c	28 May 2005 18:16:21 -0000
@@ -301,8 +301,8 @@ do_setshow_command (char *arg, int from_
       switch (c->var_type)
 	{
 	case var_string:
-	  if (((char *)c->var)[0] != '\0')
-	    fputstr_filtered ((char *)c->var, '"', stb->stream);
+	  if (*(char **) c->var)
+	    fputstr_filtered (*(char **) c->var, '"', stb->stream);
 	  break;
 	case var_string_noescape:
 	case var_optional_filename:


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

* Re: [commit] Fix "show prompt"
  2005-05-28 18:40 [commit] Fix "show prompt" Daniel Jacobowitz
@ 2005-05-29  7:41 ` Eli Zaretskii
  2005-05-29 15:07   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2005-05-29  7:41 UTC (permalink / raw)
  To: gdb-patches

> Date: Sat, 28 May 2005 14:28:26 -0400
> From: Daniel Jacobowitz <drow@false.org>
> 
> One of the gcc4 warnings patches incorrectly converted the var_string
> case; it's a char **, not a char *.

True.

>        switch (c->var_type)
>  	{
>  	case var_string:
> -	  if (((char *)c->var)[0] != '\0')
> -	    fputstr_filtered ((char *)c->var, '"', stb->stream);
> +	  if (*(char **) c->var)

Doesn't this work without a cast, like this:

	if (*c->var != NULL)

?  I think we should avoid unneeded type-casting.


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

* Re: [commit] Fix "show prompt"
  2005-05-29  7:41 ` Eli Zaretskii
@ 2005-05-29 15:07   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-05-29 15:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Sun, May 29, 2005 at 09:13:06AM +0300, Eli Zaretskii wrote:
> >        switch (c->var_type)
> >  	{
> >  	case var_string:
> > -	  if (((char *)c->var)[0] != '\0')
> > -	    fputstr_filtered ((char *)c->var, '"', stb->stream);
> > +	  if (*(char **) c->var)
> 
> Doesn't this work without a cast, like this:
> 
> 	if (*c->var != NULL)
> 
> ?  I think we should avoid unneeded type-casting.

No:
    /* Pointer to variable affected by "set" and "show".  Doesn't matter
       if type is not_set.  */
    void *var;

Can't dereference that.  Really, this ought to be replaced with a
union, so that we could eliminate all the casts.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


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

end of thread, other threads:[~2005-05-29 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-28 18:40 [commit] Fix "show prompt" Daniel Jacobowitz
2005-05-29  7:41 ` Eli Zaretskii
2005-05-29 15:07   ` Daniel Jacobowitz

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