Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Re: savestring()
  2001-03-21 15:59 savestring() J.T. Conklin
@ 2001-03-21 15:59 ` Andrew Cagney
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Cagney @ 2001-03-21 15:59 UTC (permalink / raw)
  To: jtc; +Cc: gdb

"J.T. Conklin" wrote:
> 
> Lint complaints about signed/unsigned conversions in the typical use
> of savestring:

ARI just complains about it :-)

>         x->foo = savestring(bar, strlen(bar));
> 
> Is there any reason why we shouldn't change the type of savestring's
> (likewise msavestring) second argument from int to size_t?
> 
> Also, since the above is the same as:
> 
>         x->foo = xstrdup(bar);
> 
> Is there any reason why we shouldn't change it?  It's a bit odd that
> half the code uses savestring() and the other half uses xstrdup().

From the TODO file.

	--

	Replace savestring() with something from libiberty.

	An xstrldup()? but that would have different semantics.

	--

There may be more on this in the GDB and OpenBSD e-mail archives.  I
sent an e-mail to the OpenBSD group asking if there should be a
strldup() like function - the strl*() functions originated from someone
in OpenBSD land.

Anyway, yes, some instances of savestring should be xstrdup() but others
are not so should probably get ``X'' rated treatment :-)

As for size_t.  I have no idea, does libiberty manage to use size_t in
its headers?  If it does then, why not :-)

	Andrew


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

* savestring()
@ 2001-03-21 15:59 J.T. Conklin
  2001-03-21 15:59 ` savestring() Andrew Cagney
  0 siblings, 1 reply; 2+ messages in thread
From: J.T. Conklin @ 2001-03-21 15:59 UTC (permalink / raw)
  To: gdb

Lint complaints about signed/unsigned conversions in the typical use
of savestring:

        x->foo = savestring(bar, strlen(bar));

Is there any reason why we shouldn't change the type of savestring's
(likewise msavestring) second argument from int to size_t?

Also, since the above is the same as:

        x->foo = xstrdup(bar);

Is there any reason why we shouldn't change it?  It's a bit odd that
half the code uses savestring() and the other half uses xstrdup().

        --jtc

-- 
J.T. Conklin
RedBack Networks


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

end of thread, other threads:[~2001-03-21 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-21 15:59 savestring() J.T. Conklin
2001-03-21 15:59 ` savestring() Andrew Cagney

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