]> git.proxmox.com Git - proxmox-mini-journalreader.git/commitdiff
rename convert_argument to arg_to_uint64
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 May 2019 10:22:56 +0000 (10:22 +0000)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 14 May 2019 12:01:47 +0000 (12:01 +0000)
and make it static and move it nearer to it's use

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/mini-journalreader.c

index f6ae87450edc638c19fa6aab1fa41c3a74b23740..06fcd59189df3cd6d09d58de51e16842da644a47 100644 (file)
 static char buf[BUFSIZE+1];
 static size_t offset = 0;
 
-uint64_t convert_argument(const char *argument) {
-    errno = 0;
-    char * end;
-    uint64_t value = strtoull(argument, &end, 10);
-    if (errno != 0 || *end != '\0') {
-        fprintf(stderr, "%s is not a valid number\n", argument);
-        exit(1);
-    }
-
-    return value;
-}
-
 uint64_t get_timestamp(sd_journal *j) {
     uint64_t timestamp;
     int r = sd_journal_get_realtime_usec(j, &timestamp);
@@ -207,6 +195,19 @@ void usage(char *progname) {
     fprintf(stderr, "-e and -t conflict\n");
 }
 
+static uint64_t arg_to_uint64(const char *argument) {
+    errno = 0;
+    char * end;
+    uint64_t value = strtoull(argument, &end, 10);
+    if (errno != 0 || *end != '\0') {
+        fprintf(stderr, "%s is not a valid integer number\n", argument);
+        exit(1);
+    }
+
+    return value;
+}
+
+
 int main(int argc, char *argv[]) {
     uint64_t number = 0;
     const char *directory = NULL;
@@ -219,18 +220,18 @@ int main(int argc, char *argv[]) {
     while ((c = getopt (argc, argv, "b:e:d:n:f:t:h")) != -1) {
         switch (c) {
             case 'b':
-                begin = convert_argument(optarg);
-                begin = begin*1000*1000;
+                begin = arg_to_uint64(optarg);
+                begin = begin * 1000 * 1000; // µs
                 break;
             case 'e':
-                end = convert_argument(optarg);
-                end = end*1000*1000;
+                end = arg_to_uint64(optarg);
+                end = end * 1000 * 1000; // µs
                 break;
             case 'd':
                 directory = optarg;
                 break;
             case 'n':
-                number = convert_argument(optarg);
+                number = arg_to_uint64(optarg);
                 break;
             case 'f':
                 startcursor = optarg;