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 <serhe.popovych@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
b8dc6c5b0e
commit
c9391f120e
25
ip/tunnel.c
25
ip/tunnel.c
|
|
@ -40,33 +40,22 @@
|
||||||
|
|
||||||
const char *tnl_strproto(__u8 proto)
|
const char *tnl_strproto(__u8 proto)
|
||||||
{
|
{
|
||||||
static char buf[16];
|
|
||||||
|
|
||||||
switch (proto) {
|
switch (proto) {
|
||||||
case IPPROTO_IPIP:
|
case IPPROTO_IPIP:
|
||||||
strcpy(buf, "ip");
|
return "ip";
|
||||||
break;
|
|
||||||
case IPPROTO_GRE:
|
case IPPROTO_GRE:
|
||||||
strcpy(buf, "gre");
|
return "gre";
|
||||||
break;
|
|
||||||
case IPPROTO_IPV6:
|
case IPPROTO_IPV6:
|
||||||
strcpy(buf, "ipv6");
|
return "ipv6";
|
||||||
break;
|
|
||||||
case IPPROTO_ESP:
|
case IPPROTO_ESP:
|
||||||
strcpy(buf, "esp");
|
return "esp";
|
||||||
break;
|
|
||||||
case IPPROTO_MPLS:
|
case IPPROTO_MPLS:
|
||||||
strcpy(buf, "mpls");
|
return "mpls";
|
||||||
break;
|
|
||||||
case 0:
|
case 0:
|
||||||
strcpy(buf, "any");
|
return "any";
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
strcpy(buf, "unknown");
|
return "unknown";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tnl_get_ioctl(const char *basedev, void *p)
|
int tnl_get_ioctl(const char *basedev, void *p)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue