Validate channel context mismatch across UST applications
[lttng-tools.git] / src / bin / lttng-sessiond / ust-field-utils.c
index 8e890557b471efaab37c7dd59e69c94fb528081c..cef0261564c9034beef23846bd9d23b1521e4144 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
+ * Copyright (C) 2018 Francis Deslauriers <francis.deslauriers@efficios.com>
  *
- * 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.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * 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., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include <stdbool.h>
@@ -288,3 +278,33 @@ int match_ustctl_field(const struct ustctl_field *first,
 no_match:
        return false;
 }
+
+/*
+ * Compare two arrays of UST fields.
+ * Return true if both arrays have identical field definitions, false otherwise.
+ */
+bool match_lttng_ust_ctl_field_array(const struct ustctl_field *first,
+               size_t nr_first,
+               const struct ustctl_field *second,
+               size_t nr_second)
+{
+       size_t i;
+       const size_t nr_fields = nr_first;
+
+       /* Compare the array lengths. */
+       if (nr_first != nr_second) {
+               goto no_match;
+       }
+
+       /* Compare each field individually. */
+       for (i = 0; i < nr_fields; i++) {
+               if (!match_ustctl_field(&first[i], &second[i])) {
+                       goto no_match;
+               }
+       }
+
+       return true;
+
+no_match:
+       return false;
+}
This page took 0.024015 seconds and 4 git commands to generate.