Fix: statements with side-effects in assert statements
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index f222ebdb6215cd14c7d05cf983e214a2cce63664..ae2db857dd7835554c57f9683bae6ce5524a3445 100644 (file)
@@ -1249,6 +1249,7 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
 {
        enum lttng_event_rule_generate_exclusions_status
                        generate_exclusion_status;
+       enum lttng_condition_status cond_status;
        struct ust_app_event_notifier_rule *ua_event_notifier_rule;
        struct lttng_condition *condition = NULL;
        const struct lttng_event_rule *event_rule = NULL;
@@ -1269,9 +1270,9 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
        assert(lttng_condition_get_type(condition) ==
                        LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
 
-       assert(LTTNG_CONDITION_STATUS_OK ==
-                       lttng_condition_event_rule_matches_get_rule(
-                                       condition, &event_rule));
+       cond_status = lttng_condition_event_rule_matches_get_rule(
+                       condition, &event_rule);
+       assert(cond_status == LTTNG_CONDITION_STATUS_OK);
        assert(event_rule);
 
        ua_event_notifier_rule->error_counter_index =
@@ -3013,7 +3014,7 @@ static int duplicate_stream_object(struct buffer_reg_stream *reg_stream,
        assert(reg_stream);
        assert(stream);
 
-       /* Reserve the amount of file descriptor we need. */
+       /* Duplicating a stream requires 2 new fds. Reserve them. */
        ret = lttng_fd_get(LTTNG_FD_APPS, 2);
        if (ret < 0) {
                ERR("Exhausted number of available FD upon duplicate stream");
@@ -3049,7 +3050,7 @@ static int duplicate_channel_object(struct buffer_reg_channel *buf_reg_chan,
        assert(buf_reg_chan);
        assert(ua_chan);
 
-       /* Need two fds for the channel. */
+       /* Duplicating a channel requires 1 new fd. Reserve it. */
        ret = lttng_fd_get(LTTNG_FD_APPS, 1);
        if (ret < 0) {
                ERR("Exhausted number of available FD upon duplicate channel");
@@ -5903,14 +5904,16 @@ void ust_app_synchronize(struct ltt_ust_session *usess,
        ret = find_or_create_ust_app_session(usess, app, &ua_sess, NULL);
        if (ret < 0) {
                /* Tracer is probably gone or ENOMEM. */
-               goto error;
+               if (ua_sess) {
+                       destroy_app_session(app, ua_sess);
+               }
+               goto end;
        }
        assert(ua_sess);
 
        pthread_mutex_lock(&ua_sess->lock);
        if (ua_sess->deleted) {
-               pthread_mutex_unlock(&ua_sess->lock);
-               goto end;
+               goto deleted_session;
        }
 
        rcu_read_lock();
@@ -5928,23 +5931,15 @@ void ust_app_synchronize(struct ltt_ust_session *usess,
         */
        ret = create_ust_app_metadata(ua_sess, app, usess->consumer);
        if (ret < 0) {
-               goto error_unlock;
+               ERR("Metadata creation failed for app sock %d for session id %" PRIu64,
+                               app->sock, usess->id);
        }
 
        rcu_read_unlock();
 
-end:
+deleted_session:
        pthread_mutex_unlock(&ua_sess->lock);
-       /* Everything went well at this point. */
-       return;
-
-error_unlock:
-       rcu_read_unlock();
-       pthread_mutex_unlock(&ua_sess->lock);
-error:
-       if (ua_sess) {
-               destroy_app_session(app, ua_sess);
-       }
+end:
        return;
 }
 
This page took 0.024217 seconds and 4 git commands to generate.