Date: Thu, 4 Sep 2008 22:50:03 GMT From: Bruce Cran <bruce@cran.org.uk> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/71618: [PATCH] timed(8): cleanup of the usr.sbin/timed code Message-ID: <200809042250.m84Mo3Hw063554@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/71618; it has been noted by GNATS. From: Bruce Cran <bruce@cran.org.uk> To: bug-followup@FreeBSD.org, dan@obluda.cz Cc: Subject: Re: bin/71618: [PATCH] timed(8): cleanup of the usr.sbin/timed code Date: Thu, 4 Sep 2008 23:40:53 +0100 --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline The attached patches fix a lot of the warnings in usr.sbin/timed with high WARNS levels and GCC 4. -- Bruce Cran --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=acksend.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=acksend.c.diff --- acksend.c.orig 2008-09-04 23:17:01.000000000 +0100 +++ acksend.c 2008-09-04 23:17:09.000000000 +0100 @@ -43,8 +43,6 @@ struct tsp *answer; -extern u_short sequence; - void xmit(type, seq, addr) int type; --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=correct.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=correct.c.diff --- correct.c.orig 2008-09-04 23:17:34.000000000 +0100 +++ correct.c 2008-09-04 23:18:38.000000000 +0100 @@ -166,8 +166,8 @@ } } else { syslog(LOG_WARNING, - "clock correction %ld sec too large to adjust", - adj.tv_sec); + "clock correction %lld sec too large to adjust", + (long long int)adj.tv_sec); (void) gettimeofday(&now, 0); timevaladd(&now, corr); if (settimeofday(&now, 0) < 0) --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=globals.h.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=globals.h.diff --- globals.h.orig 2008-09-04 23:17:14.000000000 +0100 +++ globals.h 2008-09-04 23:17:25.000000000 +0100 @@ -55,8 +55,6 @@ #define SECHR (60*60) #define SECDAY (24*SECHR) -extern int sock; - /* Best expected round trip for a measurement. * This is essentially the number of milliseconds per CPU tick (CLK_TCK?). * All delays shorter than this are usually reported as 0. --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=master.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=master.c.diff --- master.c.orig 2008-09-04 23:18:49.000000000 +0100 +++ master.c 2008-09-04 23:21:17.000000000 +0100 @@ -44,6 +44,7 @@ #include <sys/types.h> #include <sys/times.h> #include <setjmp.h> +#include <libutil.h> #include "pathnames.h" extern int measure_delta; @@ -56,8 +57,6 @@ static void mchgdate(struct tsp *); -extern void logwtmp(char *, char *, char *); - /* * The main function of `master' is to periodically compute the differences * (deltas) between its clock and the clocks of the slaves, to compute the @@ -832,8 +831,7 @@ void -traceoff(msg) - char *msg; +traceoff(const char *msg) { get_goodgroup(1); setstatus(); --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=readmsg.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=readmsg.c.diff --- readmsg.c.orig 2008-09-04 23:21:26.000000000 +0100 +++ readmsg.c 2008-09-04 23:39:00.000000000 +0100 @@ -39,6 +39,7 @@ "$FreeBSD: src/usr.sbin/timed/timed/readmsg.c,v 1.9 2001/11/20 07:13:40 jhb Exp $"; #endif /* not lint */ +#include <stdint.h> #include "globals.h" extern char *tsptype[]; @@ -186,8 +187,8 @@ rwait.tv_usec = 1000000/CLK_TCK; if (trace) { - fprintf(fd, "readmsg: wait %ld.%6ld at %s\n", - rwait.tv_sec, rwait.tv_usec, date()); + fprintf(fd, "readmsg: wait %lld.%6ld at %s\n", + (long long int)rwait.tv_sec, rwait.tv_usec, date()); /* Notice a full disk, as we flush trace info. * It is better to flush periodically than at * every line because the tracing consists of bursts @@ -491,12 +492,12 @@ break; case TSP_ADJTIME: - fprintf(fd, "%s %d %-6u (%ld,%ld) %-15s %s\n", + fprintf(fd, "%s %d %-6u (%jd,%jd) %-15s %s\n", tsptype[msg->tsp_type], msg->tsp_vers, msg->tsp_seq, - msg->tsp_time.tv_sec, - msg->tsp_time.tv_usec, + (intmax_t)msg->tsp_time.tv_sec, + (intmax_t)msg->tsp_time.tv_usec, inet_ntoa(addr->sin_addr), msg->tsp_name); break; --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=slave.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=slave.c.diff --- slave.c.orig 2008-09-04 23:28:34.000000000 +0100 +++ slave.c 2008-09-04 23:32:48.000000000 +0100 @@ -41,14 +41,14 @@ #include "globals.h" #include <setjmp.h> +#include <sys/types.h> +#include <libutil.h> #include "pathnames.h" extern jmp_buf jmpenv; extern int Mflag; extern int justquit; -extern u_short sequence; - static char master_name[MAXHOSTNAMELEN]; static struct netinfo *old_slavenet; static int old_status; @@ -57,13 +57,11 @@ static void setmaster(struct tsp *); static void answerdelay(void); -extern void logwtmp(char *, char *, char *); - int -slave() +slave(void) { int tries; - long electiontime, refusetime, looktime, looptime, adjtime; + long electiontime, refusetime, looktime, looptime, adj_time; u_short seq; long fastelection; #define FASTTOUT 3 @@ -75,7 +73,6 @@ struct timeval ntime, wait, tmptv; time_t tsp_time_sec; struct tsp *answer; - int timeout(); char olddate[32]; char newdate[32]; struct netinfo *ntp; @@ -85,7 +82,9 @@ old_slavenet = 0; seq = 0; refusetime = 0; - adjtime = 0; + adj_time = 0; + + memset(&cadr, 0, sizeof(struct in_addr)); (void)gettimeofday(&ntime, 0); electiontime = ntime.tv_sec + delay2; @@ -230,7 +229,7 @@ * is found. */ (void)gettimeofday(&otime, 0); - if (adjtime < otime.tv_sec) + if (adj_time < otime.tv_sec) looptime -= (looptime-otime.tv_sec)/2 + 1; setmaster(msg); @@ -241,7 +240,7 @@ (void)gettimeofday(&ntime, 0); electiontime = ntime.tv_sec + delay2; fastelection = ntime.tv_sec + FASTTOUT; - adjtime = ntime.tv_sec + SAMPLEINTVL*2; + adj_time = ntime.tv_sec + SAMPLEINTVL*2; break; case TSP_SETTIME: @@ -680,7 +679,7 @@ * contention and likely collisions. */ static void -answerdelay() +answerdelay(void) { struct timeval timeout; --MP_/YIDZdtW/+AWSkfJ0mKe0ALI Content-Type: text/x-patch; name=timed.c.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=timed.c.diff --- timed.c.orig 2008-09-04 23:33:00.000000000 +0100 +++ timed.c 2008-09-04 23:34:06.000000000 +0100 @@ -115,9 +115,7 @@ * overhauled at Silicon Graphics */ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { int on; int ret; @@ -704,7 +702,7 @@ } char * -date() +date(void) { struct timeval tv; time_t tv_sec; @@ -715,8 +713,7 @@ } void -addnetname(name) - char *name; +addnetname(char *name) { register struct nets **netlist = &nets; @@ -731,9 +728,8 @@ /* note a host as trustworthy */ static void -add_good_host(name, perm) - char *name; - int perm; /* 1=not part of the netgroup */ +add_good_host(char *name, int perm) +/* int perm : 1=not part of the netgroup */ { register struct goodhost *ghp; register struct hostent *hentp; --MP_/YIDZdtW/+AWSkfJ0mKe0ALI--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809042250.m84Mo3Hw063554>