From: Michal Privoznik <[email protected]> The iptablesPrivateChainCreate() function gets a NULL terminated array of strings (@lines argument), each item representing one line of iptables output. Currently, the variable used to iterate over the array is named 'tmp' which is not very descriptive. Rename it to 'line'.
Signed-off-by: Michal Privoznik <[email protected]> --- src/network/network_iptables.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/network/network_iptables.c b/src/network/network_iptables.c index e8da15426e..be91b273ed 100644 --- a/src/network/network_iptables.c +++ b/src/network/network_iptables.c @@ -85,26 +85,27 @@ iptablesPrivateChainCreate(virFirewall *fw, iptablesGlobalChainData *data = opaque; g_autoptr(GHashTable) chains = virHashNew(NULL); g_autoptr(GHashTable) links = virHashNew(NULL); - const char *const *tmp; + const char *const *line; size_t i; - tmp = lines; - while (tmp && *tmp) { - if (STRPREFIX(*tmp, "-N ")) { /* eg "-N LIBVIRT_INP" */ - if (virHashUpdateEntry(chains, *tmp + 3, (void *)0x1) < 0) + line = lines; + while (line && *line) { + if (STRPREFIX(*line, "-N ")) { /* eg "-N LIBVIRT_INP" */ + if (virHashUpdateEntry(chains, *line + 3, (void *)0x1) < 0) return -1; - } else if (STRPREFIX(*tmp, "-A ")) { /* eg "-A INPUT -j LIBVIRT_INP" */ - char *sep = strchr(*tmp + 3, ' '); + } else if (STRPREFIX(*line, "-A ")) { /* eg "-A INPUT -j LIBVIRT_INP" */ + char *sep = strchr(*line + 3, ' '); + if (sep) { *sep = '\0'; if (STRPREFIX(sep + 1, "-j ")) { if (virHashUpdateEntry(links, sep + 4, - (char *)*tmp + 3) < 0) + (char *)*line + 3) < 0) return -1; } } } - tmp++; + line++; } for (i = 0; i < data->nchains; i++) { -- 2.51.2
