]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
c/r: use sizeof instead of magic numbers
authorTycho Andersen <tycho.andersen@canonical.com>
Thu, 16 Oct 2014 13:14:00 +0000 (13:14 +0000)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 17 Oct 2014 13:22:02 +0000 (15:22 +0200)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxccontainer.c

index d1f41c7f2141581f568d506527b28178d7f82356..d3b604695dbd4bf628177decafdb3ac0feaf8e98 100644 (file)
@@ -3639,16 +3639,16 @@ static void exec_criu(struct criu_opts *opts)
                        struct lxc_netdev *n = it->elem;
 
                        if (n->name) {
-                               if (strlen(n->name) >= 128)
+                               if (strlen(n->name) >= sizeof(eth))
                                        goto err;
-                               strncpy(eth, n->name, 128);
+                               strncpy(eth, n->name, sizeof(eth));
                        } else
                                sprintf(eth, "eth%d", netnr);
 
                        veth = n->priv.veth_attr.pair;
 
-                       ret = snprintf(buf, 257, "%s=%s", eth, veth);
-                       if (ret < 0 || ret >= 257)
+                       ret = snprintf(buf, sizeof(buf), "%s=%s", eth, veth);
+                       if (ret < 0 || ret >= sizeof(buf))
                                goto err;
 
                        /* final NULL and --veth-pair eth0=vethASDF */