diff options
author | lhb-jr <lhb.jr@gmx.com> | 2014-03-21 12:04:32 -0400 |
---|---|---|
committer | lhb-jr <lhb.jr@gmx.com> | 2014-03-21 12:04:32 -0400 |
commit | 123cccd8332df85343891e01d050cda2cf221a78 (patch) | |
tree | 4ce6ae6abcde14840726c212f43f3d50d37db512 | |
parent | c0acbd0656ae0aeaa53f1d291fdee385ea43f7ff (diff) |
workaround 'discards const' warning during compile
modified: src/udev/udev-builtin-kmod.c
Temporary copies of the arguments to the 'execv' call are made so that gcc doesn't give,
possibly confusing warning about 'discarding const' during compilation.
-rw-r--r-- | src/udev/udev-builtin-kmod.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c index a9704c101c..57e2a9af7f 100644 --- a/src/udev/udev-builtin-kmod.c +++ b/src/udev/udev-builtin-kmod.c @@ -67,8 +67,21 @@ static int load_module(struct udev *udev, const char *alias) kmod_module_unref_list(list); return err; #else - char *const argv[] = { MODPROBE, "-bq", alias, 0 }; - return execute_command(MODPROBE, argv); + int retval; + + /* + These 3 temporaries are needed because argv (below) is a const pointer, not pointer to const + */ + char *tmp_alias = strdup(alias); + char *tmp_modprobe = strdup(MODPROBE); + char *tmp_bq = strdup("-bq"); + char *const argv[] = { tmp_modprobe, tmp_bq, tmp_alias, 0 }; + + retval = execute_command(MODPROBE, argv); + + free(tmp_alias); + free(tmp_modprobe); + free(tmp_bq); #endif } |