]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - lib/uuid/gen_uuid.c
Eliminate unused parameter warnings from Android build
[thirdparty/e2fsprogs.git] / lib / uuid / gen_uuid.c
index efa4e3d3dd16586f3279c28d36f4fc84873f40f2..794c5851ba37394a69e31bbdefc0fbb4d19ff117 100644 (file)
@@ -326,10 +326,12 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
                state_fd = open("/var/lib/libuuid/clock.txt",
                                O_RDWR|O_CREAT, 0660);
                (void) umask(save_umask);
-               state_f = fdopen(state_fd, "r+");
-               if (!state_f) {
-                       close(state_fd);
-                       state_fd = -1;
+               if (state_fd >= 0) {
+                       state_f = fdopen(state_fd, "r+");
+                       if (!state_f) {
+                               close(state_fd);
+                               state_fd = -1;
+                       }
                }
        }
        fl.l_type = F_WRLCK;
@@ -343,7 +345,6 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
                        if ((errno == EAGAIN) || (errno == EINTR))
                                continue;
                        fclose(state_f);
-                       close(state_fd);
                        state_fd = -1;
                        break;
                }
@@ -401,9 +402,10 @@ try_again:
 
        if (state_fd > 0) {
                rewind(state_f);
-               len = fprintf(state_f, 
+               len = fprintf(state_f,
                              "clock: %04x tv: %016lu %08lu adj: %08d\n",
-                             clock_seq, last.tv_sec, last.tv_usec, adjustment);
+                             clock_seq, last.tv_sec, (long)last.tv_usec,
+                             adjustment);
                fflush(state_f);
                if (ftruncate(state_fd, len) < 0) {
                        fprintf(state_f, "                   \n");
@@ -411,7 +413,10 @@ try_again:
                }
                rewind(state_f);
                fl.l_type = F_UNLCK;
-               fcntl(state_fd, F_SETLK, &fl);
+               if (fcntl(state_fd, F_SETLK, &fl) < 0) {
+                       fclose(state_f);
+                       state_fd = -1;
+               }
        }
 
        *clock_high = clock_reg >> 32;
@@ -420,6 +425,7 @@ try_again:
        return 0;
 }
 
+#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
 static ssize_t read_all(int fd, char *buf, size_t count)
 {
        ssize_t ret;
@@ -470,8 +476,12 @@ static void close_all_fds(void)
                        open("/dev/null", O_RDWR);
        }
 }
+#endif /* defined(USE_UUIDD) && defined(HAVE_SYS_UN_H) */
 
-
+#pragma GCC diagnostic push
+#if !defined(USE_UUIDD) || !defined(HAVE_SYS_UN_H)
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
 /*
  * Try using the uuidd daemon to generate the UUID
  *
@@ -554,6 +564,7 @@ fail:
 #endif
        return -1;
 }
+#pragma GCC diagnostic pop
 
 void uuid__generate_time(uuid_t out, int *num)
 {