From: Dave Hart Date: Tue, 28 Apr 2009 06:59:44 +0000 (+0000) Subject: [Bug 1169] quiet compiler warnings X-Git-Tag: NTP_4_2_5P168~3^2~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32642884e0b32b6bdea9bc57f33c275781bb2a89;p=thirdparty%2Fntp.git [Bug 1169] quiet compiler warnings Re-enable gcc -Wstrict-prototypes when not building with OpenSSL Enable gcc -Wstrict-overflow ntpq/ntpdc emit newline after accepting password on Windows bk: 49f6a9608xgBUMpC9_sqXrYItlw8xA --- diff --git a/ChangeLog b/ChangeLog index 22d16f490..f326f71b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +* [Bug 1169] quiet compiler warnings +* Re-enable gcc -Wstrict-prototypes when not building with OpenSSL +* Enable gcc -Wstrict-overflow +* ntpq/ntpdc emit newline after accepting password on Windows (4.2.5p166) 2009/04/25 Released by Harlan Stenn * [Bug 1165] Clean up small memory leaks in the config file parser * Correct logconfig keyword declaration to MULTIPLE_ARG diff --git a/configure.ac b/configure.ac index 72a0cf541..373742b10 100644 --- a/configure.ac +++ b/configure.ac @@ -255,24 +255,14 @@ case "$GCC" in CFLAGS="$CFLAGS -Wmissing-prototypes" CFLAGS="$CFLAGS -Wpointer-arith" CFLAGS="$CFLAGS -Wshadow" - # - # OpenSSL has a number of callback prototypes - # inside other function prototypes which trigger - # warnings with -Wstrict-prototypes, such as: - # - # int i2d_RSA_NET(const RSA *a, unsigned char **pp, - # int (*cb)(), int sgckey); - # ^^^^^^^^^^^ - # - CFLAGS="$CFLAGS -Wno-strict-prototypes" # CFLAGS="$CFLAGS -Wtraditional" # CFLAGS="$CFLAGS -Wwrite-strings" CFLAGS="$CFLAGS -Winit-self" case "$ac_cv_gcc_Wstrict_overflow" in yes) - #not yet: CFLAGS="$CFLAGS -Wstrict-overflow" + CFLAGS="$CFLAGS -Wstrict-overflow" esac - ;; + # if building with OpenSSL, -Wno-strict-prototypes is added later esac case "$host" in @@ -3153,33 +3143,57 @@ case "$ans" in esac AC_MSG_RESULT([$ans]) +AC_MSG_CHECKING([if we will use crypto]) AC_ARG_WITH(crypto, AC_HELP_STRING([--with-crypto], [+ =openssl]), [ans=$withval], [ans=yes]) case "$ans" in - no) ;; + no) + ;; yes|openssl) if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC" then ans=no else - # We have OpenSSL inc/lib - use them. - ans=openssl - CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC" - LDFLAGS="$LDFLAGS -L$OPENSSL_LIB" - case "$need_dash_r" in - 1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB" - ;; - esac - AC_SUBST(LCRYPTO, [-lcrypto]) - AC_DEFINE(OPENSSL, , [Use OpenSSL?]) - AC_CHECK_FUNCS(EVP_md2 EVP_mdc2) + ans=yes fi - ;; esac -AC_MSG_CHECKING(for the level of crypto support) +ntp_openssl=$ans AC_MSG_RESULT([$ans]) +case "$ntp_openssl" in + yes) + # We have OpenSSL inc/lib - use them. + CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC" + LDFLAGS="$LDFLAGS -L$OPENSSL_LIB" + case "$need_dash_r" in + 1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB" + esac + AC_SUBST(LCRYPTO, [-lcrypto]) + AC_DEFINE(OPENSSL, , [Use OpenSSL?]) + AC_CHECK_FUNCS([EVP_md2 EVP_mdc2]) +esac + +# +# OpenSSL has a number of callback prototypes inside other function +# prototypes which trigger copious warnings with -Wstrict-prototypes, +# (which is included in -Wall). +# +# An example: +# +# int i2d_RSA_NET(const RSA *a, unsigned char **pp, +# int (*cb)(), int sgckey); +# ^^^^^^^^^^^ +# +# The OpenSSL headers probably haven't been fixed in this regard +# due to the hoops you have to jump through to stay compatible with +# K&R C compilers. +# +case "$GCC$ntp_openssl" in + yesyes) + CFLAGS="$CFLAGS -Wno-strict-prototypes" +esac + AC_MSG_CHECKING([if we want to compile with ElectricFence]) AC_ARG_WITH(electricfence, AC_HELP_STRING([--with-electricfence], [- compile with ElectricFence malloc debugger]), diff --git a/gsoc_sntp/crypto.c b/gsoc_sntp/crypto.c index e3335dcb3..acf48a0b0 100644 --- a/gsoc_sntp/crypto.c +++ b/gsoc_sntp/crypto.c @@ -67,7 +67,7 @@ auth_md5 ( */ int auth_init ( - char *keyfile, + const char *keyfile, struct key **keys ) { @@ -75,7 +75,7 @@ auth_init ( struct key *prev = NULL; register int a, line_limit; - int scan_cnt, line_cnt = 0, key_cnt = 0; + int scan_cnt, line_cnt = 0; char kbuf[96]; if(keyf == NULL) { @@ -104,7 +104,7 @@ auth_init ( for(a=0; a +#include #include #include #include @@ -85,18 +86,18 @@ sntp_main ( /* Initialize logging system */ if(HAVE_OPT(FILELOG)) { - init_log((char *)OPT_ARG(FILELOG)); + init_log(OPT_ARG(FILELOG)); } /* If there's a specified KOD file init KOD system. * If not and system may save to HD use default file. */ if(HAVE_OPT(KOD)) { - kod_init_kod_db((char *)OPT_ARG(KOD)); + kod_init_kod_db(OPT_ARG(KOD)); } if(HAVE_OPT(KEYFILE)) { - auth_init((char *)OPT_ARG(KEYFILE), &keys); + auth_init(OPT_ARG(KEYFILE), &keys); } diff --git a/gsoc_sntp/networking.c b/gsoc_sntp/networking.c index a4472df1a..1fa641b47 100644 --- a/gsoc_sntp/networking.c +++ b/gsoc_sntp/networking.c @@ -244,7 +244,7 @@ recv_bcst_data ( { struct timeval timeout_tv; fd_set bcst_fd; - + char *buf; int btrue = 1; int recv_bytes = 0; @@ -252,22 +252,17 @@ recv_bcst_data ( setsockopt(rsock, SOL_SOCKET, SO_REUSEADDR, &btrue, sizeof(btrue)); if(sas->ss_family == AF_INET) { - struct sockaddr_in sin; struct ip_mreq mdevadr; - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = htonl(INADDR_ANY); - sin.sin_port = htons(123); - if(bind(rsock, (struct sockaddr *) sas, SOCKLEN(sas)) < 0) {} if(setsockopt(rsock, IPPROTO_IP, IP_MULTICAST_LOOP, &btrue, sizeof(btrue)) < 0) { /* some error message regarding setting up multicast loop */ return BROADCAST_FAILED; - } + } - char *buf = ss_to_str(sas); + buf = ss_to_str(sas); mdevadr.imr_multiaddr.s_addr = inet_addr(buf); mdevadr.imr_interface.s_addr = htonl(INADDR_ANY); @@ -284,7 +279,7 @@ recv_bcst_data ( if (setsockopt(rsock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mdevadr, sizeof(mdevadr)) < 0) { if(ENABLED_OPT(NORMALVERBOSE)) { - char *buf = ss_to_str(sas); + buf = ss_to_str(sas); printf("sntp recv_bcst_data: Couldn't add IP membership for %s\n", buf); @@ -295,13 +290,8 @@ recv_bcst_data ( } } else if(sas->ss_family == AF_INET6) { - struct sockaddr_in6 sin6; struct ipv6_mreq mdevadr; - sin6.sin6_family = AF_INET6; - sin6.sin6_addr = in6addr_any; - sin6.sin6_port = htons(123); - if(bind(rsock, (struct sockaddr *) sas, sizeof(sas)) < 0) { if(ENABLED_OPT(NORMALVERBOSE)) printf("sntp recv_bcst_data: Couldn't bind() address.\n"); @@ -318,7 +308,7 @@ recv_bcst_data ( if(!IN6_IS_ADDR_MULTICAST((struct in6_addr *) &mdevadr.ipv6mr_multiaddr)) { if(ENABLED_OPT(NORMALVERBOSE)) { - char *buf = ss_to_str(sas); + buf = ss_to_str(sas); printf("sntp recv_bcst_data: %s is not a broad-/multicast address, aborting...\n", buf); @@ -330,7 +320,7 @@ recv_bcst_data ( if (setsockopt(rsock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mdevadr, sizeof(mdevadr)) < 0) { if(ENABLED_OPT(NORMALVERBOSE)) { - char *buf = ss_to_str(sas); + buf = ss_to_str(sas); printf("sntp recv_bcst_data: Couldn't join group for %s\n", buf); @@ -361,7 +351,7 @@ recv_bcst_data ( case 0: if(ENABLED_OPT(NORMALVERBOSE)) - printf("sntp recv_bcst_data: select() reached timeout (%i sec), aborting.\n", timeout_tv.tv_sec); + printf("sntp recv_bcst_data: select() reached timeout (%li sec), aborting.\n", timeout_tv.tv_sec); return BROADCAST_FAILED; break; diff --git a/include/isc/file.h b/include/isc/file.h index 16b007572..b2d9e8f51 100644 --- a/include/isc/file.h +++ b/include/isc/file.h @@ -30,10 +30,10 @@ ISC_LANG_BEGINDECLS isc_result_t -isc_file_settime(const char *file, isc_time_t *time); +isc_file_settime(const char *file, isc_time_t *mtime); isc_result_t -isc_file_getmodtime(const char *file, isc_time_t *time); +isc_file_getmodtime(const char *file, isc_time_t *mtime); /*!< * \brief Get the time of last modication of a file. * diff --git a/include/isc/mem.h b/include/isc/mem.h index f8e73d0e7..7881e18ec 100644 --- a/include/isc/mem.h +++ b/include/isc/mem.h @@ -1,3 +1,7 @@ +/* + * short-circuited NTP-local imitation of isc/mem.h + */ + /* * Copyright (C) 1997-2001 Internet Software Consortium. * @@ -20,12 +24,13 @@ #ifndef ISC_MEM_H #define ISC_MEM_H 1 +#include #include -#include -void * -isc_mem_get(isc_mem_t *, size_t); -void -isc_mem_put(isc_mem_t *, void *, size_t); + +#define isc_mem_get(c, cnt) malloc((cnt) ? (cnt) : 1) +#define isc_mem_put(c, mem, cnt) free(mem) +#define isc_mem_free(c, mem) free(mem) +#define isc_mem_strdup(c, str) strdup(str) #endif /* ISC_MEM_H */ diff --git a/include/ntp_config.h b/include/ntp_config.h index 58b8f5d27..e8845616f 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -177,6 +177,7 @@ struct REMOTE_CONFIG_INFO { struct peer_node *create_peer_node(int hmode, struct address_node *addr, queue *options); struct unpeer_node *create_unpeer_node(struct address_node *addr); struct address_node *create_address_node(char *addr, int type); +void destroy_address_node(struct address_node *my_node); queue *enqueue_in_new_queue(void *my_node); struct attr_val *create_attr_dval(int attr, double value); struct attr_val *create_attr_ival(int attr, int value); diff --git a/include/ntp_stdlib.h b/include/ntp_stdlib.h index 9496b5d6e..f6f26549e 100644 --- a/include/ntp_stdlib.h +++ b/include/ntp_stdlib.h @@ -70,8 +70,8 @@ extern char * inttoa (long); extern char * mfptoa (u_long, u_long, short); extern char * mfptoms (u_long, u_long, short); extern const char * modetoa (int); -extern const char * eventstr (int); -extern const char * ceventstr (int); +extern const char * eventstr (int); +extern const char * ceventstr (int); extern char * statustoa (int, int); extern const char * sysstatstr (int); extern const char * peerstatstr (int); @@ -79,8 +79,8 @@ extern const char * clockstatstr (int); extern struct sockaddr_storage* netof (struct sockaddr_storage*); extern char * numtoa (u_int32); extern char * numtohost (u_int32); -extern char * socktoa (struct sockaddr_storage *); -extern char * socktohost (struct sockaddr_storage *); +extern char * socktoa (struct sockaddr_storage *); +extern char * socktohost (struct sockaddr_storage *); extern int octtoint (const char *, u_long *); extern u_long ranp2 (int); extern char * refnumtoa (struct sockaddr_storage *); @@ -89,7 +89,7 @@ extern char * uinttoa (u_long); extern int decodenetnum (const char *, struct sockaddr_storage *); -extern const char * FindConfig (const char *); +extern const char * FindConfig (const char *); extern void signal_no_reset (int, RETSIGTYPE (*func)(int)); diff --git a/include/ntpsim.h b/include/ntpsim.h index 9be8f2990..1d9e6d7ca 100644 --- a/include/ntpsim.h +++ b/include/ntpsim.h @@ -125,6 +125,7 @@ extern sim_info simulation; /* Simulation Control Variables */ /* Function Prototypes */ +int ntpsim (int argc, char *argv[]); Event *event (double t, funcTkn f); void sim_event_timer (Event *e); int simulate_server (struct sockaddr_storage *serv_addr, diff --git a/libisc/inet_ntop.c b/libisc/inet_ntop.c index 395d0e50d..feb85f135 100644 --- a/libisc/inet_ntop.c +++ b/libisc/inet_ntop.c @@ -22,6 +22,8 @@ static char rcsid[] = #include +#ifdef ISC_PLATFORM_NEEDNTOP + #include #include #include @@ -196,3 +198,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size) return (dst); } #endif /* AF_INET6 */ + +#else +int inet_ntop_c_not_empty; +#endif /* ISC_PLATFORM_NEEDNTOP */ diff --git a/libisc/inet_pton.c b/libisc/inet_pton.c index afda394ca..3416dffda 100644 --- a/libisc/inet_pton.c +++ b/libisc/inet_pton.c @@ -22,6 +22,8 @@ static char rcsid[] = #include +#ifdef ISC_PLATFORM_NEEDPTON + #include #include @@ -209,3 +211,7 @@ inet_pton6(const char *src, unsigned char *dst) { memcpy(dst, tmp, NS_IN6ADDRSZ); return (1); } + +#else +int inet_pton_c_not_empty; +#endif /* ISC_PLATFORM_NEEDPTON */ diff --git a/libisc/mem.c b/libisc/mem.c index 39f1e5c7c..f503c84fa 100644 --- a/libisc/mem.c +++ b/libisc/mem.c @@ -1,3 +1,8 @@ +/* + * this file is leaving the NTP build in favor of + * inline macros in isc/mem.h for now + */ + /* * Copyright (C) 1997-2002 Internet Software Consortium. * diff --git a/libntp/Makefile.am b/libntp/Makefile.am index 5da1af1fd..790a8fb81 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -17,11 +17,9 @@ libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \ uglydate.c uinttoa.c ymd2yd.c \ $(srcdir)/../libisc/assertions.c $(srcdir)/../libisc/error.c \ $(srcdir)/../libisc/interfaceiter.c $(srcdir)/../libisc/lib.c \ - $(srcdir)/../libisc/log.c $(srcdir)/../libisc/md5.c \ - $(srcdir)/../libisc/mem.c $(srcdir)/../libisc/msgcat.c \ + $(srcdir)/../libisc/md5.c $(srcdir)/../libisc/msgcat.c \ $(srcdir)/../libisc/net.c $(srcdir)/../libisc/isc_strerror.c \ - $(srcdir)/../libisc/inet_ntop.c \ - $(srcdir)/../libisc/inet_pton.c \ + $(srcdir)/../libisc/inet_ntop.c $(srcdir)/../libisc/inet_pton.c \ $(srcdir)/../libisc/netaddr.c $(srcdir)/../libisc/sockaddr.c \ $(srcdir)/../libisc/netscope.c libntp_a_SOURCES = systime.c $(libntp_a_SRCS) diff --git a/libntp/machines.c b/libntp/machines.c index c8e4e07c9..481837af1 100644 --- a/libntp/machines.c +++ b/libntp/machines.c @@ -509,6 +509,9 @@ getpass(const char * prompt) } password[i] = '\0'; + fputc('\n', stderr); + fflush(stderr); + return password; } #endif /* SYS_WINNT */ diff --git a/libntp/numtoa.c b/libntp/numtoa.c index de95118af..4ec6036ec 100644 --- a/libntp/numtoa.c +++ b/libntp/numtoa.c @@ -1,6 +1,14 @@ /* * numtoa - return asciized network numbers store in local array space */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#if HAVE_NETINET_IN_H +#include /* ntohl */ +#endif + #include #include "ntp_fp.h" diff --git a/libntp/numtohost.c b/libntp/numtohost.c index dd51c5d01..e81dd42ac 100644 --- a/libntp/numtohost.c +++ b/libntp/numtohost.c @@ -2,6 +2,14 @@ * numtohost - convert network number to host name. */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#if HAVE_NETINET_IN_H +#include /* ntohl */ +#endif + #include "ntp_fp.h" #include "ntp_stdlib.h" #include "lib_strbuf.h" diff --git a/libntp/prettydate.c b/libntp/prettydate.c index 77458f00b..09f358fe5 100644 --- a/libntp/prettydate.c +++ b/libntp/prettydate.c @@ -9,6 +9,8 @@ #include "ntp_stdlib.h" #include "ntp_assert.h" +static char *common_prettydate(l_fp *, int); + const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" @@ -151,7 +153,7 @@ ntp2unix_tm( } -char * +static char * common_prettydate( l_fp *ts, int local diff --git a/libntp/statestr.c b/libntp/statestr.c index 8a051215f..b809b2028 100644 --- a/libntp/statestr.c +++ b/libntp/statestr.c @@ -82,8 +82,10 @@ struct codestring clock_codes[] = { { -1, "clk" } }; + +#ifdef FLASH_CODES_UNUSED /* - * Flash bits + * Flash bits -- see ntpq.c tstflags & tstflagnames */ static struct codestring flash_codes[] = { @@ -102,6 +104,8 @@ struct codestring flash_codes[] = { { TEST13, "peer_unreach" }, { -1, "flash" } }; +#endif + /* * System events (sys) diff --git a/libparse/parsesolaris.c b/libparse/parsesolaris.c index 32ae14444..2d499f0f6 100644 --- a/libparse/parsesolaris.c +++ b/libparse/parsesolaris.c @@ -264,7 +264,7 @@ ntp_memset( static void pprintf( int lev, - const char *form, + char *form, ... ) { @@ -273,7 +273,7 @@ pprintf( va_start(ap, form); if (lev & parsedebug) - vcmn_err(CE_CONT, (char *)form, ap); + vcmn_err(CE_CONT, form, ap); va_end(ap); } @@ -641,15 +641,15 @@ parserput( register parsestream_t * parse = (parsestream_t *)q->q_ptr; register mblk_t *nmp; register unsigned long ch; - timestamp_t ctime; + timestamp_t c_time; timespec_t hres_time; /* * get time on packet delivery */ gethrestime(&hres_time); - ctime.tv.tv_sec = hres_time.tv_sec; - ctime.tv.tv_usec = hres_time.tv_nsec / 1000; + c_time.tv.tv_sec = hres_time.tv_sec; + c_time.tv.tv_usec = hres_time.tv_nsec / 1000; if (!(parse->parse_status & PARSE_ENABLE)) { @@ -672,7 +672,7 @@ parserput( while (mp != (mblk_t *)NULL) { ch = rdchar(&mp); - if (ch != ~0 && parse_ioread(&parse->parse_io, (unsigned int)ch, &ctime)) + if (ch != ~0 && parse_ioread(&parse->parse_io, (unsigned int)ch, &c_time)) { /* * up up and away (hopefully ...) @@ -693,7 +693,7 @@ parserput( } else { - if (parse_ioread(&parse->parse_io, (unsigned int)0, &ctime)) + if (parse_ioread(&parse->parse_io, (unsigned int)0, &c_time)) { /* * up up and away (hopefully ...) @@ -723,19 +723,19 @@ parserput( case M_UNHANGUP: { register parsestream_t * parse = (parsestream_t *)q->q_ptr; - timestamp_t ctime; + timestamp_t c_time; timespec_t hres_time; register mblk_t *nmp; register int status = cd_invert ^ (type == M_UNHANGUP); gethrestime(&hres_time); - ctime.tv.tv_sec = hres_time.tv_sec; - ctime.tv.tv_usec = hres_time.tv_nsec / 1000; + c_time.tv.tv_sec = hres_time.tv_sec; + c_time.tv.tv_usec = hres_time.tv_nsec / 1000; pprintf(DD_RPUT, "parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN"); if ((parse->parse_status & PARSE_ENABLE) && - parse_iopps(&parse->parse_io, status ? SYNC_ONE : SYNC_ZERO, &ctime)) + parse_iopps(&parse->parse_io, status ? SYNC_ONE : SYNC_ZERO, &c_time)) { nmp = (mblk_t *)NULL; if (canputnext(parse->parse_queue) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED))) @@ -759,7 +759,7 @@ parserput( if (status) { - parse->parse_ppsclockev.tv = ctime.tv; + parse->parse_ppsclockev.tv = c_time.tv; ++(parse->parse_ppsclockev.serial); } } diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index bba74974e..a2bea6717 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -215,7 +215,9 @@ static void free_auth_node(void); #endif double *create_dval(double val); void destroy_restrict_node(struct restrict_node *my_node); +#if !defined(SIM) static struct sockaddr_storage *get_next_address(struct address_node *addr); +#endif static void config_other_modes(void); static void config_auth(void); @@ -372,6 +374,7 @@ void free_syntax_tree(void) { DESTROY_QUEUE(my_config.peers); + DESTROY_QUEUE(my_config.unpeers); DESTROY_QUEUE(my_config.orphan_cmds); DESTROY_QUEUE(my_config.manycastserver); @@ -805,6 +808,8 @@ create_sim_script_info( } +#if !defined(SIM) + #define ADDR_LENGTH 16 + 1 static struct sockaddr_storage * @@ -841,6 +846,7 @@ get_next_address( freeaddrinfo(ptr); return final_addr; } +#endif /* !SIM */ server_info * diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index 1ff059aac..29a4996ea 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -142,7 +142,6 @@ char *req_file; /* name of the file with configuration info */ /* end stuff to be filled in */ -static RETSIGTYPE bong (int); static void checkparent (void); static void removeentry (struct conf_entry *); static void addentry (char *, int, int, int, int, u_int, diff --git a/ntpd/ntp_parser.y b/ntpd/ntp_parser.y index 9f02427c2..1822e8806 100644 --- a/ntpd/ntp_parser.y +++ b/ntpd/ntp_parser.y @@ -395,8 +395,8 @@ unpeer_command } ; unpeer_keyword - : T_Unconfig { $$ = T_Unconfig } - | T_Unpeer { $$ = T_Unpeer } + : T_Unconfig { $$ = T_Unconfig; } + | T_Unpeer { $$ = T_Unpeer; } ; diff --git a/ntpd/ntp_refclock.c b/ntpd/ntp_refclock.c index c04813361..cd1e51f35 100644 --- a/ntpd/ntp_refclock.c +++ b/ntpd/ntp_refclock.c @@ -1215,7 +1215,7 @@ refclock_ppsapi( struct refclock_atom *ap /* atom structure pointer */ ) { - if (ap->handle == NULL) { + if (!ap->handle) { if (time_pps_create(fddev, &ap->handle) < 0) { msyslog(LOG_ERR, "refclock_atom: time_pps_create failed: %m"); @@ -1301,7 +1301,7 @@ refclock_pps( * most recent PPS timestamp. */ pp = peer->procptr; - if (ap->handle == NULL) + if (!ap->handle) return (0); if (ap->pps_params.mode == 0 && sys_leap != LEAP_NOTINSYNC) { diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c index cf11521bc..36fa10150 100644 --- a/ntpd/ntp_util.c +++ b/ntpd/ntp_util.c @@ -110,6 +110,13 @@ static double prev_drift_comp; /* last frequency update */ static int leap_file(FILE *); static void record_sys_stats(void); +/* + * Prototypes + */ +#ifdef DEBUG +void uninit_util(void); +#endif + /* * uninit_util - free memory allocated by init_util diff --git a/ntpd/ntpsim.c b/ntpd/ntpsim.c index 4556f206c..f7479313c 100644 --- a/ntpd/ntpsim.c +++ b/ntpd/ntpsim.c @@ -77,7 +77,6 @@ void create_server_associations() /* Main Simulator Code */ -int ntpsim(int argc, char *argv[]); int ntpsim(int argc, char *argv[]) { diff --git a/ntpd/refclock_mx4200.c b/ntpd/refclock_mx4200.c index d65187c44..77ccedd6c 100644 --- a/ntpd/refclock_mx4200.c +++ b/ntpd/refclock_mx4200.c @@ -961,18 +961,18 @@ mx4200_parse_t( char time_mark_valid, time_sync, op_mode; int sentence_type, valid; int year, day_of_year, month, day_of_month; - int hour, minute, second, leapsec; + int hour, minute, second, leapsec_warn; int oscillator_offset, time_mark_error, time_bias; pp = peer->procptr; up = (struct mx4200unit *)pp->unitptr; - leapsec = 0; /* Not all receivers output leap second warnings (!) */ + leapsec_warn = 0; /* Not all receivers output leap second warnings (!) */ sscanf(pp->a_lastcode, "$PMVXG,%d,%c,%d,%d,%d,%d:%d:%d,%c,%c,%d,%d,%d,%d", &sentence_type, &time_mark_valid, &year, &month, &day_of_month, &hour, &minute, &second, &time_sync, &op_mode, - &oscillator_offset, &time_mark_error, &time_bias, &leapsec); + &oscillator_offset, &time_mark_error, &time_bias, &leapsec_warn); if (sentence_type != PMVXG_D_TRECOVOUT) return ("wrong rec-type"); @@ -1005,8 +1005,8 @@ mx4200_parse_t( mx4200_debug(peer, "mx4200_parse_t: bad time %02d:%02d:%02d", hour, minute, second); - if (leapsec != 0) - mx4200_debug(peer, " (leap %+d\n)", leapsec); + if (leapsec_warn != 0) + mx4200_debug(peer, " (leap %+d\n)", leapsec_warn); mx4200_debug(peer, "\n"); refclock_report(peer, CEVNT_BADTIME); return ("bad time"); @@ -1068,7 +1068,7 @@ mx4200_parse_t( /* * Setup leap second indicator */ - switch (leapsec) { + switch (leapsec_warn) { case 0: pp->leap = LEAP_NOWARNING; break; @@ -1085,12 +1085,12 @@ mx4200_parse_t( /* * Any change to the leap second warning status? */ - if (leapsec != up->last_leap ) { + if (leapsec_warn != up->last_leap ) { msyslog(LOG_DEBUG, "mx4200: leap second warning: %d to %d (%d)", - up->last_leap, leapsec, pp->leap); + up->last_leap, leapsec_warn, pp->leap); } - up->last_leap = leapsec; + up->last_leap = leapsec_warn; /* * Copy time data for billboard monitoring. @@ -1520,14 +1520,14 @@ mx4200_pps( if (time_pps_fetch(up->pps_h, PPS_TSFMT_TSPEC, &(up->pps_i), &timeout) < 0) { mx4200_debug(peer, - "mx4200_pps: time_pps_fetch: serial=%ul, %s\n", + "mx4200_pps: time_pps_fetch: serial=%lu, %s\n", (unsigned long)up->pps_i.assert_sequence, strerror(errno)); refclock_report(peer, CEVNT_FAULT); return(1); } if (temp_serial == up->pps_i.assert_sequence) { mx4200_debug(peer, - "mx4200_pps: assert_sequence serial not incrementing: %ul\n", + "mx4200_pps: assert_sequence serial not incrementing: %lu\n", (unsigned long)up->pps_i.assert_sequence); refclock_report(peer, CEVNT_FAULT); return(1); @@ -1540,7 +1540,7 @@ mx4200_pps( if (up->pps_i.assert_sequence == up->lastserial) { mx4200_debug(peer, "mx4200_pps: no new pps event\n"); } else { - mx4200_debug(peer, "mx4200_pps: missed %ul pps events\n", + mx4200_debug(peer, "mx4200_pps: missed %lu pps events\n", up->pps_i.assert_sequence - up->lastserial - 1UL); } refclock_report(peer, CEVNT_FAULT); diff --git a/ntpd/refclock_palisade.c b/ntpd/refclock_palisade.c index d92758b55..d443c0ae6 100644 --- a/ntpd/refclock_palisade.c +++ b/ntpd/refclock_palisade.c @@ -121,6 +121,7 @@ static void praecis_parse(struct recvbuf *rbufp, struct peer *peer); * They are taken from Markus Prosch */ +#ifdef UNUSED /* * sendcmd - Build data packet for sending */ @@ -130,10 +131,11 @@ sendcmd ( int c ) { - buffer->data[0] = DLE; - buffer->data[1] = (unsigned char)c; - buffer->size = 2; + buffer->data[0] = DLE; + buffer->data[1] = (unsigned char)c; + buffer->size = 2; } +#endif /* * sendsupercmd - Build super data packet for sending diff --git a/ntpd/refclock_palisade.h b/ntpd/refclock_palisade.h index 9c2ae9272..a2b4bb7a8 100644 --- a/ntpd/refclock_palisade.h +++ b/ntpd/refclock_palisade.h @@ -189,7 +189,9 @@ short getint (u_char *); long getlong (u_char *); /* Thunderbolt specific function prototypes */ +#ifdef UNUSED static void sendcmd (struct packettx *buffer, int c); +#endif static void sendsupercmd (struct packettx *buffer, int c1, int c2); static void sendbyte (struct packettx *buffer, int b); static void sendint (struct packettx *buffer, int a); diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index 389ddffa3..5f7420085 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -256,12 +256,16 @@ static int sendpkt (char *, int); static int getresponse (int, int, u_short *, int *, char **, int); static int sendrequest (int, int, int, int, char *); static char * tstflags (u_long); +#ifndef BUILD_AS_LIB static void getcmds (void); +#ifndef SYS_WINNT static RETSIGTYPE abortcmd (int); +#endif /* SYS_WINNT */ static void docmd (const char *); static void tokenize (const char *, char **, int *); -static int findcmd (char *, struct xcmd *, struct xcmd *, struct xcmd **); static int getarg (char *, int, arg_v *); +#endif /* BUILD_AS_LIB */ +static int findcmd (char *, struct xcmd *, struct xcmd *, struct xcmd **); static int rtdatetolfp (char *, l_fp *); static int decodearr (char *, int *, l_fp *); static void help (struct parse *, FILE *); @@ -382,7 +386,7 @@ struct xcmd builtins[] = { #define MAXVARLEN 256 /* maximum length of a variable name */ #define MAXVALLEN 400 /* maximum length of a variable value */ #define MAXOUTLINE 72 /* maximum length of an output line */ -#define SCREENWIDTH 76 /* nominal screen width in columns */ +#define SCREENWIDTH 76 /* nominal screen width in columns */ /* * Some variables used and manipulated locally @@ -479,20 +483,20 @@ volatile int debug; #ifdef NO_MAIN_ALLOWED #ifndef BUILD_AS_LIB CALL(ntpq,"ntpq",ntpqmain); -#endif void clear_globals(void) { - extern int ntp_optind; - showhostnames = 0; /* don'tshow host names by default */ - ntp_optind = 0; - server_entry = NULL; /* server entry for ntp */ - havehost = 0; /* set to 1 when host open */ - numassoc = 0; /* number of cached associations */ - numcmds = 0; - numhosts = 0; + extern int ntp_optind; + showhostnames = 0; /* don'tshow host names by default */ + ntp_optind = 0; + server_entry = NULL; /* server entry for ntp */ + havehost = 0; /* set to 1 when host open */ + numassoc = 0; /* number of cached associations */ + numcmds = 0; + numhosts = 0; } -#endif +#endif /* !BUILD_AS_LIB */ +#endif /* NO_MAIN_ALLOWED */ /* * main - parse arguments and handle options @@ -621,7 +625,7 @@ ntpqmain( ADDHOST(DEFHOST); } else { for (; ntp_optind < argc; ntp_optind++) - ADDHOST(argv[ntp_optind]); + ADDHOST(argv[ntp_optind]); } if (numcmds == 0 && interactive == 0 @@ -643,8 +647,8 @@ ntpqmain( for (ihost = 0; ihost < numhosts; ihost++) { if (openhost(chosts[ihost])) - for (icmd = 0; icmd < numcmds; icmd++) - docmd(ccmds[icmd]); + for (icmd = 0; icmd < numcmds; icmd++) + docmd(ccmds[icmd]); } } #ifdef SYS_WINNT @@ -652,7 +656,7 @@ ntpqmain( #endif /* SYS_WINNT */ return 0; } -#endif // build as lib +#endif /* !BUILD_AS_LIB */ /* * openhost - open a socket to a host @@ -724,21 +728,21 @@ openhost( } if (ai->ai_canonname == NULL) { - strncpy(temphost, stoa((struct sockaddr_storage *)ai->ai_addr), - LENHOSTNAME); - temphost[LENHOSTNAME-1] = '\0'; + strncpy(temphost, + stoa((struct sockaddr_storage *)ai->ai_addr), + LENHOSTNAME); } else { strncpy(temphost, ai->ai_canonname, LENHOSTNAME); - temphost[LENHOSTNAME-1] = '\0'; } + temphost[LENHOSTNAME-1] = '\0'; if (debug > 2) - printf("Opening host %s\n", temphost); + printf("Opening host %s\n", temphost); if (havehost == 1) { if (debug > 2) - printf("Closing old host %s\n", currenthost); + printf("Closing old host %s\n", currenthost); (void) closesocket(sockfd); havehost = 0; } @@ -761,9 +765,13 @@ openhost( int optionValue = SO_SYNCHRONOUS_NONALERT; int err; - err = setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&optionValue, sizeof(optionValue)); - if (err != NO_ERROR) { - (void) fprintf(stderr, "cannot open nonoverlapped sockets\n"); + err = setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, + (char *)&optionValue, sizeof(optionValue)); + if (err) { + err = WSAGetLastError(); + fprintf(stderr, + "setsockopt(SO_SYNCHRONOUS_NONALERT) " + "error: %s\n", strerror(err)); exit(1); } } @@ -1440,6 +1448,7 @@ doquery( } +#ifndef BUILD_AS_LIB /* * getcmds - read commands from the standard input and execute them */ @@ -1447,35 +1456,36 @@ static void getcmds(void) { #if defined(HAVE_LIBREADLINE) - char *line; - - for (;;) { - if ((line = readline(interactive?prompt:"")) == NULL) return; - if (*line) add_history(line); - docmd(line); - free(line); - } + char *line; + + for (;;) { + if ((line = readline(interactive?prompt:"")) == NULL) return; + if (*line) add_history(line); + docmd(line); + free(line); + } #else /* not (HAVE_LIBREADLINE) */ - char line[MAXLINE]; + char line[MAXLINE]; - for (;;) { - if (interactive) { -#ifdef VMS /* work around a problem with mixing stdout & stderr */ - fputs("",stdout); + for (;;) { + if (interactive) { +#ifdef VMS /* work around a problem with mixing stdout & stderr */ + fputs("",stdout); #endif - (void) fputs(prompt, stderr); - (void) fflush(stderr); - } + (void) fputs(prompt, stderr); + (void) fflush(stderr); + } - if (fgets(line, sizeof line, stdin) == NULL) - return; + if (fgets(line, sizeof line, stdin) == NULL) + return; - docmd(line); - } + docmd(line); + } #endif /* not (HAVE_LIBREADLINE || HAVE_LIBEDIT) */ } +#endif /* !BUILD_AS_LIB */ -#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */ +#if !defined(SYS_WINNT) && !defined(BUILD_AS_LIB) /* * abortcmd - catch interrupts and abort the current command */ @@ -1490,8 +1500,10 @@ abortcmd( (void) fflush(stderr); if (jump) longjmp(interrupt_buf, 1); } -#endif /* SYS_WINNT */ +#endif /* !SYS_WINNT && !BUILD_AS_LIB */ + +#ifndef BUILD_AS_LIB /* * docmd - decode the command line and execute a command */ @@ -1542,9 +1554,9 @@ docmd( break; } if ((xcmd->arg[i] & OPT) && (*tokens[i+1] == '>')) - break; + break; if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i])) - return; + return; pcmd.nargs++; } @@ -1553,9 +1565,9 @@ docmd( char *fname; if (*(tokens[i]+1) != '\0') - fname = tokens[i]+1; + fname = tokens[i]+1; else if ((i+1) < ntok) - fname = tokens[i+1]; + fname = tokens[i+1]; else { (void) fprintf(stderr, "***No file for redirect\n"); return; @@ -1632,88 +1644,21 @@ tokenize( * If yes, continue reading till the next double quote */ else if (*cp == '\"') { - ++cp; - do { - *sp++ = *cp++; - } while ((*cp != '\"') && !ISEOL(*cp)); - /* HMS: a missing closing " should be an error */ - } - else { - do { - *sp++ = *cp++; - } while ((*cp != '\"') && !ISSPACE(*cp) && !ISEOL(*cp)); - /* HMS: Why check for a " in the previous line? */ - } - - *sp++ = '\0'; - } -} - - -/* - * findcmd - find a command in a command description table - */ -static int -findcmd( - register char *str, - struct xcmd *clist1, - struct xcmd *clist2, - struct xcmd **cmd - ) -{ - register struct xcmd *cl; - register int clen; - int nmatch; - struct xcmd *nearmatch = NULL; - struct xcmd *clist; - - clen = strlen(str); - nmatch = 0; - if (clist1 != 0) - clist = clist1; - else if (clist2 != 0) - clist = clist2; - else - return 0; - - again: - for (cl = clist; cl->keyword != 0; cl++) { - /* do a first character check, for efficiency */ - if (*str != *(cl->keyword)) - continue; - if (strncmp(str, cl->keyword, (unsigned)clen) == 0) { - /* - * Could be extact match, could be approximate. - * Is exact if the length of the keyword is the - * same as the str. - */ - if (*((cl->keyword) + clen) == '\0') { - *cmd = cl; - return 1; - } - nmatch++; - nearmatch = cl; + ++cp; + do { + *sp++ = *cp++; + } while ((*cp != '\"') && !ISEOL(*cp)); + /* HMS: a missing closing " should be an error */ + } + else { + do { + *sp++ = *cp++; + } while ((*cp != '\"') && !ISSPACE(*cp) && !ISEOL(*cp)); + /* HMS: Why check for a " in the previous line? */ } - } - - /* - * See if there is more to do. If so, go again. Sorry about the - * goto, too much looking at BSD sources... - */ - if (clist == clist1 && clist2 != 0) { - clist = clist2; - goto again; - } - /* - * If we got extactly 1 near match, use it, else return number - * of matches. - */ - if (nmatch == 1) { - *cmd = nearmatch; - return 1; + *sp++ = '\0'; } - return nmatch; } @@ -1807,6 +1752,74 @@ getarg( return 1; } +#endif /* !BUILD_AS_LIB */ + + +/* + * findcmd - find a command in a command description table + */ +static int +findcmd( + register char *str, + struct xcmd *clist1, + struct xcmd *clist2, + struct xcmd **cmd + ) +{ + register struct xcmd *cl; + register int clen; + int nmatch; + struct xcmd *nearmatch = NULL; + struct xcmd *clist; + + clen = strlen(str); + nmatch = 0; + if (clist1 != 0) + clist = clist1; + else if (clist2 != 0) + clist = clist2; + else + return 0; + + again: + for (cl = clist; cl->keyword != 0; cl++) { + /* do a first character check, for efficiency */ + if (*str != *(cl->keyword)) + continue; + if (strncmp(str, cl->keyword, (unsigned)clen) == 0) { + /* + * Could be extact match, could be approximate. + * Is exact if the length of the keyword is the + * same as the str. + */ + if (*((cl->keyword) + clen) == '\0') { + *cmd = cl; + return 1; + } + nmatch++; + nearmatch = cl; + } + } + + /* + * See if there is more to do. If so, go again. Sorry about the + * goto, too much looking at BSD sources... + */ + if (clist == clist1 && clist2 != 0) { + clist = clist2; + goto again; + } + + /* + * If we got extactly 1 near match, use it, else return number + * of matches. + */ + if (nmatch == 1) { + *cmd = nearmatch; + return 1; + } + return nmatch; +} /* @@ -1863,10 +1876,11 @@ nntohost( ) { if (!showhostnames) - return stoa(netnum); - if ((netnum->ss_family == AF_INET) && ISREFCLOCKADR(netnum)) - return refnumtoa(netnum); - return socktohost(netnum); + return stoa(netnum); + else if ((netnum->ss_family == AF_INET) && ISREFCLOCKADR(netnum)) + return refnumtoa(netnum); + else + return socktohost(netnum); } @@ -2010,7 +2024,7 @@ decodets( * If it starts with a 0x, decode as hex. */ if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X')) - return hextolfp(str+2, lfp); + return hextolfp(str+2, lfp); /* * If it starts with a '"', try it as an RT-11 date. @@ -2022,7 +2036,7 @@ decodets( bp = buf; while (*cp != '"' && *cp != '\0' && bp < &buf[29]) - *bp++ = *cp++; + *bp++ = *cp++; *bp = '\0'; return rtdatetolfp(buf, lfp); } @@ -2032,14 +2046,15 @@ decodets( * about heuristics! */ if ((*str >= 'A' && *str <= 'F') || (*str >= 'a' && *str <= 'f')) - return hextolfp(str, lfp); + return hextolfp(str, lfp); /* * Try it as a decimal. If this fails, try as an unquoted * RT-11 date. This code should go away eventually. */ if (atolfp(str, lfp)) - return 1; + return 1; + return rtdatetolfp(str, lfp); } @@ -2144,21 +2159,21 @@ help( FILE *fp ) { - struct xcmd *xcp; + struct xcmd *xcp = NULL; /* quiet warning */ char *cmd; const char *list[100]; - int word, words; - int row, rows; - int col, cols; + int word, words; + int row, rows; + int col, cols; if (pcmd->nargs == 0) { words = 0; for (xcp = builtins; xcp->keyword != 0; xcp++) { if (*(xcp->keyword) != '?') - list[words++] = xcp->keyword; + list[words++] = xcp->keyword; } for (xcp = opcmds; xcp->keyword != 0; xcp++) - list[words++] = xcp->keyword; + list[words++] = xcp->keyword; qsort( #ifdef QSORT_USES_VOID_P @@ -2171,21 +2186,22 @@ help( for (word = 0; word < words; word++) { int length = strlen(list[word]); if (col < length) { - col = length; - } + col = length; + } } cols = SCREENWIDTH / ++col; - rows = (words + cols - 1) / cols; + rows = (words + cols - 1) / cols; (void) fprintf(fp, "ntpq commands:\n"); for (row = 0; row < rows; row++) { - for (word = row; word < words; word += rows) { - (void) fprintf(fp, "%-*.*s", col, col-1, list[word]); - } - (void) fprintf(fp, "\n"); - } + for (word = row; word < words; word += rows) { + (void) fprintf(fp, "%-*.*s", col, + col-1, list[word]); + } + (void) fprintf(fp, "\n"); + } } else { cmd = pcmd->argval[0].string; words = findcmd(cmd, builtins, opcmds, &xcp); @@ -2322,9 +2338,10 @@ host( if (pcmd->nargs == 0) { if (havehost) - (void) fprintf(fp, "current host is %s\n", currenthost); + (void) fprintf(fp, "current host is %s\n", + currenthost); else - (void) fprintf(fp, "no current host\n"); + (void) fprintf(fp, "no current host\n"); return; } @@ -2338,7 +2355,8 @@ host( else { if (havehost) (void) fprintf(fp, - "current host remains %s\n", currenthost); + "current host remains %s\n", + currenthost); else (void) fprintf(fp, "still no current host\n"); return; @@ -2350,10 +2368,11 @@ host( numassoc = 0; } else { if (havehost) - (void) fprintf(fp, - "current host remains %s\n", currenthost); + (void) fprintf(fp, + "current host remains %s\n", + currenthost); else - (void) fprintf(fp, "still no current host\n"); + (void) fprintf(fp, "still no current host\n"); } } @@ -2442,10 +2461,10 @@ passwd( } pass = getpass("MD5 Password: "); if (*pass == '\0') - (void) fprintf(fp, "Password unchanged\n"); + (void) fprintf(fp, "Password unchanged\n"); else { - authusekey(info_auth_keyid, info_auth_keytype, (u_char *)pass); - authtrust(info_auth_keyid, 1); + authusekey(info_auth_keyid, info_auth_keytype, (u_char *)pass); + authtrust(info_auth_keyid, 1); } } @@ -3365,9 +3384,9 @@ assoccmp( const struct association *ass2 = (const struct association *)t2; if (ass1->assid < ass2->assid) - return -1; + return -1; if (ass1->assid > ass2->assid) - return 1; + return 1; return 0; } #else diff --git a/parseutil/dcfd.c b/parseutil/dcfd.c index d08668373..449d24fba 100644 --- a/parseutil/dcfd.c +++ b/parseutil/dcfd.c @@ -185,7 +185,7 @@ static char pat[] = "-\\|/"; #define R_SHIFT(_X_, _Y_) (((_X_) < 0) ? -(-(_X_) >> (_Y_)) : ((_X_) >> (_Y_))) -static struct timeval max_adj_offset = { 0, 128000 }; +static long max_adj_offset_usec = 128000; static long clock_adjust = 0; /* current adjustment value (usec * 2^USECSCALE) */ static long accum_drift = 0; /* accumulated drift value (usec / ADJINTERVAL) */ @@ -195,8 +195,8 @@ static char skip_adjust = 1; /* discard first adjustment (bad samples) */ /* * DCF77 state flags */ -#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ -#define DCFB_DST 0x0002 /* DST in effect */ +#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */ +#define DCFB_DST 0x0002 /* DST in effect */ #define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */ #define DCFB_ALTERNATE 0x0008 /* alternate antenna used */ @@ -1042,7 +1042,8 @@ adjust_clock( toffset = *offset; toffset.tv_sec = l_abs(toffset.tv_sec); toffset.tv_usec = l_abs(toffset.tv_usec); - if (timercmp(&toffset, &max_adj_offset, >)) + if (toffset.tvsec || + (!toffset.tv_sec && toffset.tv_usec > max_adj_offset_usec)) { /* * hopeless - set the clock - and clear the timing diff --git a/ports/winnt/libntp/libntp.vcproj b/ports/winnt/libntp/libntp.vcproj index b61634ae9..53f637ac3 100644 --- a/ports/winnt/libntp/libntp.vcproj +++ b/ports/winnt/libntp/libntp.vcproj @@ -1033,28 +1033,6 @@ RelativePath="..\..\..\libisc\md5.c" > - - - - - - - - diff --git a/ports/winnt/ntpd/ntpd.vcproj b/ports/winnt/ntpd/ntpd.vcproj index 6290f75a3..68f4116ba 100644 --- a/ports/winnt/ntpd/ntpd.vcproj +++ b/ports/winnt/ntpd/ntpd.vcproj @@ -937,6 +937,10 @@ RelativePath="..\..\..\include\ntpd.h" > + + diff --git a/ports/winnt/ntpd/ntservice.c b/ports/winnt/ntpd/ntservice.c index 2624711ab..34b8693a4 100644 --- a/ports/winnt/ntpd/ntservice.c +++ b/ports/winnt/ntpd/ntservice.c @@ -148,7 +148,7 @@ ntservice_init() { SetConsoleTitle(ConsoleTitle); } - #ifdef _DEBUG + #if defined(_MSC_VER) && defined(_DEBUG) /* ask the runtime to dump memory leaks at exit */ _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #ifdef WANT_LEAK_CHECK_ON_STDERR_TOO @@ -158,7 +158,7 @@ ntservice_init() { /* the file being stderr */ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); #endif - #endif /* _DEBUG */ + #endif /* _MSC_VER && _DEBUG */ atexit( ntservice_exit ); } @@ -190,7 +190,7 @@ ntservice_exit( void ) msyslog(LOG_INFO, "ntservice: The Network Time Protocol Service is stopping."); -#ifdef _DEBUG +#ifdef DEBUG FormatErrorFreeMem(); #endif @@ -229,7 +229,7 @@ ServiceControl(DWORD dwCtrlCode) { case SERVICE_CONTROL_PAUSE: case SERVICE_CONTROL_CONTINUE: case SERVICE_CONTROL_INTERROGATE: - default: + default: break; } UpdateSCM(SERVICE_RUNNING); @@ -301,6 +301,6 @@ OnConsoleEvent( } /* we've handled it, no more handlers should be called */ - return TRUE;; + return TRUE; } diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c index 787cf4d7c..243af4e04 100644 --- a/util/ntp-keygen.c +++ b/util/ntp-keygen.c @@ -295,16 +295,16 @@ main( #ifdef OPENSSL passwd1 = hostbuf; if (HAVE_OPT( PVT_PASSWD )) - passwd1 = OPT_ARG( PVT_PASSWD ); + passwd1 = strdup(OPT_ARG( PVT_PASSWD )); if (HAVE_OPT( GET_PVT_PASSWD )) - passwd2 = OPT_ARG( GET_PVT_PASSWD ); + passwd2 = strdup(OPT_ARG( GET_PVT_PASSWD )); if (HAVE_OPT( HOST_KEY )) hostkey++; if (HAVE_OPT( SIGN_KEY )) - sign = OPT_ARG( SIGN_KEY ); + sign = strdup(OPT_ARG( SIGN_KEY )); if (HAVE_OPT( GQ_PARAMS )) gqkey++; @@ -327,10 +327,10 @@ main( scheme = OPT_ARG( CERTIFICATE ); if (HAVE_OPT( SUBJECT_NAME )) - hostname = OPT_ARG( SUBJECT_NAME ); + hostname = strdup(OPT_ARG( SUBJECT_NAME )); if (HAVE_OPT( ISSUER_NAME )) - groupname = OPT_ARG( ISSUER_NAME ); + groupname = strdup(OPT_ARG( ISSUER_NAME )); if (HAVE_OPT( PVT_CERT )) exten = EXT_KEY_PRIVATE; @@ -716,7 +716,7 @@ gen_md5( int i, j; str = fheader("MD5key", id, groupname); - ntp_srandom(epoch); + ntp_srandom((u_long)epoch); for (i = 1; i <= MD5KEYS; i++) { for (j = 0; j < 16; j++) { int temp; @@ -1825,7 +1825,7 @@ x509 ( cert = X509_new(); X509_set_version(cert, 2L); serial = ASN1_INTEGER_new(); - ASN1_INTEGER_set(serial, epoch + JAN_1970); + ASN1_INTEGER_set(serial, (long)epoch + JAN_1970); X509_set_serialNumber(cert, serial); ASN1_INTEGER_free(serial); X509_time_adj(X509_get_notBefore(cert), 0L, &epoch);