summaryrefslogtreecommitdiffstats
path: root/sntpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sntpc.c')
-rw-r--r--sntpc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sntpc.c b/sntpc.c
index 61724ad..150d23c 100644
--- a/sntpc.c
+++ b/sntpc.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008 Natanael Copa
+/* Copyright (c) 2008-2016 Natanael Copa
*
* Licencend under GPL-2
*/
@@ -34,7 +34,7 @@ static const char *usage_str = "usage: sntpc [-bdhnvV] [-i INTERVAL] NTPHOST\n"
" -h Show this help\n"
" -n Do not set time, just show the offset and delay\n"
" -i Poll every INTERVAL seconds\n"
-" -v Verbose logging\n"
+" -v Verbose logging\n"
" -V Show version and exit\n"
"\n";
@@ -44,7 +44,7 @@ int init_conn(const char *host, const char *service) {
struct addrinfo hints;
struct addrinfo *res, *res0;
int fd, error;
-
+
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
@@ -134,7 +134,7 @@ int ntp_msg_recv(int fd, struct ntp_msg *msg)
return 0;
}
-int ntp_msg_query(int fd, struct ntp_msg *response,
+int ntp_msg_query(int fd, struct ntp_msg *response,
double *T1, double *T4)
{
int retry = 3;
@@ -148,9 +148,9 @@ int ntp_msg_query(int fd, struct ntp_msg *response,
if (ntp_msg_wait(fd, 3000) <= 0)
continue;
-
+
*T4 = gettime();
- if (ntp_msg_recv(fd, response) == 0)
+ if (ntp_msg_recv(fd, response) == 0)
break;
}
if (retry == 0)
@@ -199,7 +199,7 @@ int sync_time(const char *host)
int ret;
int fd;
double T1, T2, T3, T4, delay, offset;
-
+
fd = init_conn(host, "ntp");
if (fd < 0)
return -1;
@@ -228,7 +228,7 @@ void daemonize(void) {
int pid = fork();
if (pid < 0)
fatal("fork");
-
+
if (pid > 0)
exit(0);
@@ -249,7 +249,7 @@ int main(int argc, char * const argv[])
background++;
break;
case 'h':
- printf(usage_str);
+ printf("%s", usage_str);
return(0);
case 'i':
interval = atoi(optarg);
@@ -267,7 +267,7 @@ int main(int argc, char * const argv[])
}
}
if (optind != (argc - 1)) {
- printf(usage_str);
+ printf("%s", usage_str);
return 1;
}
ntphost = argv[optind];