1
0
mirror of https://passt.top/passt synced 2024-10-01 03:25:48 +00:00

make conf_netns_opt() exit immediately after logging error

...and return void to simplify the caller.

Signed-off-by: Laine Stump <laine@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Laine Stump 2023-02-15 03:24:35 -05:00 committed by Stefano Brivio
parent ead4a98111
commit 60bd93e91f

16
conf.c
View File

@ -464,10 +464,8 @@ out:
* conf_netns_opt() - Parse --netns option * conf_netns_opt() - Parse --netns option
* @netns: buffer of size PATH_MAX, updated with netns path * @netns: buffer of size PATH_MAX, updated with netns path
* @arg: --netns argument * @arg: --netns argument
*
* Return: 0 on success, negative error code otherwise
*/ */
static int conf_netns_opt(char *netns, const char *arg) static void conf_netns_opt(char *netns, const char *arg)
{ {
int ret; int ret;
@ -479,12 +477,8 @@ static int conf_netns_opt(char *netns, const char *arg)
ret = snprintf(netns, PATH_MAX, "%s", arg); ret = snprintf(netns, PATH_MAX, "%s", arg);
} }
if (ret <= 0 || ret > PATH_MAX) { if (ret <= 0 || ret > PATH_MAX)
err("Network namespace name/path %s too long"); die("Network namespace name/path %s too long");
return -E2BIG;
}
return 0;
} }
/** /**
@ -1157,9 +1151,7 @@ void conf(struct ctx *c, int argc, char **argv)
if (c->mode != MODE_PASTA) if (c->mode != MODE_PASTA)
die("--netns is for pasta mode only"); die("--netns is for pasta mode only");
ret = conf_netns_opt(netns, optarg); conf_netns_opt(netns, optarg);
if (ret < 0)
usage(argv[0]);
break; break;
case 4: case 4:
if (c->mode != MODE_PASTA) if (c->mode != MODE_PASTA)