From: David Goulet Date: Thu, 24 Nov 2011 20:22:31 +0000 (-0500) Subject: Do not permit NULL pointer on enable API calls X-Git-Tag: v2.0-pre15~76 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=5117eeecf9d4b04ebe5a4e46b48c0d6186bb429b;ds=inline Do not permit NULL pointer on enable API calls Enable channel lttng API call now forbids the use of NULL pointer for channel attributes. Use lttng_channel_set_default_attr() before. Signed-off-by: David Goulet --- diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index fc6ff3cc1..c91a242f3 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -496,10 +496,11 @@ int lttng_enable_event(struct lttng_handle *handle, { struct lttcomm_session_msg lsm; - if (!handle || ev == NULL) { + if (handle == NULL || ev == NULL) { return -1; } + /* If no channel name, we put the default name */ if (channel_name == NULL) { copy_string(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, sizeof(lsm.u.enable.channel_name)); @@ -566,13 +567,14 @@ int lttng_enable_channel(struct lttng_handle *handle, { struct lttcomm_session_msg lsm; - if (!handle) { + /* + * NULL arguments are forbidden. No default values. + */ + if (handle == NULL || chan == NULL) { return -1; } - if (chan) { - memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan)); - } + memcpy(&lsm.u.channel.chan, chan, sizeof(lsm.u.channel.chan)); lsm.cmd_type = LTTNG_ENABLE_CHANNEL;