From: Dave Hart Date: Sun, 3 Apr 2011 19:25:33 +0000 (+0000) Subject: Cleanup a few Coverity static analysis warnings. X-Git-Tag: NTP_4_2_7P145~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1ab57a030447435f3d6dcc35ef60ae601b4f3b2;p=thirdparty%2Fntp.git Cleanup a few Coverity static analysis warnings. bk: 4d98c9adNbJZ847uPe6pAZv0X-JCXw --- diff --git a/include/ntp_config.h b/include/ntp_config.h index f16ec2b30..efd7f9a03 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -289,8 +289,9 @@ typedef struct settrap_parms_tag { const char * token_name(int token); /* generic fifo routines for structs linked by 1st member */ -void *append_gen_fifo(void *fifo, void *entry); -void *concat_gen_fifos(void *first, void *second); +void check_gen_fifo_consistency(void *fifo); +void* append_gen_fifo(void *fifo, void *entry); +void * concat_gen_fifos(void *first, void *second); #define APPEND_G_FIFO(pf, pe) \ ((pf) = append_gen_fifo((pf), (pe))) #define CONCAT_G_FIFOS(first, second) \ diff --git a/lib/isc/task.c b/lib/isc/task.c index 73817af90..0b6d297fc 100644 --- a/lib/isc/task.c +++ b/lib/isc/task.c @@ -1024,8 +1024,8 @@ manager_free(isc_taskmgr_t *manager) { (void)isc_condition_destroy(&manager->work_available); isc_mem_free(manager->mctx, manager->threads); #endif /* ISC_PLATFORM_USETHREADS */ - DESTROYLOCK(&manager->lock); manager->magic = 0; + DESTROYLOCK(&manager->lock); mctx = manager->mctx; isc_mem_put(mctx, manager, sizeof(*manager)); isc_mem_detach(&mctx); diff --git a/libntp/audio.c b/libntp/audio.c index 6fca793f1..9a3e9cf3e 100644 --- a/libntp/audio.c +++ b/libntp/audio.c @@ -175,19 +175,19 @@ audio_config_read( continue; if (!strncmp(cc, "IDEV", (size_t) 4)) { - sscanf(ca, "%s", ab); + sscanf(ca, "%99s", ab); strncpy(cf_i_dev, ab, sizeof(cf_i_dev)); printf("idev <%s>\n", ab); } else if (!strncmp(cc, "CDEV", (size_t) 4)) { - sscanf(ca, "%s", ab); + sscanf(ca, "%99s", ab); strncpy(cf_c_dev, ab, sizeof(cf_c_dev)); printf("cdev <%s>\n", ab); } else if (!strncmp(cc, "AGC", (size_t) 3)) { - sscanf(ca, "%s", ab); + sscanf(ca, "%99s", ab); strncpy(cf_agc, ab, sizeof(cf_agc)); printf("agc <%s> %d\n", ab, i); } else if (!strncmp(cc, "MONITOR", (size_t) 7)) { - sscanf(ca, "%s", ab); + sscanf(ca, "%99s", ab); strncpy(cf_monitor, ab, sizeof(cf_monitor)); printf("monitor <%s> %d\n", ab, mixer_name(ab, -1)); } diff --git a/libntp/work_thread.c b/libntp/work_thread.c index 622a0ab49..532fafc94 100644 --- a/libntp/work_thread.c +++ b/libntp/work_thread.c @@ -204,9 +204,9 @@ send_blocking_req_internal( { blocking_pipe_header * threadcopy; - DEBUG_REQUIRE(hdr != NULL); - DEBUG_REQUIRE(hdr->octets > sizeof(*hdr)); - DEBUG_REQUIRE(data != NULL); + REQUIRE(hdr != NULL); + REQUIRE(hdr->octets > sizeof(*hdr)); + REQUIRE(data != NULL); DEBUG_REQUIRE(BLOCKING_REQ_MAGIC == hdr->magic_sig); ensure_workitems_empty_slot(c); diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index f23ade358..c633713a9 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -956,13 +956,13 @@ dump_config_tree( /* generic fifo routines for structs linked by 1st member */ #ifdef NTP_DEBUG_LISTS_H void -check_gen_fifo_consistency(void *pfv) +check_gen_fifo_consistency(void *fifo) { gen_fifo *pf; gen_node *pthis; gen_node **pptail; - pf = pfv; + pf = fifo; REQUIRE((NULL == pf->phead && NULL == pf->pptail) || (NULL != pf->phead && NULL != pf->pptail)); diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c index 3ac7d1e14..fdb0c71ff 100644 --- a/ntpd/refclock_nmea.c +++ b/ntpd/refclock_nmea.c @@ -359,7 +359,7 @@ nmea_start( * * ln -s server:port /dev/gps1 */ - char buffer[80]; + char buffer[PATH_MAX]; char *nmea_host, *nmea_tail; u_long nmea_port; int len; @@ -367,14 +367,15 @@ nmea_start( struct addrinfo *ai; int rc; - if ((len = readlink(device,buffer,sizeof(buffer))) == -1) - return(0); - buffer[len] = 0; + len = readlink(device, buffer, sizeof(buffer) - 1); + if (-1 == len) + return 0; + buffer[len] = '\0'; if ((nmea_host = strtok(buffer,":")) == NULL) - return(0); + return 0; if ((nmea_tail = strtok(NULL,":")) == NULL) - return(0); + return 0; if (!atouint(nmea_tail, &nmea_port) || nmea_port > USHRT_MAX) return 0; @@ -399,6 +400,7 @@ nmea_start( freeaddrinfo(ai); return 0; } + /* blocking connect also naughty, see above. */ rc = connect(fd, ai->ai_addr, ai->ai_addrlen); freeaddrinfo(ai); if (-1 == rc) {