From: Serhey Popovych Date: Thu, 18 Jan 2018 14:04:36 +0000 (+0200) Subject: tunnel: Return constant string without copying it X-Git-Tag: v4.15.0~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9391f120e617118d851ec5c1aff07ce6c681013;p=thirdparty%2Fiproute2.git tunnel: Return constant string without copying it 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 Signed-off-by: Stephen Hemminger --- diff --git a/ip/tunnel.c b/ip/tunnel.c index 42ae70e97..041480465 100644 --- a/ip/tunnel.c +++ b/ip/tunnel.c @@ -40,33 +40,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)