From patchwork Fri Dec 18 06:34:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 1418108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=l6WMZ+Iz; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cxzck6ZNLz9sWK for ; Fri, 18 Dec 2020 17:35:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0CAA3938C03; Fri, 18 Dec 2020 06:34:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0CAA3938C03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1608273298; bh=Go/vVhXQjmEv7XP9bWqBUocrqI90cFplS2r4L7y5h3I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=l6WMZ+Izl8kKrrRHEx6qTi21H8+z2rAAkh+3Lc2BqLKewyrn9t/PGO9qjbh6yOOal z4u902Pw440Mm6Y2GD3yVgx9NboBcqWKxcbx6POkGywdXDXOgtUH+OUgoWYYn30Jg1 slsh8mdQym6hzu6EYnJvq6vqKxPshNpYyhjvnFy4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from crocodile.elm.relay.mailchannels.net (crocodile.elm.relay.mailchannels.net [23.83.212.45]) by sourceware.org (Postfix) with ESMTPS id 2B9BB3938399 for ; Fri, 18 Dec 2020 06:34:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2B9BB3938399 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 01B584023E3; Fri, 18 Dec 2020 06:34:55 +0000 (UTC) Received: from pdx1-sub0-mail-a52.g.dreamhost.com (100-96-5-83.trex.outbound.svc.cluster.local [100.96.5.83]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 5660C401A61; Fri, 18 Dec 2020 06:34:53 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a52.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.11); Fri, 18 Dec 2020 06:34:54 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Minister-Soft: 096964835c777552_1608273293986_3490507189 X-MC-Loop-Signature: 1608273293986:1141701076 X-MC-Ingress-Time: 1608273293986 Received: from pdx1-sub0-mail-a52.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a52.g.dreamhost.com (Postfix) with ESMTP id 1D3BF7F13D; Thu, 17 Dec 2020 22:34:53 -0800 (PST) Received: from rhbox.redhat.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a52.g.dreamhost.com (Postfix) with ESMTPSA id 652F07ED7F; Thu, 17 Dec 2020 22:34:48 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a52 To: libc-alpha@sourceware.org Subject: [COMMITTED] getenv: Move call to strlen to the branch it's used in. Date: Fri, 18 Dec 2020 12:04:35 +0530 Message-Id: <20201218063435.869976-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Cc: fweimer@redhat.com, Lode Willems Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" I have committed this to master after verifying that it does indeed changed the generated assembly to a small extent and it is a useful cleanup. Siddhesh 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 57a8b6f013..b38b332ff8 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