qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject svn commit: r1664472 - in /qpid/dispatch/trunk: router/src/main.c src/container.c src/dispatch.c src/parse.c src/posix/driver.c src/router_config.c src/server.c
Date Thu, 05 Mar 2015 20:21:56 GMT
Author: kgiusti
Date: Thu Mar  5 20:21:55 2015
New Revision: 1664472

URL: http://svn.apache.org/r1664472
Log:
NO-JIRA: minor cleanups for issues raised by Coverity Scan

Modified:
    qpid/dispatch/trunk/router/src/main.c
    qpid/dispatch/trunk/src/container.c
    qpid/dispatch/trunk/src/dispatch.c
    qpid/dispatch/trunk/src/parse.c
    qpid/dispatch/trunk/src/posix/driver.c
    qpid/dispatch/trunk/src/router_config.c
    qpid/dispatch/trunk/src/server.c

Modified: qpid/dispatch/trunk/router/src/main.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/router/src/main.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/router/src/main.c (original)
+++ qpid/dispatch/trunk/router/src/main.c Thu Mar  5 20:21:55 2015
@@ -65,6 +65,7 @@ static void server_signal_handler(void*
     switch (signum) {
     case SIGINT:
         exit_with_sigint = 1;
+        // fallthrough
 
     case SIGQUIT:
     case SIGTERM:

Modified: qpid/dispatch/trunk/src/container.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/container.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/container.c (original)
+++ qpid/dispatch/trunk/src/container.c Thu Mar  5 20:21:55 2015
@@ -269,12 +269,13 @@ static int close_handler(void* unused, p
     pn_link_t *pn_link = pn_link_head(conn, PN_LOCAL_ACTIVE);
     while (pn_link) {
         qd_link_t *link = (qd_link_t*) pn_link_get_context(pn_link);
-        pn_link_t *link_to_free;
-        qd_node_t *node = link->node;
-        if (node && link)
-            node->ntype->link_detach_handler(node->context, link, 0);
+        if (link) {
+            qd_node_t *node = link->node;
+            if (node)
+                node->ntype->link_detach_handler(node->context, link, 0);
+        }
         pn_link_close(pn_link);
-        link_to_free = pn_link;
+        pn_link_t *link_to_free = pn_link;
         pn_link = pn_link_next(pn_link, PN_LOCAL_ACTIVE);
         pn_link_free(link_to_free);
     }

Modified: qpid/dispatch/trunk/src/dispatch.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch.c (original)
+++ qpid/dispatch/trunk/src/dispatch.c Thu Mar  5 20:21:55 2015
@@ -56,7 +56,7 @@ qd_dispatch_t *qd_dispatch(const char *p
     qd_alloc_initialize();
     qd_log_initialize();
     qd_error_initialize();
-    if (qd_error_code()) return 0;
+    if (qd_error_code()) { qd_dispatch_free(qd); return 0; }
 
     qd->router_area = strdup("0");
     qd->router_id   = strdup("0");
@@ -98,7 +98,11 @@ qd_error_t qd_dispatch_configure_contain
     const char *default_name = "00000000-0000-0000-0000-000000000000";
     qd->thread_count   = qd_entity_opt_long(entity, "workerThreads", 1); QD_ERROR_RET();
     qd->container_name = qd_entity_opt_string(entity, "containerName", default_name);
QD_ERROR_RET();
-    qd_alloc_debug_dump(qd_entity_opt_string(entity, "debugDump", 0)); QD_ERROR_RET();
+    char *dump_file = qd_entity_opt_string(entity, "debugDump", 0);
+    if (dump_file) {
+        qd_alloc_debug_dump(dump_file); QD_ERROR_RET();
+        free(dump_file);
+    }
     return QD_ERROR_NONE;
 }
 

Modified: qpid/dispatch/trunk/src/parse.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/parse.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/parse.c (original)
+++ qpid/dispatch/trunk/src/parse.c Thu Mar  5 20:21:55 2015
@@ -197,6 +197,7 @@ uint32_t qd_parse_as_uint(qd_parsed_fiel
     case QD_AMQP_UINT:
         result |= ((uint32_t) qd_field_iterator_octet(field->raw_iter)) << 24;
         result |= ((uint32_t) qd_field_iterator_octet(field->raw_iter)) << 16;
+        // fallthrough
 
     case QD_AMQP_USHORT:
         result |= ((uint32_t) qd_field_iterator_octet(field->raw_iter)) << 8;

Modified: qpid/dispatch/trunk/src/posix/driver.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/posix/driver.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/posix/driver.c (original)
+++ qpid/dispatch/trunk/src/posix/driver.c Thu Mar  5 20:21:55 2015
@@ -430,6 +430,7 @@ qdpn_connector_t *qdpn_connector(qdpn_dr
 
     int sock = qdpn_create_socket(addr->ai_family);
     if (sock == PN_INVALID_SOCKET) {
+        freeaddrinfo(addr);
         qdpn_log_errno(driver, "pn_create_socket");
         return 0;
     }

Modified: qpid/dispatch/trunk/src/router_config.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/router_config.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/router_config.c (original)
+++ qpid/dispatch/trunk/src/router_config.c Thu Mar  5 20:21:55 2015
@@ -35,8 +35,10 @@ qd_error_t qd_router_configure_address(q
     char *prefix = qd_entity_get_string(entity, "prefix"); QD_ERROR_RET();
 
     if (phase < 0 || phase > 9) {
+        qd_error_t err = qd_error(QD_ERROR_CONFIG,
+                                  "Invalid phase %d for prefix '%s' must be between 0 and
9.  Ignoring", phase, prefix);
         free(prefix);
-        return qd_error(QD_ERROR_CONFIG, "Invalid phase %d for prefix '%s' must be between
0 and 9.  Ignoring", phase, prefix);
+        return err;
     }
 
     //
@@ -78,6 +80,7 @@ qd_error_t qd_router_configure_address(q
       case QD_SCHEMA_FIXEDADDRESS_FANOUT_SINGLE: semantics |= QD_FANOUT_SINGLE; break;
       default:
         free(prefix);
+        free(addr_phase);
         return qd_error(QD_ERROR_CONFIG, "Invalid fanout value %d", fanout);
     }
 
@@ -87,6 +90,7 @@ qd_error_t qd_router_configure_address(q
           case QD_SCHEMA_FIXEDADDRESS_BIAS_SPREAD: semantics |= QD_BIAS_SPREAD; break;
           default:
             free(prefix);
+            free(addr_phase);
             return qd_error(QD_ERROR_CONFIG, "Invalid bias value %d", fanout);
         }
         qd_log(router->log_source, QD_LOG_INFO,
@@ -116,9 +120,11 @@ qd_error_t qd_router_configure_waypoint(
     int   out_phase = qd_entity_opt_long(entity, "outPhase", 0);  QD_ERROR_RET();
 
     if (in_phase > 9 || out_phase > 9) {
+        qd_error_t err = qd_error(QD_ERROR_CONFIG,
+                                  "Phases for waypoint '%s' must be between 0 and 9.", address);
         free(address);
         free(connector);
-        return qd_error(QD_ERROR_CONFIG, "Phases for waypoint '%s' must be between 0 and
9.", address);
+        return err;
     }
     qd_waypoint_t *waypoint = NEW(qd_waypoint_t);
     memset(waypoint, 0, sizeof(qd_waypoint_t));
@@ -184,10 +190,12 @@ qd_error_t qd_router_configure_lrp(qd_ro
 
         if (!lrp) {
             sys_mutex_unlock(router->lock);
+            qd_error_t err = qd_error(QD_ERROR_CONFIG,
+                                      "Failed to create link-route-pattern: prefix=%s connector=%s",
+                                      prefix, connector);
             free(prefix);
             free(connector);
-            return qd_error(QD_ERROR_CONFIG,
-                            "Failed to create link-route-pattern: prefix=%s connector=%s",
prefix, connector);
+            return err;
         }
 
         qd_log(router->log_source, QD_LOG_INFO,

Modified: qpid/dispatch/trunk/src/server.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/server.c?rev=1664472&r1=1664471&r2=1664472&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/server.c (original)
+++ qpid/dispatch/trunk/src/server.c Thu Mar  5 20:21:55 2015
@@ -412,7 +412,6 @@ void qdpn_driver_wait_3(qdpn_driver_t *d
 static void *thread_run(void *arg)
 {
     qd_thread_t      *thread    = (qd_thread_t*) arg;
-    qd_server_t      *qd_server = thread->qd_server;
     qd_work_item_t   *work;
     qdpn_connector_t *cxtr;
     pn_connection_t  *conn;
@@ -423,6 +422,7 @@ static void *thread_run(void *arg)
     if (!thread)
         return 0;
 
+    qd_server_t      *qd_server = thread->qd_server;
     thread_server   = qd_server;
     thread->running = 1;
 
@@ -869,8 +869,6 @@ void qd_server_free(qd_server_t *qd_serv
 {
     if (!qd_server) return;
     int i;
-    if (!qd_server)
-        return;
 
     for (i = 0; i < qd_server->thread_count; i++)
         thread_free(qd_server->threads[i]);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message