[lxc-devel] [lxc/master] Avoid hardcoded string length
Rachid-Koucha on Github
lxc-bot at linuxcontainers.org
Sun Jan 27 00:08:27 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 421 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190126/38753a08/attachment.bin>
-------------- next part --------------
From db1228b35f3ea83f668b58dbec33e12623c5c4b1 Mon Sep 17 00:00:00 2001
From: Rachid Koucha <47061324+Rachid-Koucha at users.noreply.github.com>
Date: Sun, 27 Jan 2019 01:07:38 +0100
Subject: [PATCH] Avoid hardcoded string length
Use strlen() on "state" variable instead of harcoded
value 6.
Signed-off-by: Rachid Koucha <rachid.koucha at gmail.com>
---
src/lxc/freezer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/lxc/freezer.c b/src/lxc/freezer.c
index e9755d1baf..ad9052c7bc 100644
--- a/src/lxc/freezer.c
+++ b/src/lxc/freezer.c
@@ -52,10 +52,11 @@ static int do_freeze_thaw(bool freeze, struct lxc_conf *conf, const char *name,
char v[100];
struct cgroup_ops *cgroup_ops;
const char *state;
- size_t state_len = 6;
+ size_t state_len;
lxc_state_t new_state = freeze ? FROZEN : THAWED;
state = lxc_state2str(new_state);
+ state_len = strlen(state);
cgroup_ops = cgroup_init(conf);
if (!cgroup_ops)
More information about the lxc-devel
mailing list