From patchwork Sat Nov 2 09:58:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lode Willems X-Patchwork-Id: 35575 Received: (qmail 37078 invoked by alias); 2 Nov 2019 09:58:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 37069 invoked by uid 89); 2 Nov 2019 09:58:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cHxe8FwMR4RSxHRv0aVZPX+Q3e+S0KHg0GeQTCUu5gW7p49wcgZvoSMSDX9BF033JBEvh4QrwSMcx9/t0k03e2AQaJGARI07csq6Kg7PzCPVTV9v3x1TvW80h+oPupKLdKX8nxNevWsUCwZGf8m3u7W8+4CU4xk6Ep0BhXPXVJ3JgMRtErOwf1V5UohNnY+u4I8LamIg6ZOvi+Hhz3iGxVGnnxy1GJtwhcWmJKjlHp/aeQ6izt6BuYnpmtrBRxZ/ADyuFjZgC0qiUsoQllZzUedzWQyM80RJ5gcjbaOBujPRM/zrOtkrN/TdIZmyPAgasjYCYtGIanbVLMTPc3vP7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3CQt6wYTbVv8xufdwTnoUaGcsFBKI/UkxhN/S288DOk=; b=HmYjALTSJXa4v6q+chHvBotTosPirGfbSujNGgbGTEThFCRCgNWQKgKRKUni2+ib98i4k78G1ZFD3Icauno3Zzt6OUEiIBWxN8UwMqhSTyIsqk/mOKvK4q9wxPjukmZPl2CwECF1dq22wEKZijQbElG8nwcQiYxeroC1H61Psrg1Hht0OXLIfziff6gir2FqeTJHCxB4nXYZ1GUX/kkta7MOdVXHcpXkQx+lPcGh/jaWHoX8R6Ornm1W0dHVqrw0QQhJOAee8n/b/fvNMihZfl7CEoYRC8wNqZUxthMA0w1TGe3RJxxuvDF/WC/xPnPpJgtknhNyv0e+CKxf0EyZHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ugent.be; dmarc=pass action=none header.from=ugent.be; dkim=pass header.d=ugent.be; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ugentbe.onmicrosoft.com; s=selector2-ugentbe-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3CQt6wYTbVv8xufdwTnoUaGcsFBKI/UkxhN/S288DOk=; b=eTJC694VxzA9KimSebnzDpw6OCFyQ+uCH8q7N1wdH8xKTvUwncZXqs0dWfXKmpTrlgZQy4tvFI2xJSjdMPj5aiBH3pauZ/sDBGZdC+R+TIrF8ZrSAb5MYpsHkbSN35UIre4YX/vWiNYZNVqFl6pQY3abujr/8dAKiGakz586J54= From: Lode Willems To: "libc-alpha@sourceware.org" Subject: [PATCH] getenv: Move call to strlen to the branch it's used in. Date: Sat, 2 Nov 2019 09:58:50 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Lode.Willems@UGent.be; x-ms-oob-tlc-oobclassifiers: OLM:6108; received-spf: None (protection.outlook.com: UGent.be does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: V3syySgg7ZYKKpInl3zgWYYr4vmCQpuZK/wSS6jVgAYxjPUn29ZnDhSrD08kaHYsfhMX9dkHBU4b9CBdbntfRA== The len variable is only used in the else branch. We don't need the call to strlen if the name is 0 or 1 characters long. 2019-10-02 Lode Willems * tdlib/getenv.c: Move the call to strlen into the branch it's used. diff --git a/stdlib/getenv.c b/stdlib/getenv.c index 6be97b2a54..aa5e69d0b0 100644 --- a/stdlib/getenv.c +++ b/stdlib/getenv.c @@ -32,7 +32,6 @@ char * getenv (const char *name) { - size_t len = strlen (name); char **ep; uint16_t name_start; @@ -63,6 +62,7 @@ getenv (const char *name) } else { + size_t len = strlen (name); #if _STRING_ARCH_unaligned name_start = *(const uint16_t *) name; #else