Fix: clang llvm warnings
[lttng-tools.git] / src / bin / lttng-sessiond / event.c
index 0a82372bd57fdddf0d34061d56bc697c70a911c9..c9c2f17f4a24450d561e7d4d607f95c5744de2a5 100644 (file)
@@ -1,18 +1,18 @@
 /*
  * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; only version 2 of the License.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2 only,
+ * as published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _GNU_SOURCE
@@ -134,10 +134,16 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
        if (kevent == NULL) {
                ret = kernel_create_event(event, kchan);
                if (ret < 0) {
-                       if (ret == -EEXIST) {
+                       switch (-ret) {
+                       case EEXIST:
                                ret = LTTCOMM_KERN_EVENT_EXIST;
-                       } else {
+                               break;
+                       case ENOSYS:
+                               ret = LTTCOMM_KERN_EVENT_ENOSYS;
+                               break;
+                       default:
                                ret = LTTCOMM_KERN_ENABLE_FAIL;
+                               break;
                        }
                        goto end;
                }
@@ -147,7 +153,12 @@ int event_kernel_enable_tracepoint(struct ltt_kernel_session *ksession,
                        ret = LTTCOMM_KERN_ENABLE_FAIL;
                        goto end;
                }
+       } else {
+               /* At this point, the event is considered enabled */
+               ret = LTTCOMM_KERN_EVENT_EXIST;
+               goto end;
        }
+
        ret = LTTCOMM_OK;
 end:
        return ret;
@@ -234,15 +245,26 @@ end:
 int event_kernel_enable_all(struct ltt_kernel_session *ksession,
                struct ltt_kernel_channel *kchan, int kernel_tracer_fd)
 {
-       int ret;
+       int tp_ret;
 
-       ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
-       if (ret != LTTCOMM_OK) {
+       tp_ret = event_kernel_enable_all_tracepoints(ksession, kchan, kernel_tracer_fd);
+       if (tp_ret != LTTCOMM_OK) {
                goto end;
        }
-       ret = event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
+       /*
+        * Reaching this code path means that all tracepoints were enabled without
+        * errors so we ignore the error value of syscalls.
+        *
+        * At the moment, failing to enable syscalls on "lttng enable-event -a -k"
+        * is not considered an error that need to be returned to the client since
+        * tracepoints did not fail. Future work will allow us to send back
+        * multiple errors to the client in one API call.
+        */
+       (void) event_kernel_enable_all_syscalls(ksession, kchan, kernel_tracer_fd);
+
 end:
-       return ret;
+       return tp_ret;
 }
 
 /*
@@ -257,8 +279,7 @@ end:
 int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                struct ltt_ust_channel *uchan)
 {
-       int ret, i;
-       size_t size;
+       int ret, i, size;
        struct lttng_ht_iter iter;
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
@@ -340,7 +361,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -409,7 +430,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto end;
        }
 
@@ -478,7 +499,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
@@ -499,8 +520,7 @@ error:
 int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                struct ltt_ust_channel *uchan)
 {
-       int ret, i;
-       size_t size;
+       int ret, i, size;
        struct lttng_ht_iter iter;
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
@@ -551,7 +571,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
 #endif
        default:
-               ret = LTTCOMM_NOT_IMPLEMENTED;
+               ret = LTTCOMM_UND;
                goto error;
        }
 
This page took 0.026218 seconds and 4 git commands to generate.