cppcheck: Simplify empty string test without using strlen()
authorDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 20:09:23 +0000 (15:09 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 22 Jan 2013 20:09:23 +0000 (15:09 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng/commands/enable_events.c
src/lib/lttng-ctl/lttng-ctl.c

index 4d02c842798f65c1024b9326a248493ea60204af..b854aabac9923c9b832b81b338d933b2feafa6d7 100644 (file)
@@ -294,7 +294,7 @@ int main(int argc, char **argv)
        /* Set up max poll set size */
        lttng_poll_set_max_size();
 
-       if (strlen(command_sock_path) == 0) {
+       if (*command_sock_path == '\0') {
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
                        snprintf(command_sock_path, PATH_MAX, DEFAULT_KCONSUMERD_CMD_SOCK_PATH,
@@ -330,7 +330,7 @@ int main(int argc, char **argv)
        }
 
        lttng_consumer_set_command_sock_path(ctx, command_sock_path);
-       if (strlen(error_sock_path) == 0) {
+       if (*error_sock_path == '\0') {
                switch (opt_type) {
                case LTTNG_CONSUMER_KERNEL:
                        snprintf(error_sock_path, PATH_MAX, DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
index 456ddeb77d85fd4d1a6f70ca7116494435a12b5e..bdc9c9acab52a1cbe893efe1faaa50198b27206e 100644 (file)
@@ -105,7 +105,7 @@ static int build_network_session_path(char *dst, size_t size,
         * Do we have a UST url set. If yes, this means we have both kernel and UST
         * to print.
         */
-       if (strlen(tmp_uurl) > 0) {
+       if (*tmp_uurl != '\0') {
                ret = snprintf(dst, size, "[K]: %s [data: %d] -- [U]: %s [data: %d]",
                                tmp_urls, kdata_port, tmp_uurl, udata_port);
        } else {
index 46e1b344612e1f8af58a1117ec214c112b0a05b3..a83cb46fc9dec796868dbb95157d901cb46cdb70 100644 (file)
@@ -201,7 +201,7 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
                        LTTNG_SYMBOL_NAME_LEN);
        kctx.u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
 
-       if (strlen(channel_name) == 0) {
+       if (*channel_name == '\0') {
                ret = add_kctx_all_channels(ksession, &kctx);
                if (ret != LTTNG_OK) {
                        goto error;
@@ -262,7 +262,7 @@ int context_ust_add(struct ltt_ust_session *usess, int domain,
        }
 
        /* Get UST channel if defined */
-       if (strlen(channel_name) != 0) {
+       if (channel_name != '\0') {
                uchan = trace_ust_find_channel_by_name(chan_ht, channel_name);
                if (uchan == NULL) {
                        ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
index d3742be16e944c55adac4ab339bb021854b5ef96..53053f2067c6a8b20cc92f0b6a3019fb360c473b 100644 (file)
@@ -109,7 +109,7 @@ struct ltt_kernel_session *trace_kernel_create_session(char *path)
         */
        lks->tmp_consumer = NULL;
 
-       if (path && strlen(path) > 0) {
+       if (*path != '\0') {
                int ret;
 
                /* Use the default consumer output which is the tracing session path. */
index 81bf535f626c6996a730c7c9e3807773ae87ce93..5e06a845242b79293d78add5d8f30d4e2bc81579 100644 (file)
@@ -216,7 +216,7 @@ struct ltt_ust_session *trace_ust_create_session(char *path,
        lus->tmp_consumer = NULL;
 
        /* Use the default consumer output which is the tracing session path. */
-       if (path && strlen(path) > 0) {
+       if (*path != '\0') {
                int ret;
 
                ret = snprintf(lus->consumer->dst.trace_path, PATH_MAX,
index b6c18e142ca6c3e7434e616db17f3499df636d45..73c9e05209316cb99045a9cc0d744ddd349f83ae 100644 (file)
@@ -199,7 +199,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
                strncpy(ev->attr.probe.symbol_name, name, LTTNG_SYMBOL_NAME_LEN);
                ev->attr.probe.symbol_name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
                DBG("probe symbol %s", ev->attr.probe.symbol_name);
-               if (strlen(s_hex) == 0) {
+               if (*s_hex == '\0') {
                        ERR("Invalid probe offset %s", s_hex);
                        ret = -1;
                        goto end;
@@ -227,7 +227,7 @@ static int parse_probe_opts(struct lttng_event *ev, char *opt)
        /* Check for address */
        ret = sscanf(opt, "%s", s_hex);
        if (ret > 0) {
-               if (strlen(s_hex) == 0) {
+               if (*s_hex == '\0') {
                        ERR("Invalid probe address %s", s_hex);
                        ret = -1;
                        goto end;
index 6bf19a46acadc97ee3815a91189835daa8e307ba..3e532ad60067c6db4a454eb2d4d6b3ab890a6d7e 100644 (file)
@@ -1399,7 +1399,7 @@ int lttng_session_daemon_alive(void)
                return ret;
        }
 
-       if (strlen(sessiond_sock_path) == 0) {
+       if (*sessiond_sock_path == '\0') {
                /*
                 * No socket path set. Weird error which means the constructor was not
                 * called.
This page took 0.033035 seconds and 5 git commands to generate.