bool lttng_trigger_is_equal(
const struct lttng_trigger *a, const struct lttng_trigger *b)
{
- if (strcmp(a->name, b->name) != 0) {
+ if (!!a->name != !!b->name) {
+ /* Both must be either anonymous or named. */
+ return false;
+ }
+
+ if (a->name && strcmp(a->name, b->name) != 0) {
return false;
}
return true;
}
+LTTNG_HIDDEN
enum lttng_trigger_status lttng_trigger_set_name(struct lttng_trigger *trigger,
const char* name)
{
char *name_copy = NULL;
enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
- if (!trigger || !name ||
- strlen(name) == 0) {
+ if (!trigger) {
status = LTTNG_TRIGGER_STATUS_INVALID;
goto end;
}
- name_copy = strdup(name);
- if (!name_copy) {
- status = LTTNG_TRIGGER_STATUS_ERROR;
- goto end;
+ if (name) {
+ name_copy = strdup(name);
+ if (!name_copy) {
+ status = LTTNG_TRIGGER_STATUS_ERROR;
+ goto end;
+ }
}
free(trigger->name);