From patchwork Sat Dec 8 09:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Heimpold X-Patchwork-Id: 10719303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87B1714E2 for ; Sat, 8 Dec 2018 09:43:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DBE22CA94 for ; Sat, 8 Dec 2018 09:43:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 399482CAA2; Sat, 8 Dec 2018 09:43:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DDDE2CA94 for ; Sat, 8 Dec 2018 09:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726101AbeLHJnE (ORCPT ); Sat, 8 Dec 2018 04:43:04 -0500 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]:22742 "EHLO mo4-p01-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbeLHJnE (ORCPT ); Sat, 8 Dec 2018 04:43:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1544262183; s=strato-dkim-0002; d=heimpold.de; h=References:Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID: X-RZG-AUTH:From:Subject:Sender; bh=pvzSw4oSuEsIHUPRQp7scDg3j/K0Ptqj7FdI6KKkrqE=; b=tSgaPlUgWs6zV7c1XI+K/SNkDh+HT1B8/QH25CvjGse1ntnWfzcvYEyDydinb0xP8w TTUYOA6PipiQZuptvyox63u60q/30pZnpdOON1oOyIlq5SaQc8rQ/TKoYrsk1Cy7jG4Q hxfnF8vtahsSQJre8gNHEj9X1YckskisIsPl/1s4dwYhBjpi97ZLnHpf1VchqWAavklG GhUjRNWEFTpnpxxag6Gp0u+/LhftvlpSL82pJnTYEgbrDgYpXI1SvdI3x0ZflWexhIJe AWjAL91TPfEXXoMMadYhjZcxYDILDM2pGqoLljnENdELqZwljSL9s7O+hklPe1k6vpr/ 4SHg== X-RZG-AUTH: ":O2kGeEG7b/pS1EW8QnKjhhg/vO4pzqdNytq77N6ZPUGwIpLOmsCM+BB/Jumg6xovrMWyi9ETLmAGXKXZV11jTpjIndx4lVemTznnn+ECaTSi" X-RZG-CLASS-ID: mo00 Received: from tonne.mhei.heimpold.itr by smtp.strato.de (RZmta 44.6 AUTH) with ESMTPSA id w096b8uB89h3ACP (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sat, 8 Dec 2018 10:43:03 +0100 (CET) Received: from kerker.mhei.heimpold.itr (kerker.mhei.heimpold.itr [192.168.8.1]) by tonne.mhei.heimpold.itr (Postfix) with ESMTP id B730B1C5B4B; Sat, 8 Dec 2018 10:43:01 +0100 (CET) From: Michael Heimpold To: chris@printf.net Cc: Michael Heimpold , Wolfram Sang , Wolfram Sang , "linux-mmc@vger.kernel.org" Subject: [PATCH V2 mmc-utils] One further optimization of trimming routine Date: Sat, 8 Dec 2018 10:43:01 +0100 Message-Id: <20181208094301.11199-1-mhei@heimpold.de> X-Mailer: git-send-email 2.17.1 References: <20181208093441.10886-1-mhei@heimpold.de> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The last change to the trimming routine made it more efficient, however, we can even get rid of the memmove() as we leave the function with strdup() anyway. Signed-off-by: Michael Heimpold Reviewed-by: Wolfram Sang --- V2: remove copy&paste left-over from commit message lsmmc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lsmmc.c b/lsmmc.c index 9737b37..86be802 100644 --- a/lsmmc.c +++ b/lsmmc.c @@ -358,10 +358,9 @@ char *read_file(char *name) start++; len--; } - memmove(line, start, len); - line[len] = '\0'; + start[len] = '\0'; - return strdup(line); + return strdup(start); } /* Hexadecimal string parsing functions */