diff options
Diffstat (limited to 'drivers/net/failsafe/failsafe_args.c')
-rw-r--r-- | drivers/net/failsafe/failsafe_args.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/net/failsafe/failsafe_args.c b/drivers/net/failsafe/failsafe_args.c index 1f22416f..cfc83e36 100644 --- a/drivers/net/failsafe/failsafe_args.c +++ b/drivers/net/failsafe/failsafe_args.c @@ -115,8 +115,7 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) /* store possible newline as well */ char output[DEVARGS_MAXLEN + 1]; size_t len; - int old_err; - int ret, pclose_ret; + int ret; RTE_ASSERT(cmdline != NULL || sdev->cmdline != NULL); if (sdev->cmdline == NULL) { @@ -135,12 +134,10 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) sdev->cmdline[i] = ' '; } DEBUG("'%s'", sdev->cmdline); - old_err = errno; fp = popen(sdev->cmdline, "r"); if (fp == NULL) { - ret = errno; + ret = -errno; ERROR("popen: %s", strerror(errno)); - errno = old_err; return ret; } /* We only read one line */ @@ -155,18 +152,11 @@ fs_execute_cmd(struct sub_device *sdev, char *cmdline) goto ret_pclose; } ret = fs_parse_device(sdev, output); - if (ret) { + if (ret) ERROR("Parsing device '%s' failed", output); - goto ret_pclose; - } ret_pclose: - pclose_ret = pclose(fp); - if (pclose_ret) { - pclose_ret = errno; + if (pclose(fp) == -1) ERROR("pclose: %s", strerror(errno)); - errno = old_err; - return pclose_ret; - } return ret; } @@ -286,10 +276,17 @@ fs_remove_sub_devices_definition(char params[DEVARGS_MAXLEN]) ERROR("Invalid parameter"); return -EINVAL; } - if (params[b] == ',' || params[b] == '\0') - i += snprintf(&buffer[i], b - a + 1, "%s", ¶ms[a]); - if (params[b] == '(') { + if (params[b] == ',' || params[b] == '\0') { + size_t len = b - a; + + if (i > 0) + len += 1; + snprintf(&buffer[i], len + 1, "%s%s", + i ? "," : "", ¶ms[a]); + i += len; + } else if (params[b] == '(') { size_t start = b; + b += closing_paren(¶ms[b]); if (b == start) return -EINVAL; @@ -393,6 +390,7 @@ failsafe_args_parse(struct rte_eth_dev *dev, const char *params) &dev->data->mac_addrs[0]); if (ret < 0) goto free_kvlist; + mac_from_arg = 1; } } |