Fix: atomic_long_add_unless() returns a boolean
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 18 Mar 2019 20:20:36 +0000 (16:20 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 18 Mar 2019 20:37:26 +0000 (16:37 -0400)
Because of a documentation error in older kernels, it was assumed that
atomic_long_add_unless would return the old value, but the
implementation actually returns a boolean.

Also add missing error code int 'ret' and compare against the right type
max value.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-events.c

index c45c10f42c747fa4d553d08d18900b5bca1a9e08..bee4255d47b4832d15dc2b48d2bc1514b7b41568 100644 (file)
@@ -429,8 +429,8 @@ int lttng_abi_create_channel(struct file *session_file,
                transport_name = "<unknown>";
                break;
        }
-       if (atomic_long_add_unless(&session_file->f_count,
-               1, INT_MAX) == INT_MAX) {
+       if (!atomic_long_add_unless(&session_file->f_count, 1, LONG_MAX)) {
+               ret = -EOVERFLOW;
                goto refcount_error;
        }
        /*
@@ -1038,8 +1038,7 @@ int lttng_abi_create_event(struct file *channel_file,
                goto file_error;
        }
        /* The event holds a reference on the channel */
-       if (atomic_long_add_unless(&channel_file->f_count,
-               1, INT_MAX) == INT_MAX) {
+       if (!atomic_long_add_unless(&channel_file->f_count, 1, LONG_MAX)) {
                ret = -EOVERFLOW;
                goto refcount_error;
        }
index 687e8bc1df1f2daa4a85152bf605c6966c115d0f..da1d38e67b5ef80e4d381f15ceed0097093837bd 100644 (file)
@@ -1120,8 +1120,8 @@ int lttng_session_list_tracker_pids(struct lttng_session *session)
                ret = PTR_ERR(tracker_pids_list_file);
                goto file_error;
        }
-       if (atomic_long_add_unless(&session->file->f_count,
-               1, INT_MAX) == INT_MAX) {
+       if (!atomic_long_add_unless(&session->file->f_count, 1, LONG_MAX)) {
+               ret = -EOVERFLOW;
                goto refcount_error;
        }
        ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file);
This page took 0.028146 seconds and 4 git commands to generate.