This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] libiberty: Fix and cleanup choose_temp_base()
- From: "Ian Lance Taylor via binutils" <binutils at sourceware dot org>
- To: Tim Rühsen <tim dot ruehsen at gmx dot de>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 7 Nov 2019 09:43:39 -0800
- Subject: Re: [PATCH] libiberty: Fix and cleanup choose_temp_base()
- References: <f8a7d6a5-bb3b-65a9-f134-b071748c8fe0@gmx.de>
- Reply-to: Ian Lance Taylor <iant at google dot com>
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