[lxc-devel] [lxc/master] cleanup: remove unnecessary zeroing
Blub on Github
lxc-bot at linuxcontainers.org
Wed Sep 6 10:02:02 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 428 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170906/ddf46576/attachment.bin>
-------------- next part --------------
From ed14a30f9012a614e5b5ea103f4a3f96058d1ca9 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <w.bumiller at proxmox.com>
Date: Wed, 6 Sep 2017 11:45:03 +0200
Subject: [PATCH] cleanup: remove unnecessary zeroing
The entire netdev is zeroed via memset() already. Unions and
all.
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
src/lxc/confile_legacy.c | 10 ----------
src/lxc/confile_utils.c | 9 ---------
2 files changed, 19 deletions(-)
diff --git a/src/lxc/confile_legacy.c b/src/lxc/confile_legacy.c
index 80dd3851e..93df47376 100644
--- a/src/lxc/confile_legacy.c
+++ b/src/lxc/confile_legacy.c
@@ -170,16 +170,6 @@ int set_config_network_legacy_type(const char *key, const char *value,
lxc_list_init(&netdev->ipv4);
lxc_list_init(&netdev->ipv6);
- netdev->name[0] = '\0';
- netdev->link[0] = '\0';
- memset(&netdev->priv, 0, sizeof(netdev->priv));
- /* I'm not completely sure if the memset takes care to zero the arrays
- * in the union as well. So let's make extra sure and set the first byte
- * to zero so that we don't have any surprises.
- */
- netdev->priv.veth_attr.pair[0] = '\0';
- netdev->priv.veth_attr.veth1[0] = '\0';
-
list = malloc(sizeof(*list));
if (!list) {
SYSERROR("failed to allocate memory");
diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c
index 02924fa93..d43d516db 100644
--- a/src/lxc/confile_utils.c
+++ b/src/lxc/confile_utils.c
@@ -183,15 +183,6 @@ struct lxc_netdev *lxc_network_add(struct lxc_list *networks, int idx, bool tail
memset(netdev, 0, sizeof(*netdev));
lxc_list_init(&netdev->ipv4);
lxc_list_init(&netdev->ipv6);
- netdev->name[0] = '\0';
- netdev->link[0] = '\0';
- memset(&netdev->priv, 0, sizeof(netdev->priv));
- /* I'm not completely sure if the memset takes care to zero the arrays
- * in the union as well. So let's make extra sure and set the first byte
- * to zero so that we don't have any surprises.
- */
- netdev->priv.veth_attr.pair[0] = '\0';
- netdev->priv.veth_attr.veth1[0] = '\0';
/* give network a unique index */
netdev->idx = idx;
More information about the lxc-devel
mailing list