From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] tunnel: Return constant string without copying it
Date: Thu, 18 Jan 2018 16:08:18 +0200 [thread overview]
Message-ID: <7df4de70-3f98-36f6-711b-27666121a8aa@gmail.com> (raw)
In-Reply-To: <1515779354-26684-1-git-send-email-serhe.popovych@gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1450 bytes --]
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.
>
> Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
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(-)
>
> 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 @@
>
> 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;
> }
>
> int tnl_get_ioctl(const char *basedev, void *p)
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
prev parent reply other threads:[~2018-01-18 14:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 17:49 [PATCH iproute2] tunnel: Return constant string without copying it Serhey Popovych
2018-01-18 14:08 ` Serhey Popovych [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7df4de70-3f98-36f6-711b-27666121a8aa@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).