hammer - Fix version output
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Tue, 19 Apr 2011 18:58:07 +0000 (20:58 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Tue, 19 Apr 2011 18:58:07 +0000 (20:58 +0200)
Do not try to display WIP version if there isn't one.

sbin/hammer/cmd_version.c

index 956e0f5..5c1f9c9 100644 (file)
@@ -46,6 +46,7 @@ void
 hammer_cmd_get_version(char **av, int ac)
 {
        struct hammer_ioc_version version;
+       char wip[16];
        int fd;
 
        if (ac != 1)
@@ -66,9 +67,10 @@ hammer_cmd_get_version(char **av, int ac)
                fprintf(stderr, "hammer version ioctl: %s\n", strerror(errno));
                exit(1);
        }
-       printf("min=%d wip=%d max=%d current=%d description=\"%s\"\n",
+       snprintf(wip, 16, "%d", version.wip_version);
+       printf("min=%d wip=%s max=%d current=%d description=\"%s\"\n",
                version.min_version,
-               version.wip_version,
+              (version.wip_version > version.max_version) ? "none" : wip,
                version.max_version,
                version.cur_version,
                version.description