Fix: liblttng-ctl comm: lttng_event is not packed
[lttng-tools.git] / src / common / userspace-probe.c
index a15e5b7e42480fd50484c039a1722791536f313f..e85c3c56fc67eea6163b5442694a1855332892ad 100644 (file)
@@ -413,17 +413,20 @@ lttng_userspace_probe_location_function_copy(
                goto error;
        }
 
-       /* Duplicate the binary fd */
+       /*
+        * Duplicate the binary fd if possible. The binary fd can be -1 on
+        * listing
+        */
        fd = lttng_userspace_probe_location_function_get_binary_fd(location);
-       if (fd == -1) {
-               ERR("Error getting file descriptor to binary");
-               goto error;
-       }
-
-       new_fd = dup(fd);
-       if (new_fd == -1) {
-               PERROR("Error duplicating file descriptor to binary");
-               goto error;
+       if (fd > -1) {
+               new_fd = dup(fd);
+               if (new_fd == -1) {
+                       PERROR("Error duplicating file descriptor to binary");
+                       goto error;
+               }
+       } else {
+               /* The original fd is not set. */
+               new_fd = -1;
        }
 
        /*
@@ -509,15 +512,15 @@ lttng_userspace_probe_location_tracepoint_copy(
 
        /* Duplicate the binary fd */
        fd = lttng_userspace_probe_location_tracepoint_get_binary_fd(location);
-       if (fd == -1) {
-               ERR("Error getting file descriptor to binary");
-               goto error;
-       }
-
-       new_fd = dup(fd);
-       if (new_fd == -1) {
-               PERROR("Error duplicating file descriptor to binary");
-               goto error;
+       if (fd > -1) {
+               new_fd = dup(fd);
+               if (new_fd == -1) {
+                       PERROR("Error duplicating file descriptor to binary");
+                       goto error;
+               }
+       } else {
+               /* The original fd is not set. */
+               new_fd = -1;
        }
 
        /*
This page took 0.023497 seconds and 4 git commands to generate.