summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorblueness <basile@opensource.dyc.edu>2014-03-22 16:52:55 -0400
committerblueness <basile@opensource.dyc.edu>2014-03-22 16:52:55 -0400
commitac73951d246e035b92771bdddc2892bdabeed760 (patch)
treed39e8c63b906c0c8eaa3198174c44fee3431a33e /src
parentfbfcfb49a6f2bfa61e235f5fe601fa9a9f95b4ea (diff)
parenta45adc4f91de8b6a27387fe2ccd16b8b0f613d65 (diff)
Merge pull request #91 from lhb-jr/fix_discardconst_warn
src/udev/udev-builtin-kmod.c: fix discardconst warn Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-builtin-kmod.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index a9704c101c..a8792e097f 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -38,10 +38,10 @@ static struct kmod_ctx *ctx;
static int load_module(struct udev *udev, const char *alias)
{
+ int err;
#ifdef HAVE_LIBKMOD
struct kmod_list *list = NULL;
struct kmod_list *l;
- int err;
err = kmod_module_new_from_lookup(ctx, alias, &list);
if (err < 0)
@@ -65,11 +65,25 @@ 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);
+
+ /*
+ 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 };
+
+ err = execute_command(MODPROBE, argv);
+
+ free(tmp_alias);
+ free(tmp_modprobe);
+ free(tmp_bq);
#endif
+ /* both 'kmod_module_new_from_lookup' and 'execute_command' return <0 on error
+ so it is ok to assign both to 'err' */
+ return err;
}
_printf_(6,0)