Adjust arguments of options_from_array to avoid skipping the first
array entry because that's not intuitive based on its function name.
Fixes insmod's handling of module options given as quoted command line
arguments.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/204
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
struct kmod_module *mod;
const char *filename;
char *opts = NULL;
- size_t optslen = 0;
int verbose = LOG_ERR;
int use_syslog = 0;
- int i, c, r = 0;
+ int c, r = 0;
const char *null_config = NULL;
unsigned int flags = 0;
goto end;
}
- for (i = optind + 1; i < argc; i++) {
- size_t len = strlen(argv[i]);
- void *tmp = realloc(opts, optslen + len + 2);
- if (tmp == NULL) {
- ERR("out of memory\n");
- r = EXIT_FAILURE;
- goto end;
- }
- opts = tmp;
- if (optslen > 0) {
- opts[optslen] = ' ';
- optslen++;
- }
- memcpy(opts + optslen, argv[i], len);
- optslen += len;
- opts[optslen] = '\0';
- }
+ r = options_from_array(argv + optind + 1, argc - optind - 1, &opts);
+ if (r < 0)
+ goto end;
ctx = kmod_new(NULL, &null_config);
if (!ctx) {
err = insmod_all(ctx, args, nargs);
else {
char *opts;
- err = options_from_array(args, nargs, &opts);
+ err = options_from_array(args + 1, nargs - 1, &opts);
if (err == 0) {
err = insmod(ctx, args[0], opts);
free(opts);
size_t optslen = 0;
int i, err = 0;
- for (i = 1; i < nargs; i++) {
+ for (i = 0; i < nargs; i++) {
size_t len = strlen(args[i]);
size_t qlen = 0;
const char *value;