summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-05 15:08:54 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-05 17:59:23 -0200
commite2f9478fafe6730fb7aff07b10295bce9b0552b0 (patch)
treec28cd15ddb2fec4e9940e72ee7735ede57203d1a /tools
parent96b50d362349d78b3dd452e80221ab6ed0563002 (diff)
downloadkmod-e2f9478fafe6730fb7aff07b10295bce9b0552b0.tar.gz
insmod: prefer ERR over plain fprintf
Diffstat (limited to 'tools')
-rw-r--r--tools/insmod.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/insmod.c b/tools/insmod.c
index 4eb8110..e7423c4 100644
--- a/tools/insmod.c
+++ b/tools/insmod.c
@@ -24,6 +24,8 @@
#include <string.h>
#include "libkmod.h"
+#define LOGPREFIX "insmod: "
+#define ERR(...) fprintf(stderr, LOGPREFIX "ERROR: " __VA_ARGS__)
static const char cmdopts_s[] = "psfVh";
static const struct option cmdopts[] = {
@@ -89,22 +91,20 @@ static int do_insmod(int argc, char *argv[])
case '?':
return EXIT_FAILURE;
default:
- fprintf(stderr,
- "Error: unexpected getopt_long() value '%c'.\n",
+ ERR("unexpected getopt_long() value '%c'.\n",
c);
return EXIT_FAILURE;
}
}
if (optind >= argc) {
- fprintf(stderr, "Error: missing filename.\n");
+ ERR("missing filename.\n");
return EXIT_FAILURE;
}
filename = argv[optind];
if (strcmp(filename, "-") == 0) {
- fputs("Error: this tool does not support loading from stdin!\n",
- stderr);
+ ERR("this tool does not support loading from stdin!\n");
return EXIT_FAILURE;
}
@@ -112,7 +112,7 @@ static int do_insmod(int argc, char *argv[])
size_t len = strlen(argv[i]);
void *tmp = realloc(opts, optslen + len + 2);
if (tmp == NULL) {
- fputs("Error: out of memory\n", stderr);
+ ERR("out of memory\n");
free(opts);
return EXIT_FAILURE;
}
@@ -128,22 +128,22 @@ static int do_insmod(int argc, char *argv[])
ctx = kmod_new(NULL, &null_config);
if (!ctx) {
- fputs("Error: kmod_new() failed!\n", stderr);
+ ERR("kmod_new() failed!\n");
free(opts);
return EXIT_FAILURE;
}
err = kmod_module_new_from_path(ctx, filename, &mod);
if (err < 0) {
- fprintf(stderr, "Error: could not load module %s: %s\n",
- filename, strerror(-err));
+ ERR("could not load module %s: %s\n", filename,
+ strerror(-err));
goto end;
}
err = kmod_module_insert_module(mod, 0, opts);
if (err < 0) {
- fprintf(stderr, "Error: could not insert module %s: %s\n",
- filename, mod_strerror(-err));
+ ERR("could not insert module %s: %s\n", filename,
+ mod_strerror(-err));
}
kmod_module_unref(mod);