Because of a documentation error in older kernels, it was assumed that
atomic_long_add_unless would return the 'unless' value when it failed
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 <mjean...@efficios.com>
---
 lttng-abi.c    | 7 +++----
 lttng-events.c | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lttng-abi.c b/lttng-abi.c
index 0534472..ca94379 100644
--- a/lttng-abi.c
+++ b/lttng-abi.c
@@ -419,8 +419,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;
        }
        /*
@@ -1072,8 +1072,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;
        }
diff --git a/lttng-events.c b/lttng-events.c
index f4206c5..a4570b7 100644
--- a/lttng-events.c
+++ b/lttng-events.c
@@ -1140,8 +1140,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);
-- 
2.17.1

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to