[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e9261305-a82e-452d-8da9-07accddfebb4@gmail.com>
Date: Wed, 21 Feb 2018 09:10:45 -0700
From: David Ahern <dsahern@...il.com>
To: Leon Romanovsky <leon@...nel.org>
Cc: Leon Romanovsky <leonro@...lanox.com>,
netdev <netdev@...r.kernel.org>,
Stephen Hemminger <stephen@...workplumber.org>,
RDMA mailing list <linux-rdma@...r.kernel.org>
Subject: Re: [PATCH iproute2-next] rdma: Add batch command support
On 2/21/18 5:38 AM, Leon Romanovsky wrote:
> @@ -36,17 +37,54 @@ static int rd_cmd(struct rd *rd)
> { 0 }
> };
>
> + rd->argc = argc;
> + rd->argv = argv;
> +
> return rd_exec_cmd(rd, cmds, "object");
> }
>
> -static int rd_init(struct rd *rd, int argc, char **argv, char *filename)
> +static int rd_batch(struct rd *rd, const char *name, bool force)
> +{
> + char *line = NULL;
> + size_t len = 0;
> + int ret = 0;
> +
> + if (name && strcmp(name, "-") != 0) {
> + if (!freopen(name, "r", stdin)) {
> + pr_err("Cannot open file \"%s\" for reading: %s\n",
> + name, strerror(errno));
> + return errno;
> + }
> + }
> +
> + cmdlineno = 0;
> + while (getcmdline(&line, &len, stdin) != -1) {
> + char *largv[512];
> + int largc;
> +
> + largc = makeargs(line, largv, 100);
you have largv[512] declared but passing a max of 100. I realize other
batch commands have it hardcoded, but ARRAY_SIZE is better.
Powered by blists - more mailing lists