Fix possible null pointer
authorDavid Goulet <david.goulet@polymtl.ca>
Wed, 29 Jun 2011 22:05:06 +0000 (18:05 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Wed, 29 Jun 2011 22:05:06 +0000 (18:05 -0400)
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
liblttngctl/liblttngctl.c

index 31693942dd6fbd31bfa7ef2fc445912bf63f976f..e05496a9449891f5f6174af5ed4de3c9ce1f5f0e 100644 (file)
@@ -257,11 +257,11 @@ int lttng_stop_tracing(char *session_name)
 int lttng_kernel_add_context(struct lttng_kernel_context *ctx,
                char *event_name, char *channel_name)
 {
 int lttng_kernel_add_context(struct lttng_kernel_context *ctx,
                char *event_name, char *channel_name)
 {
-       if (strlen(channel_name) != 0) {
+       if (channel_name != NULL) {
                strncpy(lsm.u.context.channel_name, channel_name, NAME_MAX);
        }
 
                strncpy(lsm.u.context.channel_name, channel_name, NAME_MAX);
        }
 
-       if (strlen(event_name) != 0) {
+       if (event_name != NULL) {
                strncpy(lsm.u.context.event_name, event_name, NAME_MAX);
        }
 
                strncpy(lsm.u.context.event_name, event_name, NAME_MAX);
        }
 
@@ -276,7 +276,7 @@ int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name)
 {
        int ret;
 
 {
        int ret;
 
-       if (strlen(channel_name) == 0) {
+       if (channel_name == NULL) {
                strncpy(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
        } else {
                strncpy(lsm.u.enable.channel_name, channel_name, NAME_MAX);
                strncpy(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
        } else {
                strncpy(lsm.u.enable.channel_name, channel_name, NAME_MAX);
@@ -301,7 +301,7 @@ int lttng_kernel_disable_event(char *name, char *channel_name)
 {
        int ret;
 
 {
        int ret;
 
-       if (strlen(channel_name) == 0) {
+       if (channel_name == NULL) {
                strncpy(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
        } else {
                strncpy(lsm.u.disable.channel_name, channel_name, NAME_MAX);
                strncpy(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
        } else {
                strncpy(lsm.u.disable.channel_name, channel_name, NAME_MAX);
This page took 0.03404 seconds and 4 git commands to generate.