Received: by 10.223.185.116 with SMTP id b49csp8357754wrg; Thu, 1 Mar 2018 23:46:02 -0800 (PST) X-Google-Smtp-Source: AG47ELshhy3SDLTqPDZcn83ki/sU1YgK//wK271nJN6ERbOZgeZpflMmYj4fz6n5eBQVljkwsL5V X-Received: by 2002:a17:902:7e4a:: with SMTP id a10-v6mr4490345pln.207.1519976762003; Thu, 01 Mar 2018 23:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519976761; cv=none; d=google.com; s=arc-20160816; b=jzom0WpQ+y1Sg/ee1fal9l3VoxuxEINeFYhk5SWe8uoZFFa9HMAbn5vVdA4Ls31h3W cP2tdzzyVtQMudyehR46xMUGy9H99l6G+TOKh27Cu2i4QBnwjiAxDbSuD1+ooXu0V9my z/v0XjEUCxyiorBH6EwIwJyeLQ+MdicFPs95ZYDIGoa3TiJ9Ub6JiH17TEde4m1VZk0U P7ZhuqXsdnf3lS7nX9brbetF1O4E5pQnQctqWdQ5qn9lcIsNx2CZPGu0NzvCyZHHFuWQ TkR1c4UWTCf2iOSWs3GEfAsnl4569CSLAPOdfFae95flL1vZA6qw6HdNCOlHDYzt8SZf Kh1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=BRMCylMtV+vC4k+I9ywxB13zoY0fu4vdhuNh8SvSgSw=; b=MwQZrIQX9D5X/eP7CxxqDvCpPTWLQ25LZl0peqt6zwpKky/3cCHZYHsAGa7jcZScbp dcMqyWtjYuMPpropNoR70QCg99LTvd+vINIENQAk2JFNKhT/iaHI8KzA7ehTIrgvd8fb 62CqyRnPVcO88nrCdNSTclsbIefACxCONKxY5W/Dbzp9o8C9xm1mYs7slkFPn1jEUNpe 1AgVu6auiXyV9kRK2N8tqfkulU38QcpNaEmjUgzeI6LuDMvi5fGnkVMkVfcRbjKU6TQ7 vsCpfUK6Yy+m0GDGTChdYjc+y8WBlzRYGNmDLA2KU/GP5/sVu+hs3Fsa6MjzCgIN1QIH kSjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O0zHMLzO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a187si3633326pge.689.2018.03.01.23.45.47; Thu, 01 Mar 2018 23:46:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O0zHMLzO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034283AbeCBHob (ORCPT + 99 others); Fri, 2 Mar 2018 02:44:31 -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-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-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bd6lqbgbkpl4nnon" Content-Disposition: inline User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --bd6lqbgbkpl4nnon Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 =3D strlen(in) + 1; - res =3D xmalloc(reslen); - res[0] =3D '\0'; + res =3D xcalloc(1, reslen); =20 while ((src =3D 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; =20 reslen =3D strlen(in) + strlen("\"\"") + 1; @@ -968,25 +967,25 @@ const char *sym_escape_string_value(const char *in) p++; } =20 - res =3D xmalloc(reslen); - res[0] =3D '\0'; - - strcat(res, "\""); + res =3D xcalloc(1, reslen); + end =3D res; + *end++ =3D '\"'; =20 p =3D in; for (;;) { l =3D strcspn(p, "\"\\"); strncat(res, p, l); p +=3D l; + end +=3D l; =20 if (p[0] =3D=3D '\0') break; =20 - strcat(res, "\\"); - strncat(res, p++, 1); + *end++ =3D '\\'; + *end++ =3D *p++; } + *end =3D '\"'; =20 - strcat(res, "\""); return res; } =20 --=20 2.16.2 Sorry about the double send, clipboards are very fickle beasts :( --bd6lqbgbkpl4nnon Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKlZXrihdNOcUPZTNruvLfWhyVBkFAlqZANgACgkQruvLfWhy VBkMpxAA4WWKNhpeoQc9XUH4aQwN6pfAS13WHvB0cT5angyIeG30zEK5FlV8nog+ jif+QVJGKWRqIQzWqI78UQkIJoJz4p8TN/Zfitn0QnXM2koy6GOE8P9Z+itWzxzL iutNN9/J0QwlBbzF6k0dMU2lot7Z1Bmpm6LcL0ioGIW6oVNQYz46WrhjGNxfl5Hu flQOsj9CFhgRL0iUizf7N0OaCN8H9dj4lqYfTNMiTr3DYXZuAixAazZ3rTbmUIJV AxiOEim5LTCGIsxYw1iRrnnhrhu0Dz6bDBC8+LrTyxMoYIxZXsAy+rfv6pxgKweP O6ZV898YbPvrk1u+WL/gK/MINHAttccssI/p3yr/GToCr41msdXT1HRlnISd2wtM zutMGF20/tUMB3/N0i52jLyFxDo4bdq4h3ycroc87ttgd51rwHRfBd8KJUMqPS6/ aNlyFc3w724HunPdNYU5b9QJcL4wiEypmTxdJNEwBq2oIt+FTIuSoWbRUUF3l+9p O+GSsfmVD0pTwkwwquXyvTWgQaYj437xDCeJooXY706+19Pr8s4RHziyqTNiyP7P BVFzEqG7vo+EP0WBt/vIyCN/Ky7WRMqu1C93S3a0tLWPU3BAuYVrVDlY/M/RGzCh G/flH/1D0wowxQ4qsTkZTxNWZ+5OLWNok0zgUiziwKUfdHTtNE8= =z1dk -----END PGP SIGNATURE----- --bd6lqbgbkpl4nnon--