From: Jérémie Galarneau Date: Fri, 13 Jan 2023 17:24:13 +0000 (-0500) Subject: Add a basic .clang-tidy file and fix typedef warnings X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e665dfbce25215d5ec77ff03a279c7163b337db1;p=lttng-tools.git Add a basic .clang-tidy file and fix typedef warnings 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 Change-Id: I074b6f2724e1af9a2df311e07a2fcdacb689bcf5 --- diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..af914d23b --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,3 @@ +HeaderFilterRegex: '.*((include/.*-internal)|(src/common.*)|(src/bin.*)|(src/lib.*)|(tests.*))\.(h|hpp)$' +Checks: '-*,modernize-use-using' +FormatStyle: 'file' diff --git a/include/lttng/action/action-internal.hpp b/include/lttng/action/action-internal.hpp index 996e166ec..e52d91f59 100644 --- a/include/lttng/action/action-internal.hpp +++ b/include/lttng/action/action-internal.hpp @@ -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; diff --git a/include/lttng/condition/condition-internal.hpp b/include/lttng/condition/condition-internal.hpp index 27407d07a..2fac62913 100644 --- a/include/lttng/condition/condition-internal.hpp +++ b/include/lttng/condition/condition-internal.hpp @@ -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. */ diff --git a/include/lttng/condition/evaluation-internal.hpp b/include/lttng/condition/evaluation-internal.hpp index f74927c24..ed2c5735f 100644 --- a/include/lttng/condition/evaluation-internal.hpp +++ b/include/lttng/condition/evaluation-internal.hpp @@ -17,10 +17,8 @@ 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 */ diff --git a/include/lttng/event-rule/event-rule-internal.hpp b/include/lttng/event-rule/event-rule-internal.hpp index 46fb98144..b1415cac7 100644 --- a/include/lttng/event-rule/event-rule-internal.hpp +++ b/include/lttng/event-rule/event-rule-internal.hpp @@ -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; diff --git a/include/lttng/kernel-probe-internal.hpp b/include/lttng/kernel-probe-internal.hpp index 07c546f9d..ec8740a62 100644 --- a/include/lttng/kernel-probe-internal.hpp +++ b/include/lttng/kernel-probe-internal.hpp @@ -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 */ diff --git a/include/lttng/ref-internal.hpp b/include/lttng/ref-internal.hpp index a02ae4cdc..68b6efd1b 100644 --- a/include/lttng/ref-internal.hpp +++ b/include/lttng/ref-internal.hpp @@ -10,8 +10,7 @@ * */ - -typedef void (*lttng_release_func)(void *); +using lttng_release_func = void (*)(void *); struct lttng_ref { unsigned long count; diff --git a/include/lttng/userspace-probe-internal.hpp b/include/lttng/userspace-probe-internal.hpp index 392242dae..f4e6ee74e 100644 --- a/include/lttng/userspace-probe-internal.hpp +++ b/include/lttng/userspace-probe-internal.hpp @@ -9,9 +9,12 @@ #ifndef LTTNG_USERSPACE_PROBE_INTERNAL_H #define LTTNG_USERSPACE_PROBE_INTERNAL_H -#include -#include #include +#include + +#include +#include + #include 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 diff --git a/src/bin/lttng-sessiond/action-executor.cpp b/src/bin/lttng-sessiond/action-executor.cpp index e7dfa845d..87e94bd82 100644 --- a/src/bin/lttng-sessiond/action-executor.cpp +++ b/src/bin/lttng-sessiond/action-executor.cpp @@ -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 *, diff --git a/src/bin/lttng-sessiond/agent.cpp b/src/bin/lttng-sessiond/agent.cpp index 15b3b9db9..323c67373 100644 --- a/src/bin/lttng-sessiond/agent.cpp +++ b/src/bin/lttng-sessiond/agent.cpp @@ -29,10 +29,10 @@ #include #include -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. diff --git a/src/bin/lttng-sessiond/cmd.hpp b/src/bin/lttng-sessiond/cmd.hpp index 8727e741b..445eda80c 100644 --- a/src/bin/lttng-sessiond/cmd.hpp +++ b/src/bin/lttng-sessiond/cmd.hpp @@ -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; diff --git a/src/bin/lttng-sessiond/notification-thread-internal.hpp b/src/bin/lttng-sessiond/notification-thread-internal.hpp index 1cab09d97..f711727c3 100644 --- a/src/bin/lttng-sessiond/notification-thread-internal.hpp +++ b/src/bin/lttng-sessiond/notification-thread-internal.hpp @@ -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, diff --git a/src/bin/lttng-sessiond/notification-thread.hpp b/src/bin/lttng-sessiond/notification-thread.hpp index 2ff86dc06..0c0740926 100644 --- a/src/bin/lttng-sessiond/notification-thread.hpp +++ b/src/bin/lttng-sessiond/notification-thread.hpp @@ -21,7 +21,7 @@ #include #include -typedef uint64_t notification_client_id; +using notification_client_id = uint64_t; /* * The notification thread holds no ownership of the tracer event source pipe diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp index 12ac3eb73..7673fe10c 100644 --- a/src/bin/lttng-sessiond/session.hpp +++ b/src/bin/lttng-sessiond/session.hpp @@ -28,10 +28,8 @@ 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 { diff --git a/src/bin/lttng-sessiond/thread.hpp b/src/bin/lttng-sessiond/thread.hpp index 530f72a8e..cc1cbd13d 100644 --- a/src/bin/lttng-sessiond/thread.hpp +++ b/src/bin/lttng-sessiond/thread.hpp @@ -13,10 +13,10 @@ 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. diff --git a/src/bin/lttng/commands/list_triggers.cpp b/src/bin/lttng/commands/list_triggers.cpp index 78be73ea7..ea47c51f4 100644 --- a/src/bin/lttng/commands/list_triggers.cpp +++ b/src/bin/lttng/commands/list_triggers.cpp @@ -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, diff --git a/src/common/actions/rate-policy.cpp b/src/common/actions/rate-policy.cpp index a25ee3e15..c93ac0474 100644 --- a/src/common/actions/rate-policy.cpp +++ b/src/common/actions/rate-policy.cpp @@ -26,16 +26,15 @@ #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; diff --git a/src/common/bytecode/bytecode.hpp b/src/common/bytecode/bytecode.hpp index 4ed51dcfe..426cc489d 100644 --- a/src/common/bytecode/bytecode.hpp +++ b/src/common/bytecode/bytecode.hpp @@ -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; diff --git a/src/common/compat/directory-handle.hpp b/src/common/compat/directory-handle.hpp index 0f969554d..ced720e5a 100644 --- a/src/common/compat/directory-handle.hpp +++ b/src/common/compat/directory-handle.hpp @@ -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; diff --git a/src/common/compat/socket.hpp b/src/common/compat/socket.hpp index 66f3c3af3..c1aa9d38d 100644 --- a/src/common/compat/socket.hpp +++ b/src/common/compat/socket.hpp @@ -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 diff --git a/src/common/consumer/consumer-timer.cpp b/src/common/consumer/consumer-timer.cpp index fa496336d..864ef6e9f 100644 --- a/src/common/consumer/consumer-timer.cpp +++ b/src/common/consumer/consumer-timer.cpp @@ -20,10 +20,10 @@ #include #include -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, diff --git a/src/common/consumer/consumer.hpp b/src/common/consumer/consumer.hpp index fb7f59bb2..cd8b89457 100644 --- a/src/common/consumer/consumer.hpp +++ b/src/common/consumer/consumer.hpp @@ -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 diff --git a/src/common/consumer/metadata-bucket.hpp b/src/common/consumer/metadata-bucket.hpp index 2c6961c88..dfa73faea 100644 --- a/src/common/consumer/metadata-bucket.hpp +++ b/src/common/consumer/metadata-bucket.hpp @@ -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, diff --git a/src/common/dynamic-array.hpp b/src/common/dynamic-array.hpp index 23f3a39b9..91ad060c4 100644 --- a/src/common/dynamic-array.hpp +++ b/src/common/dynamic-array.hpp @@ -10,8 +10,8 @@ #include -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; diff --git a/src/common/fd-tracker/fd-tracker.hpp b/src/common/fd-tracker/fd-tracker.hpp index a38c880bd..b75fc91c4 100644 --- a/src/common/fd-tracker/fd-tracker.hpp +++ b/src/common/fd-tracker/fd-tracker.hpp @@ -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 index 000000000..91aebac05 --- /dev/null +++ b/src/common/filter/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*,llvm-twine-local' diff --git a/src/common/filter/filter-ast.hpp b/src/common/filter/filter-ast.hpp index 2b460b401..ecafee229 100644 --- a/src/common/filter/filter-ast.hpp +++ b/src/common/filter/filter-ast.hpp @@ -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; diff --git a/src/common/fs-handle-internal.hpp b/src/common/fs-handle-internal.hpp index 08824673d..5d1e13409 100644 --- a/src/common/fs-handle-internal.hpp +++ b/src/common/fs-handle-internal.hpp @@ -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; diff --git a/src/common/hashtable/hashtable.hpp b/src/common/hashtable/hashtable.hpp index dee40ddfd..1feab4d39 100644 --- a/src/common/hashtable/hashtable.hpp +++ b/src/common/hashtable/hashtable.hpp @@ -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, diff --git a/src/common/ini-config/ini-config.hpp b/src/common/ini-config/ini-config.hpp index 3e4160596..d1712489a 100644 --- a/src/common/ini-config/ini-config.hpp +++ b/src/common/ini-config/ini-config.hpp @@ -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. diff --git a/src/common/ini-config/ini.hpp b/src/common/ini-config/ini.hpp index 34b3654ea..c91f68676 100644 --- a/src/common/ini-config/ini.hpp +++ b/src/common/ini-config/ini.hpp @@ -39,8 +39,7 @@ /* Make this header file easier to include in C++ code */ #include -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 diff --git a/src/common/mi-lttng.hpp b/src/common/mi-lttng.hpp index 182a189ba..c4ccf9414 100644 --- a/src/common/mi-lttng.hpp +++ b/src/common/mi-lttng.hpp @@ -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; diff --git a/src/common/runas.cpp b/src/common/runas.cpp index e2ed4fed9..667b28cb8 100644 --- a/src/common/runas.cpp +++ b/src/common/runas.cpp @@ -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; diff --git a/src/common/runas.hpp b/src/common/runas.hpp index 1732286b8..be806afc2 100644 --- a/src/common/runas.hpp +++ b/src/common/runas.hpp @@ -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, diff --git a/src/common/trace-chunk.cpp b/src/common/trace-chunk.cpp index 8267af0ec..f38a93b90 100644 --- a/src/common/trace-chunk.cpp +++ b/src/common/trace-chunk.cpp @@ -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); diff --git a/src/common/userspace-probe.cpp b/src/common/userspace-probe.cpp index 718136c44..48b9d03f0 100644 --- a/src/common/userspace-probe.cpp +++ b/src/common/userspace-probe.cpp @@ -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; diff --git a/tests/regression/kernel/select_poll_epoll.cpp b/tests/regression/kernel/select_poll_epoll.cpp index b8e2db90d..225855ef7 100644 --- a/tests/regression/kernel/select_poll_epoll.cpp +++ b/tests/regression/kernel/select_poll_epoll.cpp @@ -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 { diff --git a/tests/regression/tools/notification/notification.cpp b/tests/regression/tools/notification/notification.cpp index f730384f6..fe138c0b6 100644 --- a/tests/regression/tools/notification/notification.cpp +++ b/tests/regression/tools/notification/notification.cpp @@ -31,10 +31,10 @@ #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; diff --git a/tests/regression/tools/trigger/name/trigger_name.cpp b/tests/regression/tools/trigger/name/trigger_name.cpp index 80bd96c27..039b7bf3a 100644 --- a/tests/regression/tools/trigger/name/trigger_name.cpp +++ b/tests/regression/tools/trigger/name/trigger_name.cpp @@ -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) { diff --git a/tests/unit/test_directory_handle.cpp b/tests/unit/test_directory_handle.cpp index 60d3b4027..fb8c15553 100644 --- a/tests/unit/test_directory_handle.cpp +++ b/tests/unit/test_directory_handle.cpp @@ -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; diff --git a/tests/unit/test_event_rule.cpp b/tests/unit/test_event_rule.cpp index be4766c8a..d56116aae 100644 --- a/tests/unit/test_event_rule.cpp +++ b/tests/unit/test_event_rule.cpp @@ -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) {