From patchwork Fri Mar 2 07:44:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Pabalinas X-Patchwork-Id: 10253555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A17C6037D for ; Fri, 2 Mar 2018 07:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB778287DE for ; Fri, 2 Mar 2018 07:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DFF2A288A3; Fri, 2 Mar 2018 07:44:32 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FSL_HELO_FAKE, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI 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 0E902287DE for ; Fri, 2 Mar 2018 07:44:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034273AbeCBHoa (ORCPT ); Fri, 2 Mar 2018 02:44:30 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:42951 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034253AbeCBHo3 (ORCPT ); Fri, 2 Mar 2018 02:44:29 -0500 Received: by mail-pf0-f195.google.com with SMTP id a16so3653089pfn.9; Thu, 01 Mar 2018 23:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=BRMCylMtV+vC4k+I9ywxB13zoY0fu4vdhuNh8SvSgSw=; b=O0zHMLzOwKRih28W6KKoWs+g6n9wgo6Q2JG74Ws1JFlMcNIzIPQLWNpFIRi+iOH8cC UAoud8hTP3cBXLEwbNiWJcR3if7CVDzeI4+4LWtIm0RoCa4+aABy70LiaJ+IpYtwYc2N m4L1DcZsjrkp4c0Uf9U81MkN4uQ6vK87uQjH/jeRaQEbldBD+Du+0ae7GfYMhu+XB44W vR3pc38YSYQIs4K/zVsL2fx5iuSkukowIvezEruZawpNdhO/yXVSnF2VD2rfczbogpNL QDJQSxzeDqzbeCVOZ+5tprrR5JPCpeG0Uvk4tRz3jGpFqZLHI3oqYpcKrHdaqjOiYATm tkiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=BRMCylMtV+vC4k+I9ywxB13zoY0fu4vdhuNh8SvSgSw=; b=iLpcMCDIDM+SpeD8bE4l9ZT4uPOtMc03G4bYLU3C4LNTvdtbk6rEtZ2SqQViVeOBCZ ez1oOQvGImf+R3AKxLxmORxNpBXjoUXDh4pJiRWnPfJKrwFyy2nT240j9Cjui/XvUWo5 m2H+VrljYCorVgKsEIqNqpat+JbF+ZCG6MK2pKmg1DLENOXMprGlDHUU6vBxZ6g1SYs2 5oDVIuVzMAXm5ZQQ/uBasdUoTYvHDTRS1nGWaDZrmofSfmb6gIge94c/N8yFWDBKzBvu c6NDCLOLxmo7oJ1w/J2UgP/UHr+5xLIQF2ABIP2Kg8m713ZYolTNsQeJmax0yBX+TbwM 3fEg== X-Gm-Message-State: APf1xPCQgzWaS11FQ9NZ9ECWhsNva/SGkJAeHtQf3ppSeCfnJFktz+t4 m1P7ksp6Lr9pYI+HRmfbG1SXTw== X-Google-Smtp-Source: AG47ELvlyM03Q8cKTD+1qgEinELqEFAiII8RsarTmrEw2jDGf/tyTC8j/hhTFGlK+vLDldLLzfAJaQ== X-Received: by 10.101.72.2 with SMTP id h2mr3891139pgs.240.1519976668503; Thu, 01 Mar 2018 23:44:28 -0800 (PST) Received: from gmail.com ([2605:e000:1117:c19a:2e0:1bff:fe70:ea]) by smtp.gmail.com with ESMTPSA id q22sm12429383pfk.138.2018.03.01.23.44.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Mar 2018 23:44:26 -0800 (PST) Date: Thu, 1 Mar 2018 21:44:24 -1000 From: Joey Pabalinas To: linux-kbuild@vger.kernel.org Cc: Arnaud Lacombe , Masahiro Yamada , Linux Kernel Mailing List , Joey Pabalinas Subject: [PATCH] scripts/kconfig: replace single character strcat() appends Message-ID: <20180302074424.2myh3zhxnbpaohjq@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20171215 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert strcat() calls which only append single characters to the end of res into simpler (and most likely cheaper) single assignment statements. Signed-off-by: Joey Pabalinas 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index cca9663be5ddd91870..67600f48660f2ac142 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -910,8 +910,7 @@ char *sym_expand_string_value(const char *in) * freed, so make sure to always allocate a new string */ reslen = strlen(in) + 1; - res = xmalloc(reslen); - res[0] = '\0'; + res = xcalloc(1, reslen); while ((src = strchr(in, '$'))) { char *p, name[SYMBOL_MAXLENGTH]; @@ -951,7 +950,7 @@ const char *sym_escape_string_value(const char *in) { const char *p; size_t reslen; - char *res; + char *res, *end; size_t l; reslen = strlen(in) + strlen("\"\"") + 1; @@ -968,25 +967,25 @@ const char *sym_escape_string_value(const char *in) p++; } - res = xmalloc(reslen); - res[0] = '\0'; - - strcat(res, "\""); + res = xcalloc(1, reslen); + end = res; + *end++ = '\"'; p = in; for (;;) { l = strcspn(p, "\"\\"); strncat(res, p, l); p += l; + end += l; if (p[0] == '\0') break; - strcat(res, "\\"); - strncat(res, p++, 1); + *end++ = '\\'; + *end++ = *p++; } + *end = '\"'; - strcat(res, "\""); return res; }