From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: Re: [PATCH iproute2] tunnel: Return constant string without copying it Date: Thu, 18 Jan 2018 16:08:18 +0200 Message-ID: <7df4de70-3f98-36f6-711b-27666121a8aa@gmail.com> References: <1515779354-26684-1-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pBrgJaGbw0YqzD85cz8EJOOpQnZkE2tRI" To: netdev@vger.kernel.org Return-path: Received: from mail-wm0-f68.google.com ([74.125.82.68]:36144 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756185AbeAROI0 (ORCPT ); Thu, 18 Jan 2018 09:08:26 -0500 Received: by mail-wm0-f68.google.com with SMTP id f3so23202601wmc.1 for ; Thu, 18 Jan 2018 06:08:25 -0800 (PST) Received: from tuxracer.as41781.net (139-45-135-95.pool.ukrtel.net. [95.135.45.139]) by smtp.gmail.com with ESMTPSA id p128sm10273730wmb.23.2018.01.18.06.08.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 06:08:23 -0800 (PST) In-Reply-To: <1515779354-26684-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pBrgJaGbw0YqzD85cz8EJOOpQnZkE2tRI Content-Type: multipart/mixed; boundary="uf442L30XAzTlulmtmWQ2W48V6ArCe0z3"; protected-headers="v1" From: Serhey Popovych To: netdev@vger.kernel.org Message-ID: <7df4de70-3f98-36f6-711b-27666121a8aa@gmail.com> Subject: Re: [PATCH iproute2] tunnel: Return constant string without copying it References: <1515779354-26684-1-git-send-email-serhe.popovych@gmail.com> In-Reply-To: <1515779354-26684-1-git-send-email-serhe.popovych@gmail.com> --uf442L30XAzTlulmtmWQ2W48V6ArCe0z3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Serhey Popovych wrote: > We return constant string from tnl_strproto(), no need > to copy it to temporary buffer and then return such > buffer as const: return constant string instead. >=20 > Signed-off-by: Serhey Popovych This change should be ignored: now it is a part of series of patches with cover letter subject: "ip/tunnel: Improve tunnel parameters printing" since v2. > --- > ip/tunnel.c | 25 +++++++------------------ > 1 file changed, 7 insertions(+), 18 deletions(-) >=20 > diff --git a/ip/tunnel.c b/ip/tunnel.c > index f860103..946a36c 100644 > --- a/ip/tunnel.c > +++ b/ip/tunnel.c > @@ -39,33 +39,22 @@ > =20 > const char *tnl_strproto(__u8 proto) > { > - static char buf[16]; > - > switch (proto) { > case IPPROTO_IPIP: > - strcpy(buf, "ip"); > - break; > + return "ip"; > case IPPROTO_GRE: > - strcpy(buf, "gre"); > - break; > + return "gre"; > case IPPROTO_IPV6: > - strcpy(buf, "ipv6"); > - break; > + return "ipv6"; > case IPPROTO_ESP: > - strcpy(buf, "esp"); > - break; > + return "esp"; > case IPPROTO_MPLS: > - strcpy(buf, "mpls"); > - break; > + return "mpls"; > case 0: > - strcpy(buf, "any"); > - break; > + return "any"; > default: > - strcpy(buf, "unknown"); > - break; > + return "unknown"; > } > - > - return buf; > } > =20 > int tnl_get_ioctl(const char *basedev, void *p) >=20 --uf442L30XAzTlulmtmWQ2W48V6ArCe0z3-- --pBrgJaGbw0YqzD85cz8EJOOpQnZkE2tRI Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJaYKpYAAoJEBTawMmQ61bBW6UH/240i49T314t0briiScyVNj0 aLim1/f0lw5KlzdLydkUEz1Y8L9XqN3mgPFySpn33ia4Od9rLJwOXZbw2Lcldapv 1dqHjZE6G1Irpvid0EMGXJ7uYadiz+R8uwoZREzWN3uKuIoa662/UF4XgCBAWZJF ogT1pM3nPnL5Q4oNNOEWRSULDN+hZZssRsPSgG3HTZCNIYeec3R+tLrZlBR2hIj9 2ByM8lzhJ0boqOPObf+shfWB9tJ9LXv+fxSyDkwFpxoTmnpX29AHtvJsE5smYw+W gi3zvu3IRkitfIuQ8n1GXWLtVXQTRppweUFteAx6NZQeKvl2NE0f0gsWDm9AHKE= =MtbX -----END PGP SIGNATURE----- --pBrgJaGbw0YqzD85cz8EJOOpQnZkE2tRI--