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;
if ((errno == EAGAIN) || (errno == EINTR))
continue;
fclose(state_f);
- close(state_fd);
state_fd = -1;
break;
}
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");
}
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;
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;
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
*
#endif
return -1;
}
+#pragma GCC diagnostic pop
void uuid__generate_time(uuid_t out, int *num)
{