]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tunnel: Return constant string without copying it
authorSerhey Popovych <serhe.popovych@gmail.com>
Thu, 18 Jan 2018 14:04:36 +0000 (16:04 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 19 Jan 2018 00:34:41 +0000 (16:34 -0800)
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>
ip/tunnel.c

index 42ae70e976be6391d09938f79a8d8e181fce0fd2..0414804652664335b9b592a26ae324aaaf8d4e98 100644 (file)
 
 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)