cppcheck: don't check NULL pointer before freeing them
authorDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 20:15:08 +0000 (15:15 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 20:15:08 +0000 (15:15 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/session.c
src/bin/lttng/commands/create.c
src/bin/lttng/commands/list.c
src/bin/lttng/commands/view.c
src/bin/lttng/conf.c
src/common/compat/poll.h
src/common/consumer.c
src/common/sessiond-comm/sessiond-comm.c
src/common/uri.c
src/lib/lttng-ctl/lttng-ctl.c

index 65e3145a5fd63bae374117a25e25261300eaec91..6fb6bd3602256abffe4b8f0922e0a9baeb57bc32 100644 (file)
@@ -246,9 +246,7 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid)
 
 error:
 error_asprintf:
-       if (new_session != NULL) {
-               free(new_session);
-       }
+       free(new_session);
 
 error_malloc:
        return ret;
index d66f0309e28de3613468fdd4f3ba06d4ccf51040..6c7ab786e5d25fc90ca4b2606ee67a6bb9ff0f49 100644 (file)
@@ -390,13 +390,8 @@ static int create_session(void)
        ret = CMD_SUCCESS;
 
 error:
-       if (alloc_url) {
-               free(alloc_url);
-       }
-
-       if (traces_path) {
-               free(traces_path);
-       }
+       free(alloc_url);
+       free(traces_path);
        free(alloc_path);
 
        if (ret < 0) {
index a6ea6b8c9c6c153375bac25c7b390466b830d01d..8fec91fac30ffe6cab6986ac7e717a75dbf18d36 100644 (file)
@@ -474,9 +474,7 @@ static int list_events(const char *channel_name)
        MSG("");
 
 end:
-       if (events) {
-               free(events);
-       }
+       free(events);
        ret = CMD_SUCCESS;
 
 error:
@@ -821,9 +819,7 @@ int cmd_list(int argc, const char **argv)
        }
 
 end:
-       if (domains) {
-               free(domains);
-       }
+       free(domains);
        if (handle) {
                lttng_destroy_handle(handle);
        }
index e3eff22ca394c6680babf7ef75a064bb7bc53b83..d339282e61e7513b3559643d646f5d847a20bf24 100644 (file)
@@ -361,9 +361,7 @@ static int view_trace(void)
        }
 
 free_sessions:
-       if (sessions) {
-               free(sessions);
-       }
+       free(sessions);
 free_error:
        if (opt_session_name == NULL) {
                free(session_name);
index 995407d03d4d4ba6863ee991c6da927df06e8db8..c1bfcfd45b8d87eacfae6d3be878033121ee85cc 100644 (file)
@@ -65,9 +65,7 @@ static FILE *open_config(char *path, const char *mode)
        }
 
 error:
-       if (file_path) {
-               free(file_path);
-       }
+       free(file_path);
        return fp;
 }
 
index 49673cd5af643e40a10aa9173d1ff4cf489d0802..9e889767f8321a05ea23f97c211086cf0c6e3836 100644 (file)
@@ -43,9 +43,7 @@ extern unsigned int poll_max_size;
  */
 static inline void __lttng_poll_free(void *events)
 {
-       if (events) {
-               free(events);
-       }
+       free(events);
 }
 
 /*
index 15fc9b09f800d6225be465b0d3c993e69a279f09..8bcfa45ebd746fd6be782c6259790ba9391168f8 100644 (file)
@@ -2283,14 +2283,11 @@ void *consumer_thread_data_poll(void *data)
                 */
                pthread_mutex_lock(&consumer_data.lock);
                if (consumer_data.need_update) {
-                       if (pollfd != NULL) {
-                               free(pollfd);
-                               pollfd = NULL;
-                       }
-                       if (local_stream != NULL) {
-                               free(local_stream);
-                               local_stream = NULL;
-                       }
+                       free(pollfd);
+                       pollfd = NULL;
+
+                       free(local_stream);
+                       local_stream = NULL;
 
                        /* allocate for all fds + 1 for the consumer_data_pipe */
                        pollfd = zmalloc((consumer_data.stream_count + 1) * sizeof(struct pollfd));
@@ -2487,14 +2484,8 @@ void *consumer_thread_data_poll(void *data)
        }
 end:
        DBG("polling thread exiting");
-       if (pollfd != NULL) {
-               free(pollfd);
-               pollfd = NULL;
-       }
-       if (local_stream != NULL) {
-               free(local_stream);
-               local_stream = NULL;
-       }
+       free(pollfd);
+       free(local_stream);
 
        /*
         * Close the write side of the pipe so epoll_wait() in
index 799290cbf40402b6149ac3926c96a2d8e7270847..d1324d53013a696cea0289711d29c69bf17be4a9 100644 (file)
@@ -312,7 +312,5 @@ alloc_error:
 __attribute__((visibility("hidden")))
 void lttcomm_destroy_sock(struct lttcomm_sock *sock)
 {
-       if (sock != NULL) {
-               free(sock);
-       }
+       free(sock);
 }
index f64a0de9fb88d24f4980fbce8623289fbd18510a..5cc53525f1f09a37c1dd9ae73ebae40d15316656 100644 (file)
@@ -189,10 +189,7 @@ int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2)
 __attribute__((visibility("hidden")))
 void uri_free(struct lttng_uri *uri)
 {
-       /* Safety check */
-       if (uri != NULL) {
-               free(uri);
-       }
+       free(uri);
 }
 
 /*
index 3e532ad60067c6db4a454eb2d4d6b3ab890a6d7e..9ea891e92f980d037a47328a83ddeb79c4ec8c26 100644 (file)
@@ -636,9 +636,7 @@ end:
  */
 void lttng_destroy_handle(struct lttng_handle *handle)
 {
-       if (handle) {
-               free(handle);
-       }
+       free(handle);
 }
 
 /*
This page took 0.048012 seconds and 4 git commands to generate.