diff --git a/CHANGES b/CHANGES index 519aad60d6..5cdf4dbf10 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2216. [cleanup] Fix a number of errors reported by Coverity. + [RT #17094] + 2215. [bug] Bad REQUIRE check isc_hmacsha1_verify(). [RT #17094] 2214. [bug] Deregister OpenSSL lock callback when cleaning diff --git a/lib/bind/dst/dst_api.c b/lib/bind/dst/dst_api.c index d08570cd69..d3976ef543 100644 --- a/lib/bind/dst/dst_api.c +++ b/lib/bind/dst/dst_api.c @@ -1,5 +1,5 @@ #ifndef LINT -static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.15 2006/03/09 23:57:56 marka Exp $"; +static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.16 2007/08/27 03:32:26 marka Exp $"; #endif /* @@ -359,7 +359,7 @@ dst_read_key(const char *in_keyname, const u_int16_t in_id, pubkey->dk_alg) == 0) dg_key = dst_free_key(dg_key); - pubkey = dst_free_key(pubkey); + (void)dst_free_key(pubkey); return (dg_key); } diff --git a/lib/bind/irs/gai_strerror.c b/lib/bind/irs/gai_strerror.c index 90e90cdd15..9ca1c4bfe1 100644 --- a/lib/bind/irs/gai_strerror.c +++ b/lib/bind/irs/gai_strerror.c @@ -69,7 +69,7 @@ gai_strerror(int ecode) { goto unknown; if (!once) { if (pthread_key_create(&key, free) != 0) { - pthread_mutex_unlock(&lock); + (void)pthread_mutex_unlock(&lock); goto unknown; } once = 1; diff --git a/lib/bind/irs/irs_data.c b/lib/bind/irs/irs_data.c index a3e776a60e..cd8ba00c50 100644 --- a/lib/bind/irs/irs_data.c +++ b/lib/bind/irs/irs_data.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: irs_data.c,v 1.11 2007/02/25 23:46:58 marka Exp $"; +static const char rcsid[] = "$Id: irs_data.c,v 1.12 2007/08/27 03:32:26 marka Exp $"; #endif #include "port_before.h" @@ -133,7 +133,7 @@ net_data_init(const char *conf_file) { return (NULL); if (!once) { if (pthread_key_create(&key, net_data_destroy) != 0) { - pthread_mutex_unlock(&keylock); + (void)pthread_mutex_unlock(&keylock); return (NULL); } once = 1; diff --git a/lib/bind/nameser/ns_parse.c b/lib/bind/nameser/ns_parse.c index a6dbb20761..09b19f861c 100644 --- a/lib/bind/nameser/ns_parse.c +++ b/lib/bind/nameser/ns_parse.c @@ -16,7 +16,7 @@ */ #ifndef lint -static const char rcsid[] = "$Id: ns_parse.c,v 1.8 2005/10/11 00:10:15 marka Exp $"; +static const char rcsid[] = "$Id: ns_parse.c,v 1.9 2007/08/27 03:32:26 marka Exp $"; #endif /* Import. */ @@ -40,7 +40,7 @@ static void setsection(ns_msg *msg, ns_sect sect); /* Macros. */ -#ifndef SOLARIS2 +#if !defined(SOLARIS2) || defined(__COVERITY__) #define RETERR(err) do { errno = (err); return (-1); } while (0) #else #define RETERR(err) \ diff --git a/lib/dns/master.c b/lib/dns/master.c index 84e946a23a..432d927815 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.c,v 1.165 2007/06/18 23:47:40 tbox Exp $ */ +/* $Id: master.c,v 1.166 2007/08/27 03:32:26 marka Exp $ */ /*! \file */ @@ -2349,8 +2349,7 @@ dns_master_loadfile2(const char *master_file, dns_name_t *top, INSIST(result != DNS_R_CONTINUE); cleanup: - if (lctx != NULL) - dns_loadctx_detach(&lctx); + dns_loadctx_detach(&lctx); return (result); } @@ -2397,8 +2396,7 @@ dns_master_loadfileinc2(const char *master_file, dns_name_t *top, } cleanup: - if (lctx != NULL) - dns_loadctx_detach(&lctx); + dns_loadctx_detach(&lctx); return (result); } @@ -2492,8 +2490,7 @@ dns_master_loadbuffer(isc_buffer_t *buffer, dns_name_t *top, INSIST(result != DNS_R_CONTINUE); cleanup: - if (lctx != NULL) - dns_loadctx_detach(&lctx); + dns_loadctx_detach(&lctx); return (result); } @@ -2529,8 +2526,7 @@ dns_master_loadbufferinc(isc_buffer_t *buffer, dns_name_t *top, } cleanup: - if (lctx != NULL) - dns_loadctx_detach(&lctx); + dns_loadctx_detach(&lctx); return (result); } diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index 3a1c0ee86d..24aff3fa01 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sdb.c,v 1.58 2007/06/18 23:47:41 tbox Exp $ */ +/* $Id: sdb.c,v 1.59 2007/08/27 03:32:27 marka Exp $ */ /*! \file */ @@ -121,6 +121,10 @@ typedef struct sdb_rdatasetiter { /* This is a reasonable value */ #define SDB_DEFAULT_TTL (60 * 60 * 24) +#ifdef __COVERITY__ +#define MAYBE_LOCK(sdb) LOCK(&sdb->implementation->driverlock) +#define MAYBE_UNLOCK(sdb) UNLOCK(&sdb->implementation->driverlock) +#else #define MAYBE_LOCK(sdb) \ do { \ unsigned int flags = sdb->implementation->flags; \ @@ -134,6 +138,7 @@ typedef struct sdb_rdatasetiter { if ((flags & DNS_SDBFLAG_THREADSAFE) == 0) \ UNLOCK(&sdb->implementation->driverlock); \ } while (0) +#endif static int dummy; diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 314d0e16d6..627ea2e193 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -50,7 +50,7 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sdlz.c,v 1.13 2007/06/18 23:47:41 tbox Exp $ */ +/* $Id: sdlz.c,v 1.14 2007/08/27 03:32:27 marka Exp $ */ /*! \file */ @@ -166,6 +166,10 @@ typedef struct sdlz_rdatasetiter { static int dummy; +#ifdef __COVERITY__ +#define MAYBE_LOCK(imp) LOCK(&imp->driverlock) +#define MAYBE_UNLOCK(imp) UNLOCK(&imp->driverlock) +#else #define MAYBE_LOCK(imp) \ do { \ unsigned int flags = imp->flags; \ @@ -179,6 +183,7 @@ static int dummy; if ((flags & DNS_SDLZFLAG_THREADSAFE) == 0) \ UNLOCK(&imp->driverlock); \ } while (0) +#endif /* * Forward references. Try to keep these to a minimum. diff --git a/lib/dns/zone.c b/lib/dns/zone.c index d12895edd6..d614b6333c 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.465 2007/06/18 23:47:42 tbox Exp $ */ +/* $Id: zone.c,v 1.466 2007/08/27 03:32:27 marka Exp $ */ /*! \file */ @@ -5565,7 +5565,6 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags, REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(messagep != NULL && *messagep == NULL); - message = NULL; result = dns_message_create(zone->mctx, DNS_MESSAGE_INTENTRENDER, &message); if (result != ISC_R_SUCCESS) @@ -5692,8 +5691,7 @@ notify_createmessage(dns_zone_t *zone, unsigned int flags, dns_message_puttempname(message, &tempname); if (temprdataset != NULL) dns_message_puttemprdataset(message, &temprdataset); - if (message != NULL) - dns_message_destroy(&message); + dns_message_destroy(&message); return (result); } diff --git a/lib/isc/httpd.c b/lib/isc/httpd.c index dfdf112288..fe0beba12d 100644 --- a/lib/isc/httpd.c +++ b/lib/isc/httpd.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: httpd.c,v 1.10 2007/06/18 23:47:44 tbox Exp $ */ +/* $Id: httpd.c,v 1.11 2007/08/27 03:32:27 marka Exp $ */ /*! \file */ @@ -257,7 +257,11 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task, if (httpd == NULL) return (ISC_R_NOMEMORY); - isc_mutex_init(&httpd->lock); + result = isc_mutex_init(&httpd->lock); + if (result != ISC_R_SUCCESS) { + isc_mem_put(mctx, httpd, sizeof(isc_httpdmgr_t)); + return (result); + } httpd->mctx = NULL; isc_mem_attach(mctx, &httpd->mctx); httpd->sock = NULL; @@ -274,6 +278,10 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task, result = isc_socket_accept(sock, task, isc_httpd_accept, httpd); if (result != ISC_R_SUCCESS) { + isc_task_detach(&httpd->task); + isc_socket_detach(&httpd->sock); + isc_mem_detach(&httpd->mctx); + isc_mutex_destroy(&httpd->lock); isc_mem_put(mctx, httpd, sizeof(isc_httpdmgr_t)); return (result); }