Add a basic .clang-tidy file and fix typedef warnings
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 13 Jan 2023 17:24:13 +0000 (12:24 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 16 Jan 2023 19:49:24 +0000 (14:49 -0500)
This initial .clang-tidy file only enforces the use of 'using' instead
of 'typedef'.

Note that a second .clang-tidy is added to the filter sub-folder to
disable checks against generated code.

The entire tree can be checked by running `run-clang-tidy` after
generating a compilation command database. I personally use `bear`
to generate `compile_commands.json`.

$ ./configure
$ bear -- make -j$(nproc)
$ run-clang-tidy -fix

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I074b6f2724e1af9a2df311e07a2fcdacb689bcf5

41 files changed:
.clang-tidy [new file with mode: 0644]
include/lttng/action/action-internal.hpp
include/lttng/condition/condition-internal.hpp
include/lttng/condition/evaluation-internal.hpp
include/lttng/event-rule/event-rule-internal.hpp
include/lttng/kernel-probe-internal.hpp
include/lttng/ref-internal.hpp
include/lttng/userspace-probe-internal.hpp
src/bin/lttng-sessiond/action-executor.cpp
src/bin/lttng-sessiond/agent.cpp
src/bin/lttng-sessiond/cmd.hpp
src/bin/lttng-sessiond/notification-thread-internal.hpp
src/bin/lttng-sessiond/notification-thread.hpp
src/bin/lttng-sessiond/session.hpp
src/bin/lttng-sessiond/thread.hpp
src/bin/lttng/commands/list_triggers.cpp
src/common/actions/rate-policy.cpp
src/common/bytecode/bytecode.hpp
src/common/compat/directory-handle.hpp
src/common/compat/socket.hpp
src/common/consumer/consumer-timer.cpp
src/common/consumer/consumer.hpp
src/common/consumer/metadata-bucket.hpp
src/common/dynamic-array.hpp
src/common/fd-tracker/fd-tracker.hpp
src/common/filter/.clang-tidy [new file with mode: 0644]
src/common/filter/filter-ast.hpp
src/common/fs-handle-internal.hpp
src/common/hashtable/hashtable.hpp
src/common/ini-config/ini-config.hpp
src/common/ini-config/ini.hpp
src/common/mi-lttng.hpp
src/common/runas.cpp
src/common/runas.hpp
src/common/trace-chunk.cpp
src/common/userspace-probe.cpp
tests/regression/kernel/select_poll_epoll.cpp
tests/regression/tools/notification/notification.cpp
tests/regression/tools/trigger/name/trigger_name.cpp
tests/unit/test_directory_handle.cpp
tests/unit/test_event_rule.cpp

diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644 (file)
index 0000000..af914d2
--- /dev/null
@@ -0,0 +1,3 @@
+HeaderFilterRegex: '.*((include/.*-internal)|(src/common.*)|(src/bin.*)|(src/lib.*)|(tests.*))\.(h|hpp)$'
+Checks: '-*,modernize-use-using'
+FormatStyle: 'file'
index 996e166ec2b6e8548f1dd5750b19552c41c2ee1d..e52d91f594f98824f23043ccc2cda5ffde368678 100644 (file)
@@ -24,22 +24,17 @@ struct mi_writer;
 struct mi_lttng_error_query_callbacks;
 struct lttng_trigger;
 
-typedef bool (*action_validate_cb)(struct lttng_action *action);
-typedef void (*action_destroy_cb)(struct lttng_action *action);
-typedef int (*action_serialize_cb)(struct lttng_action *action,
-               struct lttng_payload *payload);
-typedef bool (*action_equal_cb)(const struct lttng_action *a,
-               const struct lttng_action *b);
-typedef ssize_t (*action_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_action **action);
-typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
-               const struct lttng_action *action);
-typedef enum lttng_action_status (*action_add_error_query_results_cb)(
-               const struct lttng_action *action,
-               struct lttng_error_query_results *results);
-typedef enum lttng_error_code (*action_mi_serialize_cb)(
-               const struct lttng_action *condition, struct mi_writer *writer);
+using action_validate_cb = bool (*)(struct lttng_action *);
+using action_destroy_cb = void (*)(struct lttng_action *);
+using action_serialize_cb = int (*)(struct lttng_action *, struct lttng_payload *);
+using action_equal_cb = bool (*)(const struct lttng_action *, const struct lttng_action *);
+using action_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
+                                                 struct lttng_action **);
+using action_get_rate_policy_cb = const struct lttng_rate_policy *(*) (const struct lttng_action *);
+using action_add_error_query_results_cb = enum lttng_action_status (*)(
+       const struct lttng_action *, struct lttng_error_query_results *);
+using action_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_action *,
+                                                        struct mi_writer *);
 
 struct lttng_action {
        struct urcu_ref ref;
index 27407d07a6f2573a878c101cdd76c5fdd4515f18..2fac62913101745440e36a39d2a142e6a35126fe 100644 (file)
@@ -23,19 +23,14 @@ struct mi_writer;
 struct mi_lttng_error_query_callbacks;
 struct lttng_trigger;
 
-typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
-typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
-typedef int (*condition_serialize_cb)(
-               const struct lttng_condition *condition,
-               struct lttng_payload *payload);
-typedef bool (*condition_equal_cb)(const struct lttng_condition *a,
-               const struct lttng_condition *b);
-typedef ssize_t (*condition_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_condition **condition);
-typedef enum lttng_error_code (*condition_mi_serialize_cb)(
-               const struct lttng_condition *condition,
-               struct mi_writer *writer);
+using condition_destroy_cb = void (*)(struct lttng_condition *);
+using condition_validate_cb = bool (*)(const struct lttng_condition *);
+using condition_serialize_cb = int (*)(const struct lttng_condition *, struct lttng_payload *);
+using condition_equal_cb = bool (*)(const struct lttng_condition *, const struct lttng_condition *);
+using condition_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
+                                                    struct lttng_condition **);
+using condition_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_condition *,
+                                                           struct mi_writer *);
 
 struct lttng_condition {
        /* Reference counting is only exposed to internal users. */
index f74927c24b0c71d35c8b597dd3d39788c2a4edde..ed2c5735f3de2fe73c2ab7a67fe41b3920f4375f 100644 (file)
 struct lttng_payload;
 struct lttng_payload_view;
 
-typedef void (*evaluation_destroy_cb)(struct lttng_evaluation *evaluation);
-typedef int (*evaluation_serialize_cb)(
-               const struct lttng_evaluation *evaluation,
-               struct lttng_payload *payload);
+using evaluation_destroy_cb = void (*)(struct lttng_evaluation *);
+using evaluation_serialize_cb = int (*)(const struct lttng_evaluation *, struct lttng_payload *);
 
 struct lttng_evaluation_comm {
        /* enum lttng_condition_type type */
index 46fb98144820946007263297517795411085da89..b1415cac780bc8876da633be268a5f3dd7da70d0 100644 (file)
@@ -31,36 +31,24 @@ enum lttng_event_rule_generate_exclusions_status {
        LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OUT_OF_MEMORY,
 };
 
-typedef void (*event_rule_destroy_cb)(struct lttng_event_rule *event_rule);
-typedef bool (*event_rule_validate_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef int (*event_rule_serialize_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct lttng_payload *payload);
-typedef bool (*event_rule_equal_cb)(const struct lttng_event_rule *a,
-               const struct lttng_event_rule *b);
-typedef ssize_t (*event_rule_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_event_rule **event_rule);
-typedef enum lttng_error_code (*event_rule_generate_filter_bytecode_cb)(
-               struct lttng_event_rule *event_rule,
-               const struct lttng_credentials *creds);
-typedef const char *(*event_rule_get_filter_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef const struct lttng_bytecode *(
-               *event_rule_get_filter_bytecode_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef enum lttng_event_rule_generate_exclusions_status (
-               *event_rule_generate_exclusions_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct lttng_event_exclusion **exclusions);
-typedef unsigned long (*event_rule_hash_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
-               const struct lttng_event_rule *event_rule);
-typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
-               const struct lttng_event_rule *event_rule,
-               struct mi_writer *writer);
+using event_rule_destroy_cb = void (*)(struct lttng_event_rule *);
+using event_rule_validate_cb = bool (*)(const struct lttng_event_rule *);
+using event_rule_serialize_cb = int (*)(const struct lttng_event_rule *, struct lttng_payload *);
+using event_rule_equal_cb = bool (*)(const struct lttng_event_rule *,
+                                    const struct lttng_event_rule *);
+using event_rule_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
+                                                     struct lttng_event_rule **);
+using event_rule_generate_filter_bytecode_cb =
+       enum lttng_error_code (*)(struct lttng_event_rule *, const struct lttng_credentials *);
+using event_rule_get_filter_cb = const char *(*) (const struct lttng_event_rule *);
+using event_rule_get_filter_bytecode_cb =
+       const struct lttng_bytecode *(*) (const struct lttng_event_rule *);
+using event_rule_generate_exclusions_cb = enum lttng_event_rule_generate_exclusions_status (*)(
+       const struct lttng_event_rule *, struct lttng_event_exclusion **);
+using event_rule_hash_cb = unsigned long (*)(const struct lttng_event_rule *);
+using event_rule_generate_lttng_event_cb = struct lttng_event *(*) (const struct lttng_event_rule *);
+using event_rule_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_event_rule *,
+                                                            struct mi_writer *);
 
 struct lttng_event_rule {
        struct urcu_ref ref;
index 07c546f9d3d0d66d1ec4f83ee42a75bbc8f0bd5e..ec8740a62534dafb5f1099269ddb2b0253317954 100644 (file)
@@ -22,23 +22,17 @@ struct lttng_payload_view;
 struct lttng_dynamic_buffer;
 struct mi_writer;
 
-typedef bool (*kernel_probe_location_equal_cb)(
-               const struct lttng_kernel_probe_location *a,
-               const struct lttng_kernel_probe_location *b);
-typedef int (*kernel_probe_location_serialize_cb)(
-               const struct lttng_kernel_probe_location *kernel_probe_location,
-               struct lttng_payload *payload);
-typedef bool (*kernel_probe_location_equal_cb)(
-               const struct lttng_kernel_probe_location *a,
-               const struct lttng_kernel_probe_location *b);
-typedef ssize_t (*kernel_probe_location_create_from_payload_cb)(
-               struct lttng_payload_view *view,
-               struct lttng_kernel_probe_location **kernel_probe_location);
-typedef unsigned long (*kernel_probe_location_hash_cb)(
-               const struct lttng_kernel_probe_location *location);
-typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
-               const struct lttng_kernel_probe_location *location,
-               struct mi_writer *writer);
+using kernel_probe_location_equal_cb = bool (*)(const struct lttng_kernel_probe_location *,
+                                               const struct lttng_kernel_probe_location *);
+using kernel_probe_location_serialize_cb = int (*)(const struct lttng_kernel_probe_location *,
+                                                  struct lttng_payload *);
+using kernel_probe_location_equal_cb = bool (*)(const struct lttng_kernel_probe_location *,
+                                               const struct lttng_kernel_probe_location *);
+using kernel_probe_location_create_from_payload_cb =
+       ssize_t (*)(struct lttng_payload_view *, struct lttng_kernel_probe_location **);
+using kernel_probe_location_hash_cb = unsigned long (*)(const struct lttng_kernel_probe_location *);
+using kernel_probe_location_mi_serialize_cb =
+       enum lttng_error_code (*)(const struct lttng_kernel_probe_location *, struct mi_writer *);
 
 struct lttng_kernel_probe_location_comm {
        /* enum lttng_kernel_probe_location_type */
index a02ae4cdc1229a627226e74991cebb49887b4820..68b6efd1b8b6a8290a964fe0ee045cdd553b2508 100644 (file)
@@ -10,8 +10,7 @@
  *
  */
 
-
-typedef void (*lttng_release_func)(void *);
+using lttng_release_func = void (*)(void *);
 
 struct lttng_ref {
        unsigned long count;
index 392242daecfed435ce9f7842c8584c1ce9747116..f4e6ee74eb887e4619cb62cddfdb0f81df4cce0c 100644 (file)
@@ -9,9 +9,12 @@
 #ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H
 #define LTTNG_USERSPACE_PROBE_INTERNAL_H
 
-#include <lttng/userspace-probe.h>
-#include <common/macros.hpp>
 #include <common/fd-handle.hpp>
+#include <common/macros.hpp>
+
+#include <lttng/lttng-error.h>
+#include <lttng/userspace-probe.h>
+
 #include <stdbool.h>
 
 struct lttng_payload;
@@ -19,14 +22,12 @@ struct lttng_payload_view;
 struct lttng_dynamic_buffer;
 struct mi_writer;
 
-typedef bool (*userspace_probe_location_equal_cb)(
-               const struct lttng_userspace_probe_location *a,
-               const struct lttng_userspace_probe_location *b);
-typedef unsigned long (*userspace_probe_location_hash_cb)(
-               const struct lttng_userspace_probe_location *location);
-typedef enum lttng_error_code (*userspace_probe_location_mi)(
-               const struct lttng_userspace_probe_location *location,
-               struct mi_writer);
+using userspace_probe_location_equal_cb = bool (*)(const struct lttng_userspace_probe_location *,
+                                                  const struct lttng_userspace_probe_location *);
+using userspace_probe_location_hash_cb =
+       unsigned long (*)(const struct lttng_userspace_probe_location *);
+using userspace_probe_location_mi =
+       enum lttng_error_code (*)(const struct lttng_userspace_probe_location *, struct mi_writer);
 
 /*
  * No elf-specific comm structure is defined since no elf-specific payload is
index e7dfa845d0fa8e80988ef28fcf4d9a4de1828e24..87e94bd82b7ad26e9db0fd99338d47576da07740 100644 (file)
@@ -116,9 +116,9 @@ struct action_work_subitem {
  * Only return non-zero on a fatal error that should shut down the action
  * executor.
  */
-typedef int (*action_executor_handler)(struct action_executor *executor,
-                                      const struct action_work_item *,
-                                      struct action_work_subitem *item);
+using action_executor_handler = int (*)(struct action_executor *,
+                                       const struct action_work_item *,
+                                       struct action_work_subitem *);
 
 static int action_executor_notify_handler(struct action_executor *executor,
                                          const struct action_work_item *,
index 15b3b9db97e0c15117162e37814fe1db65da9ec3..323c673735ee8e6005fddf27d0c3a42acc7243f6 100644 (file)
 #include <urcu/rculist.h>
 #include <urcu/uatomic.h>
 
-typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
-       const struct lttng_event_rule *rule, const char **pattern);
-typedef enum lttng_event_rule_status (*event_rule_logging_get_log_level_rule)(
-       const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule);
+using event_rule_logging_get_name_pattern =
+       enum lttng_event_rule_status (*)(const struct lttng_event_rule *, const char **);
+using event_rule_logging_get_log_level_rule = enum lttng_event_rule_status (*)(
+       const struct lttng_event_rule *, const struct lttng_log_level_rule **);
 
 /*
  * Agent application context representation.
index 8727e741bca66a715237ed5e275c0000fc0d1a01..445eda80c95aece5d4e9bf66791b659e94e298d4 100644 (file)
@@ -25,7 +25,7 @@ struct lttng_dynamic_buffer;
  * completed successfully. On failure, the handler's return code should
  * be the only reply sent to the client.
  */
-typedef enum lttng_error_code (*completion_handler_function)(void *);
+using completion_handler_function = enum lttng_error_code (*)(void *);
 struct cmd_completion_handler {
        completion_handler_function run;
        void *data;
index 1cab09d9707347530d34c1b5bbb5e87f46aec1b4..f711727c32342606b0d8b067e6911f87d7a5984f 100644 (file)
@@ -239,10 +239,9 @@ bool notification_client_list_get(struct notification_client_list *list);
 void notification_client_list_put(struct notification_client_list *list);
 
 /* Only returns a non-zero value if a fatal error occurred. */
-typedef int (*report_client_transmission_result_cb)(
-               struct notification_client *client,
-               enum client_transmission_status status,
-               void *user_data);
+using report_client_transmission_result_cb = int (*)(struct notification_client *,
+                                                    enum client_transmission_status,
+                                                    void *);
 
 int notification_client_list_send_evaluation(
                struct notification_client_list *list,
index 2ff86dc0613a04fb3e4e75618516c07fb83a9ccb..0c0740926ead3657ec01524e9834967cda7f957b 100644 (file)
@@ -21,7 +21,7 @@
 #include <urcu/list.h>
 #include <urcu/rculfhash.h>
 
-typedef uint64_t notification_client_id;
+using notification_client_id = uint64_t;
 
 /*
  * The notification thread holds no ownership of the tracer event source pipe
index 12ac3eb73f78e39afc3a982df278b869a88bc081..7673fe10c3952f20c9f53188625fe1510e740ede 100644 (file)
 
 struct ltt_ust_session;
 
-typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
-               void *user_data);
-typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
-               void *user_data);
+using ltt_session_destroy_notifier = void (*)(const struct ltt_session *, void *);
+using ltt_session_clear_notifier = void (*)(const struct ltt_session *, void *);
 
 namespace lttng {
 namespace sessiond {
index 530f72a8e446e3a9c1a2b188ccaaf415129b7625..cc1cbd13d209f1bde11d96bb0cfc28dd48bba9b8 100644 (file)
 struct lttng_thread;
 
 /* Main function of the new thread. */
-typedef void *(*lttng_thread_entry_point)(void *);
+using lttng_thread_entry_point = void *(*) (void *);
 
 /* Callback invoked to initiate the shutdown a thread. */
-typedef bool (*lttng_thread_shutdown_cb)(void *);
+using lttng_thread_shutdown_cb = bool (*)(void *);
 
 /*
  * Callback invoked to clean-up the thread data.
@@ -24,7 +24,7 @@ typedef bool (*lttng_thread_shutdown_cb)(void *);
  * race between a use by the "thread shutdown callback" and
  * a use by the thread itself.
  */
-typedef void (*lttng_thread_cleanup_cb)(void *);
+using lttng_thread_cleanup_cb = void (*)(void *);
 
 /*
  * Returns a reference to the newly-created thread.
index 78be73ea758062d96322cab5c2e54c1643d8f6e7..ea47c51f4ba694e2d596a7f9356343fea83e930b 100644 (file)
@@ -32,12 +32,12 @@ static const char help_msg[] =
 
 #define INDENTATION_LEVEL_STR "  "
 
-typedef enum lttng_event_rule_status (*event_rule_logging_get_name_pattern)(
-       const struct lttng_event_rule *rule, const char **pattern);
-typedef enum lttng_event_rule_status (*event_rule_logging_get_filter)(
-       const struct lttng_event_rule *rule, const char **expression);
-typedef enum lttng_event_rule_status (*event_rule_logging_get_log_level_rule)(
-       const struct lttng_event_rule *rule, const struct lttng_log_level_rule **log_level_rule);
+using event_rule_logging_get_name_pattern =
+       enum lttng_event_rule_status (*)(const struct lttng_event_rule *, const char **);
+using event_rule_logging_get_filter =
+       enum lttng_event_rule_status (*)(const struct lttng_event_rule *, const char **);
+using event_rule_logging_get_log_level_rule = enum lttng_event_rule_status (*)(
+       const struct lttng_event_rule *, const struct lttng_log_level_rule **);
 
 enum {
        OPT_HELP,
index a25ee3e1572bfd79e6c5312f1cce8df32cea1d59..c93ac0474347abed141d26cdcf1f53d262ea0215 100644 (file)
 #define IS_ONCE_AFTER_N_RATE_POLICY(policy) \
        (lttng_rate_policy_get_type(policy) == LTTNG_RATE_POLICY_TYPE_ONCE_AFTER_N)
 
-typedef void (*rate_policy_destroy_cb)(struct lttng_rate_policy *rate_policy);
-typedef int (*rate_policy_serialize_cb)(struct lttng_rate_policy *rate_policy,
-                                       struct lttng_payload *payload);
-typedef bool (*rate_policy_equal_cb)(const struct lttng_rate_policy *a,
-                                    const struct lttng_rate_policy *b);
-typedef ssize_t (*rate_policy_create_from_payload_cb)(struct lttng_payload_view *view,
-                                                     struct lttng_rate_policy **rate_policy);
-typedef struct lttng_rate_policy *(*rate_policy_copy_cb)(const struct lttng_rate_policy *source);
-typedef enum lttng_error_code (*rate_policy_mi_serialize_cb)(
-       const struct lttng_rate_policy *rate_policy, struct mi_writer *writer);
+using rate_policy_destroy_cb = void (*)(struct lttng_rate_policy *);
+using rate_policy_serialize_cb = int (*)(struct lttng_rate_policy *, struct lttng_payload *);
+using rate_policy_equal_cb = bool (*)(const struct lttng_rate_policy *,
+                                     const struct lttng_rate_policy *);
+using rate_policy_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
+                                                      struct lttng_rate_policy **);
+using rate_policy_copy_cb = struct lttng_rate_policy *(*) (const struct lttng_rate_policy *);
+using rate_policy_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_rate_policy *,
+                                                             struct mi_writer *);
 
 struct lttng_rate_policy {
        enum lttng_rate_policy_type type;
index 4ed51dcfe14ec14ad0a782c0cdfa251d819f9142..426cc489dfd02e453dec7eeb7ce56fe53f741dad 100644 (file)
@@ -191,7 +191,7 @@ enum bytecode_op {
        NR_BYTECODE_OPS,
 };
 
-typedef uint8_t bytecode_opcode_t;
+using bytecode_opcode_t = uint8_t;
 
 struct load_op {
        bytecode_opcode_t op;
index 0f969554d79ae774bd03be16d177a9399919eef7..ced720e5a307edd66d91c34606119e3f376b9fc7 100644 (file)
@@ -29,8 +29,7 @@ enum lttng_directory_handle_rmdir_recursive_flags {
 
 struct lttng_directory_handle;
 
-typedef void (*lttng_directory_handle_destroy_cb)(
-               struct lttng_directory_handle *handle, void *data);
+using lttng_directory_handle_destroy_cb = void (*)(struct lttng_directory_handle *, void *);
 
 struct lttng_directory_handle {
        struct urcu_ref ref;
index 66f3c3af3df1b5453de0ea410b1e0908c4518435..c1aa9d38d357cfb688ecf76c6daf00dded320c93 100644 (file)
@@ -153,7 +153,7 @@ end:
 
 #define LTTNG_SOCK_CREDS SCM_CREDENTIALS
 
-typedef struct ucred lttng_sock_cred;
+using lttng_sock_cred = struct ucred;
 
 #define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
 #define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
index fa496336d8643e84018e2ca286018b70078fad50..864ef6e9f7b57bf0be8cf44df0df1c8d9540c048 100644 (file)
 #include <inttypes.h>
 #include <signal.h>
 
-typedef int (*sample_positions_cb)(struct lttng_consumer_stream *stream);
-typedef int (*get_consumed_cb)(struct lttng_consumer_stream *stream, unsigned long *consumed);
-typedef int (*get_produced_cb)(struct lttng_consumer_stream *stream, unsigned long *produced);
-typedef int (*flush_index_cb)(struct lttng_consumer_stream *stream);
+using sample_positions_cb = int (*)(struct lttng_consumer_stream *);
+using get_consumed_cb = int (*)(struct lttng_consumer_stream *, unsigned long *);
+using get_produced_cb = int (*)(struct lttng_consumer_stream *, unsigned long *);
+using flush_index_cb = int (*)(struct lttng_consumer_stream *);
 
 static struct timer_signal_data timer_signal = {
        .tid = 0,
index fb7f59bb21883ec8c8888c1069ab66020b548d45..cd8b89457f07bed43b631b544416bb23f3b284a8 100644 (file)
@@ -313,7 +313,7 @@ enum get_next_subbuffer_status {
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
+using on_wake_up_cb = int (*)(struct lttng_consumer_stream *);
 
 /*
  * Perform any operation required before a consumer stream is put
@@ -321,16 +321,15 @@ typedef int (*on_wake_up_cb)(struct lttng_consumer_stream *);
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*on_sleep_cb)(struct lttng_consumer_stream *,
-               struct lttng_consumer_local_data *);
+using on_sleep_cb = int (*)(struct lttng_consumer_stream *, struct lttng_consumer_local_data *);
 
 /*
  * Acquire the subbuffer at the current 'consumed' position.
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
-               struct lttng_consumer_stream *, struct stream_subbuffer *);
+using get_next_subbuffer_cb = enum get_next_subbuffer_status (*)(struct lttng_consumer_stream *,
+                                                                struct stream_subbuffer *);
 
 /*
  * Populate the stream_subbuffer's info member. The info to populate
@@ -338,25 +337,25 @@ typedef enum get_next_subbuffer_status (*get_next_subbuffer_cb)(
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*extract_subbuffer_info_cb)(
-               struct lttng_consumer_stream *, struct stream_subbuffer *);
+using extract_subbuffer_info_cb = int (*)(struct lttng_consumer_stream *,
+                                         struct stream_subbuffer *);
 
 /*
  * Invoked after a subbuffer's info has been filled.
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*pre_consume_subbuffer_cb)(struct lttng_consumer_stream *,
-               const struct stream_subbuffer *);
+using pre_consume_subbuffer_cb = int (*)(struct lttng_consumer_stream *,
+                                        const struct stream_subbuffer *);
 
 /*
  * Consume subbuffer contents.
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
-               struct lttng_consumer_stream *,
-               const struct stream_subbuffer *);
+using consume_subbuffer_cb = ssize_t (*)(struct lttng_consumer_local_data *,
+                                        struct lttng_consumer_stream *,
+                                        const struct stream_subbuffer *);
 
 /*
  * Release the current subbuffer and advance the 'consumed' position by
@@ -364,31 +363,30 @@ typedef ssize_t (*consume_subbuffer_cb)(struct lttng_consumer_local_data *,
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*put_next_subbuffer_cb)(struct lttng_consumer_stream *,
-               struct stream_subbuffer *);
+using put_next_subbuffer_cb = int (*)(struct lttng_consumer_stream *, struct stream_subbuffer *);
 
 /*
  * Invoked after consuming a subbuffer.
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*post_consume_cb)(struct lttng_consumer_stream *,
-               const struct stream_subbuffer *,
-               struct lttng_consumer_local_data *);
+using post_consume_cb = int (*)(struct lttng_consumer_stream *,
+                               const struct stream_subbuffer *,
+                               struct lttng_consumer_local_data *);
 
 /*
  * Send a live beacon if no data is available.
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef int (*send_live_beacon_cb)(struct lttng_consumer_stream *);
+using send_live_beacon_cb = int (*)(struct lttng_consumer_stream *);
 
 /*
  * Lock the stream and channel locks and any other stream-type specific
  * lock that need to be acquired during the processing of an
  * availability notification.
  */
-typedef void (*lock_cb)(struct lttng_consumer_stream *);
+using lock_cb = void (*)(struct lttng_consumer_stream *);
 
 /*
  * Unlock the stream and channel locks and any other stream-type specific
@@ -396,14 +394,14 @@ typedef void (*lock_cb)(struct lttng_consumer_stream *);
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef void (*unlock_cb)(struct lttng_consumer_stream *);
+using unlock_cb = void (*)(struct lttng_consumer_stream *);
 
 /*
  * Assert that the stream and channel lock and any other stream type specific
  * lock that need to be acquired during the processing of a read_subbuffer
  * operation is acquired.
  */
-typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
+using assert_locked_cb = void (*)(struct lttng_consumer_stream *);
 
 /*
  * Invoked when a subbuffer's metadata version does not match the last
@@ -411,7 +409,7 @@ typedef void (*assert_locked_cb)(struct lttng_consumer_stream *);
  *
  * Stream and channel locks are acquired during this call.
  */
-typedef void (*reset_metadata_cb)(struct lttng_consumer_stream *);
+using reset_metadata_cb = void (*)(struct lttng_consumer_stream *);
 
 /*
  * Internal representation of the streams, sessiond_key is used to identify
index 2c6961c88d2df0acb42942b4027313019900d6b2..dfa73faea1e9001e56b8653865fb19592745bca6 100644 (file)
@@ -12,8 +12,7 @@
 
 struct metadata_bucket;
 
-typedef ssize_t (*metadata_bucket_flush_cb)(
-               const struct stream_subbuffer *buffer, void *data);
+using metadata_bucket_flush_cb = ssize_t (*)(const struct stream_subbuffer *, void *);
 
 enum metadata_bucket_status {
        METADATA_BUCKET_STATUS_OK,
index 23f3a39b9fe2b78eb41be42af592270204191496..91ad060c41d9e6a0e84c7ef16cb86705d8caeb91 100644 (file)
@@ -10,8 +10,8 @@
 
 #include <common/dynamic-buffer.hpp>
 
-typedef void (*lttng_dynamic_array_element_destructor)(void *element);
-typedef void (*lttng_dynamic_pointer_array_destructor)(void *ptr);
+using lttng_dynamic_array_element_destructor = void (*)(void *);
+using lttng_dynamic_pointer_array_destructor = void (*)(void *);
 
 struct lttng_dynamic_array {
        struct lttng_dynamic_buffer buffer;
index a38c880bdfebdfc0e2cd9e6f28af8cf2601e19e2..b75fc91c4f83a384fb46fc655836c6f3dd56db0c 100644 (file)
@@ -26,7 +26,7 @@ struct fd_tracker;
  *
  * Must return zero on success. Negative values should map to a UNIX error code.
  */
-typedef int (*fd_open_cb)(void *, int *out_fds);
+using fd_open_cb = int (*)(void *, int *);
 
 /*
  * Callback to allow the user to close a now-untracked file descriptor. This
@@ -38,7 +38,7 @@ typedef int (*fd_open_cb)(void *, int *out_fds);
  *
  * Must return zero on success. Negative values should map to a UNIX error code.
  */
-typedef int (*fd_close_cb)(void *, int *in_fds);
+using fd_close_cb = int (*)(void *, int *);
 
 /*
  * Set the maximal number of fds that the process should be allowed to open at
diff --git a/src/common/filter/.clang-tidy b/src/common/filter/.clang-tidy
new file mode 100644 (file)
index 0000000..91aebac
--- /dev/null
@@ -0,0 +1 @@
+Checks: '-*,llvm-twine-local'
index 2b460b401ef669d87a3ab9da67e973a564914e59..ecafee229447cd8451c9bc82be2f5d967129c505 100644 (file)
@@ -32,7 +32,7 @@
 
 #ifndef YY_TYPEDEF_YY_SCANNER_T
 #define YY_TYPEDEF_YY_SCANNER_T
-typedef void* yyscan_t;
+using yyscan_t = void *;
 #endif
 
 extern int filter_parser_debug;
index 08824673d3e1e93165dabe2e0aa47739eb989689..5d1e1340972a1828c13f1917e315b5c2ba3b3ee1 100644 (file)
@@ -18,10 +18,10 @@ struct fs_handle;
  * to use an fd-tracker.
  */
 
-typedef int (*fs_handle_get_fd_cb)(struct fs_handle *);
-typedef void (*fs_handle_put_fd_cb)(struct fs_handle *);
-typedef int (*fs_handle_unlink_cb)(struct fs_handle *);
-typedef int (*fs_handle_close_cb)(struct fs_handle *);
+using fs_handle_get_fd_cb = int (*)(struct fs_handle *);
+using fs_handle_put_fd_cb = void (*)(struct fs_handle *);
+using fs_handle_unlink_cb = int (*)(struct fs_handle *);
+using fs_handle_close_cb = int (*)(struct fs_handle *);
 
 struct fs_handle {
        fs_handle_get_fd_cb get_fd;
index dee40ddfdf935e4a5f53a8852de6ad21d303e24e..1feab4d39d1328d8e3de0021c4b920d35b0bade9 100644 (file)
@@ -18,8 +18,8 @@
 
 LTTNG_EXPORT extern unsigned long lttng_ht_seed;
 
-typedef unsigned long (*hash_fct_type)(const void *_key, unsigned long seed);
-typedef cds_lfht_match_fct hash_match_fct;
+using hash_fct_type = unsigned long (*)(const void *, unsigned long);
+using hash_match_fct = cds_lfht_match_fct;
 
 enum lttng_ht_type {
        LTTNG_HT_TYPE_STRING,
index 3e4160596d339c18c8f9328a8910d0eb552a34df..d1712489a33c9216de928db650c14667519a3ce4 100644 (file)
@@ -25,7 +25,7 @@ struct config_entry {
  * config_entry_handler_cb may return negative value to indicate an error in
  * the configuration file.
  */
-typedef int (*config_entry_handler_cb)(const struct config_entry *, void *);
+using config_entry_handler_cb = int (*)(const struct config_entry *, void *);
 
 /*
  * Read a section's entries in an INI configuration file.
index 34b3654eae7b78e933aa1e3bc20287fca193f072..c91f686763776413fad4f242741abb3f641fdd4e 100644 (file)
@@ -39,8 +39,7 @@
 /* Make this header file easier to include in C++ code */
 #include <stdio.h>
 
-typedef int (*ini_entry_handler)(void *, const char *, const char *,
-               const char *);
+using ini_entry_handler = int (*)(void *, const char *, const char *, const char *);
 
 /*
  * Parse given INI-style file. May have [section]s, name=value pairs
index 182a189babc792fefcfe961e3d09c7b0a2a6f19f..c4ccf94140d5ddf377c2926068aaef6e3a897acb 100644 (file)
@@ -39,16 +39,14 @@ struct mi_lttng_version_data {
 };
 
 /* Error query callbacks. */
-typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb)(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results **results);
-typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb)(
-               const struct lttng_trigger *trigger,
-               struct lttng_error_query_results **results);
-typedef enum lttng_error_code (*mi_lttng_error_query_action_cb)(
-               const struct lttng_trigger *trigger,
-               const struct lttng_action_path *action_path,
-               struct lttng_error_query_results **results);
+using mi_lttng_error_query_trigger_cb = enum lttng_error_code (*)(
+       const struct lttng_trigger *, struct lttng_error_query_results **);
+using mi_lttng_error_query_condition_cb = enum lttng_error_code (*)(
+       const struct lttng_trigger *, struct lttng_error_query_results **);
+using mi_lttng_error_query_action_cb =
+       enum lttng_error_code (*)(const struct lttng_trigger *,
+                                 const struct lttng_action_path *,
+                                 struct lttng_error_query_results **);
 
 struct mi_lttng_error_query_callbacks {
        mi_lttng_error_query_trigger_cb trigger_cb;
index e2ed4fed95653c48d9ca05ec717d569cc33087f0..667b28cb8e3ed8ccba5ff33db7701b41ca80ba01 100644 (file)
@@ -65,7 +65,7 @@ enum run_as_cmd {
 namespace {
 struct run_as_data;
 struct run_as_ret;
-typedef int (*run_as_fct)(struct run_as_data *data, struct run_as_ret *ret_value);
+using run_as_fct = int (*)(struct run_as_data *, struct run_as_ret *);
 
 struct run_as_mkdir_data {
        int dirfd;
index 1732286b8ed631f4e5585f37e8f3e27bb030c9cc..be806afc2f141baa4640cb0aa9346dd2a22d6d9d 100644 (file)
@@ -29,7 +29,7 @@
  * A negative return value will cause the run-as process to exit with a non-zero
  * value.
  */
-typedef int (*post_fork_cleanup_cb)(void *user_data);
+using post_fork_cleanup_cb = int (*)(void *);
 
 int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
 int run_as_mkdirat_recursive(int dirfd, const char *path, mode_t mode,
index 8267af0ec8ba473cb27b83874c4aa0cda691608d..f38a93b90930b3abd357574a34f009d1807f17b1 100644 (file)
@@ -50,7 +50,7 @@ enum trace_chunk_mode {
  * since only one thread may access a chunk during its destruction (the last
  * to release its reference to the chunk).
  */
-typedef int (*chunk_command)(struct lttng_trace_chunk *trace_chunk);
+using chunk_command = int (*)(struct lttng_trace_chunk *);
 
 /* Move a completed trace chunk to the 'completed' trace archive folder. */
 static int lttng_trace_chunk_move_to_completed_post_release(struct lttng_trace_chunk *trace_chunk);
index 718136c445275534180674ff2181791fc4a45d5a..48b9d03f0e7ff2409802b6aede31e59ce276799d 100644 (file)
@@ -1910,8 +1910,8 @@ enum lttng_error_code
 lttng_userspace_probe_location_mi_serialize(const struct lttng_userspace_probe_location *location,
                                            struct mi_writer *writer)
 {
-       typedef enum lttng_error_code (*mi_fp)(const struct lttng_userspace_probe_location *,
-                                              struct mi_writer *);
+       using mi_fp = enum lttng_error_code (*)(const struct lttng_userspace_probe_location *,
+                                               struct mi_writer *);
 
        int ret;
        enum lttng_error_code ret_code;
index b8e2db90d0218d1f709ad9ef0bd5c57a623102e1..225855ef747f18aa8ceb231009f15e403de4e0a7 100644 (file)
@@ -65,7 +65,7 @@ static void epoll_pwait_int_max(FILE *validation_output_file);
 static void ppoll_concurrent_write(FILE *validation_output_file);
 static void epoll_pwait_concurrent_munmap(FILE *validation_output_file);
 
-typedef void (*test_case_cb)(FILE *output_file);
+using test_case_cb = void (*)(FILE *);
 
 namespace {
 const struct test_case {
index f730384f601f816ad3ca3ed65d99613a8e66b664..fe138c0b614e5c0c4e9d9c760369bd46f5705b9f 100644 (file)
 #define FIELD_NAME_MAX_LEN 256
 
 /* A callback to populate the condition capture descriptor. */
-typedef int (*condition_capture_desc_cb)(struct lttng_condition *condition);
+using condition_capture_desc_cb = int (*)(struct lttng_condition *);
 
 /* A callback for captured field validation. */
-typedef int (*validate_cb)(const struct lttng_event_field_value *event_field, unsigned iteration);
+using validate_cb = int (*)(const struct lttng_event_field_value *, unsigned int);
 
 int nb_args = 0;
 int named_pipe_args_start = 0;
@@ -1466,13 +1466,13 @@ static void create_tracepoint_event_rule_trigger(const char *event_pattern,
                                                 struct lttng_condition **condition,
                                                 struct lttng_trigger **trigger)
 {
-       typedef struct lttng_event_rule *(*event_rule_create)(void);
-       typedef enum lttng_event_rule_status (
-               *event_rule_set_name_pattern)(struct lttng_event_rule * rule, const char *pattern);
-       typedef enum lttng_event_rule_status (
-               *event_rule_set_filter)(struct lttng_event_rule * rule, const char *expression);
-       typedef enum lttng_event_rule_status (*event_rule_add_name_pattern_exclusion)(
-               struct lttng_event_rule * rule, const char *exclusion);
+       using event_rule_create = struct lttng_event_rule *(*) ();
+       using event_rule_set_name_pattern =
+               enum lttng_event_rule_status (*)(struct lttng_event_rule *, const char *);
+       using event_rule_set_filter =
+               enum lttng_event_rule_status (*)(struct lttng_event_rule *, const char *);
+       using event_rule_add_name_pattern_exclusion =
+               enum lttng_event_rule_status (*)(struct lttng_event_rule *, const char *);
 
        enum lttng_event_rule_status event_rule_status;
        struct lttng_action *tmp_action = NULL;
index 80bd96c27b9f893d2c340d166ba94a0079c22745..039b7bf3a239f99cf53bdc6d7da22f783119b252 100644 (file)
@@ -26,7 +26,7 @@ enum unregistration_trigger_instance {
        UNREGISTRATION_TRIGGER_INSTANCE_FROM_LISTING,
 };
 
-typedef void (*test_function)(enum unregistration_trigger_instance);
+using test_function = void (*)(enum unregistration_trigger_instance);
 
 static const char *get_trigger_name(const struct lttng_trigger *trigger)
 {
index 60d3b4027b0b1cfd6d348dd38d1b13455b52057d..fb8c1555301c6052a0a744ca84fcdaee7eccab9a 100644 (file)
@@ -32,7 +32,7 @@ int lttng_opt_mi;
  * Returns the number of tests that ran (irrespective of the result) or a
  * negative value on error (will abort all tests).
  */
-typedef int(test_func)(const char *test_base_path);
+using test_func = int(const char *);
 
 static test_func test_rmdir_fail_non_empty;
 static test_func test_rmdir_skip_non_empty;
index be4766c8a7f9e669add35214d62f7faaf280b1f2..d56116aae86d5ccfbd0eb1bff74e09281f5b1094 100644 (file)
@@ -59,11 +59,11 @@ struct tracepoint_test {
 };
 } /* namespace */
 
-typedef const char *(*log_level_name_getter)(int log_level);
+using log_level_name_getter = const char *(*) (int);
 
-typedef struct lttng_event_rule *(*event_rule_create)(void);
-typedef enum lttng_event_rule_status (*event_rule_set_log_level)(
-       struct lttng_event_rule *rule, const struct lttng_log_level_rule *log_level_rule);
+using event_rule_create = struct lttng_event_rule *(*) ();
+using event_rule_set_log_level = enum lttng_event_rule_status (*)(
+       struct lttng_event_rule *, const struct lttng_log_level_rule *);
 
 static void test_event_rule_kernel_tracepoint(void)
 {
This page took 0.044603 seconds and 4 git commands to generate.