Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Aug 5, 2016, 05:36 UTC
- Message-ID
- <5ce2ec67-aa7d-0079-54fe-d73a70a46825@kdbg.org>
- In-Reply-To
- <xmqqk2fwyx8h.fsf@gitster.mtv.corp.google.com>
Am 05.08.2016 um 00:39 schrieb Junio C Hamano:
Show 11 quoted lines
> @@ -955,12 +955,10 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, size_t *sizes, void **
> */
> char *strdup(const char *s1)
> {
> - char *s2 = 0;
> - if (s1) {
> - size_t len = strlen(s1) + 1;
> - s2 = malloc(len);
> + size_t len = strlen(s1) + 1;
> + s2 = malloc(len);
> + if (s1)It does not make sense to check s1 for NULL when it was passed to strlen() earlier; strlen() does not accept NULL, either...
Show 5 quoted lines
> memcpy(s2, s1, len); > - } > return s2; > } > #endif
-- Hannes