]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wdctl: align with other util-linux commands
authorSami Kerola <kerolasa@iki.fi>
Thu, 19 Apr 2012 19:10:54 +0000 (21:10 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 3 May 2012 13:00:07 +0000 (15:00 +0200)
* Add watchdog device path to pathnames.h
* Check output stream status at exit.
* Adjust usage() notation to follow howto file.
* Retire numeric return value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
include/pathnames.h
sys-utils/wdctl.c

index 88bec08dfc4904ef634546e0cfa8cd2ae7693734..ba8de0111094a950dc1752ae5dfc41d023ac9818 100644 (file)
 /* deprecated */
 #define _PATH_RAWDEVCTL_OLD    "/dev/rawctl"
 
+/* wdctl path */
+#define _PATH_WATCHDOG_DEV     "/dev/watchdog"
 
 #endif /* PATHNAMES_H */
 
index 179aff207d7a7d9319d46b53ee5d3d8a533e386b..4c6f87442fb7f3fe7314488731e9af579cd48417 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "nls.h"
 #include "c.h"
+#include "closestream.h"
+#include "pathnames.h"
 
 static const struct {
        uint32_t flag;
@@ -55,7 +57,8 @@ static void usage(int status)
              _(" %s [options]\n"), program_invocation_short_name);
 
        fputs(USAGE_OPTIONS, out);
-       fputs(_(" -d, --device=  device to use (/dev/watchdog)\n"), out);
+       fprintf(out,
+             _(" -d, --device <path>   device to use (default is %s)\n"), _PATH_WATCHDOG_DEV);
 
        fputs(USAGE_SEPARATOR, out);
        fputs(USAGE_HELP, out);
@@ -94,12 +97,13 @@ int main(int argc, char *argv[])
        };
 
        int c, status, sec, fd;
-       const char *device = "/dev/watchdog";
+       const char *device = _PATH_WATCHDOG_DEV;
        struct watchdog_info ident;
 
        setlocale(LC_MESSAGES, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
+       atexit(close_stdout);
 
        while((c = getopt_long(argc, argv, "hVd:", longopts, NULL)) != -1) {
 
@@ -176,5 +180,5 @@ int main(int argc, char *argv[])
 
        close(fd);
 
-       return 0;
+       return EXIT_SUCCESS;
 }