Re: [ANNOUNCE] util-linux v2.26-rc1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 18 Jan 2015, Samuel Thibault wrote:

> Here is a fix for systems which don't have sys/timex.h and its 
> ntp_gettime().

Hi Samuel,

I took liberty to move patch you sent to git

https://github.com/kerolasa/lelux-utiliteetit/commit/e64274deb47714c81df149a019d60d650558ca2a

And here is the altered version of it for public display.  IMHO if 
ntp_gettime() is not available the time quality stuff can still work, and 
tell there is no way knowing if time is syncronized.

--->8----
From: Samuel Thibault <sthibault@xxxxxxxxxx>
Date: Sun, 18 Jan 2015 21:44:54 +0000
Subject: logger: check availability of ntp_gettime()

Make compilation to work in systems which don't have sys/timex.h and its
ntp_gettime().

[Sami: make #ifdef scope near 'if (ctl->rfc5424_tq)' tighter]

Reviewed-by: Sami Kerola <kerolasa@xxxxxx>
Signed-off-by: Samuel Thibault <sthibault@xxxxxxxxxx>
---
 configure.ac        | 1 +
 misc-utils/logger.c | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 3d77307..fce7e0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -230,6 +230,7 @@ AC_CHECK_HEADERS([ \
 	sys/swap.h \
 	sys/syscall.h \
 	sys/time.h \
+	sys/timex.h \
 	sys/ttydefaults.h \
 	sys/types.h \
 	sys/un.h \
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 35caf9d..03031da 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -44,7 +44,6 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
-#include <sys/timex.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -67,6 +66,10 @@
 # include <systemd/sd-journal.h>
 #endif
 
+#ifdef HAVE_SYS_TIMEX_H
+# include <sys/timex.h>
+#endif
+
 enum {
 	TYPE_UDP = (1 << 1),
 	TYPE_TCP = (1 << 2),
@@ -325,7 +328,9 @@ static void syslog_rfc5424(const  struct logger_ctl *ctl, const char *msg)
 {
 	char *buf, *tag = NULL, *hostname = NULL;
 	char pid[32], time[64], timeq[80];
+#ifdef HAVE_SYS_TIMEX_H
 	struct ntptimeval ntptv;
+#endif
 	struct timeval tv;
 	struct tm *tm;
 	int len;
@@ -364,11 +369,13 @@ static void syslog_rfc5424(const  struct logger_ctl *ctl, const char *msg)
 		snprintf(pid, sizeof(pid), " %d", ctl->pid);
 
 	if (ctl->rfc5424_tq) {
+#ifdef HAVE_SYS_TIMEX_H
 		if (ntp_gettime(&ntptv) == TIME_OK)
 			snprintf(timeq, sizeof(timeq),
 				 " [timeQuality tzKnown=\"1\" isSynced=\"1\" syncAccuracy=\"%ld\"]",
 				 ntptv.maxerror);
 		else
+#endif
 			snprintf(timeq, sizeof(timeq),
 				 " [timeQuality tzKnown=\"1\" isSynced=\"0\"]");
 	}
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux