From 9d035200e9006c4d4cf6951c54641e06c0bdf2bc Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 22 Jan 2013 15:09:23 -0500 Subject: [PATCH] cppcheck: Simplify empty string test without using strlen() Signed-off-by: David Goulet --- src/bin/lttng-consumerd/lttng-consumerd.c | 4 ++-- src/bin/lttng-sessiond/cmd.c | 2 +- src/bin/lttng-sessiond/context.c | 4 ++-- src/bin/lttng-sessiond/trace-kernel.c | 2 +- src/bin/lttng-sessiond/trace-ust.c | 2 +- src/bin/lttng/commands/enable_events.c | 4 ++-- src/lib/lttng-ctl/lttng-ctl.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/lttng-consumerd/lttng-consumerd.c b/src/bin/lttng-consumerd/lttng-consumerd.c index 4d02c8427..b854aabac 100644 --- a/src/bin/lttng-consumerd/lttng-consumerd.c +++ b/src/bin/lttng-consumerd/lttng-consumerd.c @@ -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, diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 456ddeb77..bdc9c9aca 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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 { diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 46e1b3446..a83cb46fc 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -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; diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index d3742be16..53053f206 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -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. */ diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 81bf535f6..5e06a8452 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -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, diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index b6c18e142..73c9e0520 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -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; diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 6bf19a46a..3e532ad60 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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. -- 2.34.1