Skip to content

Commit

Permalink
tools: add kmod_version() helper
Browse files Browse the repository at this point in the history
Add a trivial helper that prints the version + features combo. I will be
adding another instance of those, so I'm aiming to keep the boilerplate
code to a minimum.

Signed-off-by: Emil Velikov <[email protected]>
Link: #138
Signed-off-by: Lucas De Marchi <[email protected]>
  • Loading branch information
evelikov authored and lucasdemarchi committed Sep 21, 2024
1 parent 6eef551 commit b644b8d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions tools/depmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -3026,8 +3026,7 @@ static int do_depmod(int argc, char *argv[])
help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
return EXIT_SUCCESS;
case '?':
goto cmdline_failed;
Expand Down
3 changes: 1 addition & 2 deletions tools/insmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ static int do_insmod(int argc, char *argv[])
help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE;
Expand Down
3 changes: 1 addition & 2 deletions tools/kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ static int handle_kmod_commands(int argc, char *argv[])
kmod_help(argc, argv);
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE;
Expand Down
6 changes: 6 additions & 0 deletions tools/kmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ extern const struct kmod_cmd kmod_cmd_list;
extern const struct kmod_cmd kmod_cmd_static_nodes;
extern const struct kmod_cmd kmod_cmd_remove;

static inline void kmod_version(void)
{
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
}

#include "log.h"
3 changes: 1 addition & 2 deletions tools/modinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,7 @@ static int do_modinfo(int argc, char *argv[])
help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE;
Expand Down
3 changes: 1 addition & 2 deletions tools/modprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,7 @@ static int do_modprobe(int argc, char **orig_argv)
verbose++;
break;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
err = 0;
goto done;
case 'h':
Expand Down
3 changes: 1 addition & 2 deletions tools/rmmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ static int do_rmmod(int argc, char *argv[])
help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
puts(KMOD_FEATURES);
kmod_version();
return EXIT_SUCCESS;
case '?':
return EXIT_FAILURE;
Expand Down

0 comments on commit b644b8d

Please sign in to comment.