]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2216. [cleanup] Fix a number of errors reported by Coverity.
authorMark Andrews <marka@isc.org>
Mon, 27 Aug 2007 03:32:27 +0000 (03:32 +0000)
committerMark Andrews <marka@isc.org>
Mon, 27 Aug 2007 03:32:27 +0000 (03:32 +0000)
                        [RT #17094]

CHANGES
lib/bind/dst/dst_api.c
lib/bind/irs/gai_strerror.c
lib/bind/irs/irs_data.c
lib/bind/nameser/ns_parse.c
lib/dns/master.c
lib/dns/sdb.c
lib/dns/sdlz.c
lib/dns/zone.c
lib/isc/httpd.c

diff --git a/CHANGES b/CHANGES
index 519aad60d66bcc816eb932fadee5d367900bfe4a..5cdf4dbf107742523af02adade29e08b3ce1691b 100644 (file)
--- 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
index d08570cd69c9b3d9088f1f89e43b2bccb33a601e..d3976ef543d0d63491eb641060544b51b5fced01 100644 (file)
@@ -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);
 }
 
index 90e90cdd154a98103e9e5bfd0cd3ca7c88ae6472..9ca1c4bfe1d9eb03e91b464784c53dc76bdf2eda 100644 (file)
@@ -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;
index a3e776a60e7d6e8016d5501f5fcb94cbc0aa0efe..cd8ba00c500349c994ea3bacdea4215f053efc48 100644 (file)
@@ -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;
index a6dbb207612ccbb0c597fb9deeffe3dd903af174..09b19f861c97b89170708277a2ce6902106e995d 100644 (file)
@@ -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) \
index 84e946a23a762a5d6e0ce7b014c4982465cacdb7..432d92781554ab5cd4e7928643794bcd548daa78 100644 (file)
@@ -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);
 }
 
index 3a1c0ee86dc3ef8057bbcc2fcad6260e9eab0e95..24aff3fa01ff2a4dd98ee2fdf08ade77ac607425 100644 (file)
@@ -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;
 
index 314d0e16d6b94fe2cadbf7b64715ae131205074b..627ea2e1934e757058eb738cc69dc5e7c263792f 100644 (file)
@@ -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.
index d12895edd6ae09b03151d078bc53f8f1e65f7f9b..d614b6333c38c638d53f18e44adf93079b69d5fd 100644 (file)
@@ -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);
 }
 
index dfdf112288d212c87279e7428ae696be8bc9e205..fe0beba12d96e483b2e3cb4651096ad0b8d0427d 100644 (file)
@@ -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);
        }