[PATCH] libiberty: Fix and cleanup choose_temp_base()

Ian Lance Taylor via binutils binutils@sourceware.org
Thu Nov 7 17:43:00 GMT 2019
On Thu, Nov 7, 2019 at 9:09 AM Tim Rühsen <tim.ruehsen@gmx.de> wrote:
>
> reduced code size by using xasprintf().
>
> Please review the check of mktemp(), which was formerly checking against
> 0 (regarding glibc man pages that was wrong). I left that check intact
> (just in case I miss something) and added the check for an empty string,
> as documented in the glibc man pages.
>
> Does it make sense to further replace strlen/malloc/strcpy/strcat
> sequences by [x]asprintf in order to reduce source lines and library
> (binary) size ? (In the means of "is it appreciated")
>
> A side effect is calming down static analyzers that dislike unbounded
> memory accesses and thus warn about strcpy() and strcat().

The new code is simpler but it will run slower.  The existing code has
been there for 20 years, I doubt it's buggy.  I don't see a benefit to
making this change.

Ian



More information about the Binutils mailing list