From 740da7d5000ca1ffdcf14bda5096bf7ccfb86bdd Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 3 Sep 2021 17:31:29 -0400 Subject: [PATCH] common: compile libcompat as C++ MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I got errors like these for programs that use libcompat (usually through libcommon), but are still linked with gcc, rather than g++: CCLD filter-grammar-test /usr/bin/ld: ./.libs/libcommon.a(directory-handle.o):(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `_ _gxx_personality_v0' Automake still links them with gcc, because they don't contain any C++ source directly. Fix that by changing them to be C++ source. Change-Id: I3eeca3d9af8940795b69f48d306f282ae0b08589 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- include/lttng/action/rate-policy-internal.h | 9 ++++ include/lttng/event-expr-internal.h | 8 ++++ include/lttng/kernel-probe-internal.h | 9 ++++ include/lttng/log-level-rule-internal.h | 1 + src/common/Makefile.am | 2 +- src/common/compat/Makefile.am | 25 ++++++++--- .../{compat-fcntl.c => compat-fcntl.cpp} | 0 ...irectory-handle.c => directory-handle.cpp} | 17 ++++---- src/common/compat/fcntl.h | 8 ++++ src/common/compat/{poll.c => poll.cpp} | 4 +- ...grammar-test.c => filter-grammar-test.cpp} | 0 tests/unit/Makefile.am | 42 +++++++++---------- tests/unit/ini_config/Makefile.am | 2 +- .../{ini_config.c => ini_config.cpp} | 0 tests/unit/{test_action.c => test_action.cpp} | 0 ...est_buffer_view.c => test_buffer_view.cpp} | 0 .../{test_condition.c => test_condition.cpp} | 0 ...ory_handle.c => test_directory_handle.cpp} | 0 ...code.c => test_event_expr_to_bytecode.cpp} | 0 ...{test_event_rule.c => test_event_rule.cpp} | 0 ...{test_fd_tracker.c => test_fd_tracker.cpp} | 0 ...t_kernel_probe.c => test_kernel_probe.cpp} | 0 ...g_level_rule.c => test_log_level_rule.cpp} | 0 ...t_notification.c => test_notification.cpp} | 0 .../unit/{test_payload.c => test_payload.cpp} | 0 ...est_rate_policy.c => test_rate_policy.cpp} | 0 ...t_string_utils.c => test_string_utils.cpp} | 4 +- ...est_unix_socket.c => test_unix_socket.cpp} | 4 +- tests/unit/{test_uri.c => test_uri.cpp} | 0 ...mpat_poll.c => test_utils_compat_poll.cpp} | 8 ++-- ...thread.c => test_utils_compat_pthread.cpp} | 0 ...pand_path.c => test_utils_expand_path.cpp} | 4 +- ...fix.c => test_utils_parse_size_suffix.cpp} | 0 ...fix.c => test_utils_parse_time_suffix.cpp} | 0 tests/unit/{test_uuid.c => test_uuid.cpp} | 0 35 files changed, 100 insertions(+), 47 deletions(-) rename src/common/compat/{compat-fcntl.c => compat-fcntl.cpp} (100%) rename src/common/compat/{directory-handle.c => directory-handle.cpp} (98%) rename src/common/compat/{poll.c => poll.cpp} (98%) rename src/common/{filter-grammar-test.c => filter-grammar-test.cpp} (100%) rename tests/unit/ini_config/{ini_config.c => ini_config.cpp} (100%) rename tests/unit/{test_action.c => test_action.cpp} (100%) rename tests/unit/{test_buffer_view.c => test_buffer_view.cpp} (100%) rename tests/unit/{test_condition.c => test_condition.cpp} (100%) rename tests/unit/{test_directory_handle.c => test_directory_handle.cpp} (100%) rename tests/unit/{test_event_expr_to_bytecode.c => test_event_expr_to_bytecode.cpp} (100%) rename tests/unit/{test_event_rule.c => test_event_rule.cpp} (100%) rename tests/unit/{test_fd_tracker.c => test_fd_tracker.cpp} (100%) rename tests/unit/{test_kernel_probe.c => test_kernel_probe.cpp} (100%) rename tests/unit/{test_log_level_rule.c => test_log_level_rule.cpp} (100%) rename tests/unit/{test_notification.c => test_notification.cpp} (100%) rename tests/unit/{test_payload.c => test_payload.cpp} (100%) rename tests/unit/{test_rate_policy.c => test_rate_policy.cpp} (100%) rename tests/unit/{test_string_utils.c => test_string_utils.cpp} (98%) rename tests/unit/{test_unix_socket.c => test_unix_socket.cpp} (99%) rename tests/unit/{test_uri.c => test_uri.cpp} (100%) rename tests/unit/{test_utils_compat_poll.c => test_utils_compat_poll.cpp} (98%) rename tests/unit/{test_utils_compat_pthread.c => test_utils_compat_pthread.cpp} (100%) rename tests/unit/{test_utils_expand_path.c => test_utils_expand_path.cpp} (98%) rename tests/unit/{test_utils_parse_size_suffix.c => test_utils_parse_size_suffix.cpp} (100%) rename tests/unit/{test_utils_parse_time_suffix.c => test_utils_parse_time_suffix.cpp} (100%) rename tests/unit/{test_uuid.c => test_uuid.cpp} (100%) diff --git a/include/lttng/action/rate-policy-internal.h b/include/lttng/action/rate-policy-internal.h index c04cabcb2..2f8267a31 100644 --- a/include/lttng/action/rate-policy-internal.h +++ b/include/lttng/action/rate-policy-internal.h @@ -11,8 +11,13 @@ #include #include #include +#include #include +#ifdef __cplusplus +extern "C" { +#endif + struct mi_writer; int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy, @@ -37,4 +42,8 @@ enum lttng_error_code lttng_rate_policy_mi_serialize( const struct lttng_rate_policy *policy, struct mi_writer *writer); +#ifdef __cplusplus +} +#endif + #endif /* LTTNG_RATE_POLICY */ diff --git a/include/lttng/event-expr-internal.h b/include/lttng/event-expr-internal.h index 469fd17bb..d40f2fa01 100644 --- a/include/lttng/event-expr-internal.h +++ b/include/lttng/event-expr-internal.h @@ -11,6 +11,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + struct lttng_bytecode; struct mi_writer; @@ -64,4 +68,8 @@ enum lttng_error_code lttng_event_expr_mi_serialize( const struct lttng_event_expr *expression, struct mi_writer *writer); +#ifdef __cplusplus +} +#endif + #endif /* LTTNG_EVENT_EXPR_INTERNAL_H */ diff --git a/include/lttng/kernel-probe-internal.h b/include/lttng/kernel-probe-internal.h index 06c3d7c7e..e0b94749e 100644 --- a/include/lttng/kernel-probe-internal.h +++ b/include/lttng/kernel-probe-internal.h @@ -11,10 +11,15 @@ #include #include #include +#include #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + struct lttng_payload; struct lttng_payload_view; struct lttng_dynamic_buffer; @@ -106,4 +111,8 @@ enum lttng_error_code lttng_kernel_probe_location_mi_serialize( const struct lttng_kernel_probe_location *location, struct mi_writer *writer); +#ifdef __cplusplus +} +#endif + #endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */ diff --git a/include/lttng/log-level-rule-internal.h b/include/lttng/log-level-rule-internal.h index b02afafe0..26abaa862 100644 --- a/include/lttng/log-level-rule-internal.h +++ b/include/lttng/log-level-rule-internal.h @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 5d1904d9c..cb8ac7b10 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -175,7 +175,7 @@ noinst_HEADERS = \ utils.h noinst_PROGRAMS = filter-grammar-test -filter_grammar_test_SOURCES = filter-grammar-test.c +filter_grammar_test_SOURCES = filter-grammar-test.cpp filter_grammar_test_LDADD = \ libcommon.la diff --git a/src/common/compat/Makefile.am b/src/common/compat/Makefile.am index a8f2c1001..0499b3568 100644 --- a/src/common/compat/Makefile.am +++ b/src/common/compat/Makefile.am @@ -2,8 +2,23 @@ noinst_LTLIBRARIES = libcompat.la -libcompat_la_SOURCES = poll.c poll.h fcntl.h endian.h mman.h dirent.h \ - socket.h compat-fcntl.c tid.h \ - getenv.h string.h paths.h pthread.h netdb.h \ - time.h directory-handle.h directory-handle.c path.h \ - errno.h +libcompat_la_SOURCES = \ + compat-fcntl.cpp \ + directory-handle.cpp \ + directory-handle.h \ + dirent.h \ + endian.h \ + errno.h \ + fcntl.h \ + getenv.h \ + mman.h \ + netdb.h \ + path.h \ + paths.h \ + poll.cpp \ + poll.h \ + pthread.h \ + socket.h \ + string.h \ + tid.h \ + time.h diff --git a/src/common/compat/compat-fcntl.c b/src/common/compat/compat-fcntl.cpp similarity index 100% rename from src/common/compat/compat-fcntl.c rename to src/common/compat/compat-fcntl.cpp diff --git a/src/common/compat/directory-handle.c b/src/common/compat/directory-handle.cpp similarity index 98% rename from src/common/compat/directory-handle.c rename to src/common/compat/directory-handle.cpp index 9b98e0482..edd82ebb6 100644 --- a/src/common/compat/directory-handle.c +++ b/src/common/compat/directory-handle.cpp @@ -101,9 +101,8 @@ void lttng_directory_handle_release(struct urcu_ref *ref); struct lttng_directory_handle *lttng_directory_handle_create(const char *path) { - const struct lttng_directory_handle cwd_handle = { - .dirfd = AT_FDCWD, - }; + lttng_directory_handle cwd_handle {}; + cwd_handle.dirfd = AT_FDCWD; /* Open a handle to the CWD if NULL is passed. */ return lttng_directory_handle_create_from_handle(path, &cwd_handle); @@ -148,7 +147,7 @@ struct lttng_directory_handle *lttng_directory_handle_create_from_dirfd( int dirfd) { int ret; - struct lttng_directory_handle *handle = zmalloc(sizeof(*handle)); + struct lttng_directory_handle *handle = (lttng_directory_handle *) zmalloc(sizeof(*handle)); struct stat stat_buf; if (!handle) { @@ -1164,7 +1163,7 @@ static void rmdir_frame_fini(void *data) { int ret; - struct rmdir_frame *frame = data; + struct rmdir_frame *frame = (rmdir_frame *) data; ret = closedir(frame->dir); if (ret == -1) { @@ -1230,7 +1229,7 @@ int remove_directory_recursive(const struct lttng_directory_handle *handle, while (lttng_dynamic_array_get_count(&frames) > 0) { struct dirent *entry; struct rmdir_frame *current_frame = - lttng_dynamic_array_get_element( + (rmdir_frame *) lttng_dynamic_array_get_element( &frames, current_frame_idx); LTTNG_ASSERT(current_frame->dir); @@ -1288,12 +1287,12 @@ int remove_directory_recursive(const struct lttng_directory_handle *handle, } } else { struct rmdir_frame new_frame = { - .path_size = current_path.size, + .parent_frame_idx = (ssize_t) current_frame_idx, .dir = lttng_directory_handle_opendir( handle, current_path.data), .empty = true, - .parent_frame_idx = current_frame_idx, + .path_size = current_path.size, }; if (!new_frame.dir) { @@ -1339,7 +1338,7 @@ int remove_directory_recursive(const struct lttng_directory_handle *handle, } else if (current_frame->parent_frame_idx >= 0) { struct rmdir_frame *parent_frame; - parent_frame = lttng_dynamic_array_get_element(&frames, + parent_frame = (rmdir_frame *) lttng_dynamic_array_get_element(&frames, current_frame->parent_frame_idx); LTTNG_ASSERT(parent_frame); parent_frame->empty = false; diff --git a/src/common/compat/fcntl.h b/src/common/compat/fcntl.h index b18e2f4e7..8bbdfe89c 100644 --- a/src/common/compat/fcntl.h +++ b/src/common/compat/fcntl.h @@ -13,6 +13,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #if (defined(__CYGWIN__)) typedef long long off64_t; #endif @@ -64,4 +68,8 @@ static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_ #error "Please add support for your OS." #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */ +#ifdef __cplusplus +} +#endif + #endif /* _COMPAT_FCNTL_H */ diff --git a/src/common/compat/poll.c b/src/common/compat/poll.cpp similarity index 98% rename from src/common/compat/poll.c rename to src/common/compat/poll.cpp index 9da2470d0..928867ffb 100644 --- a/src/common/compat/poll.c +++ b/src/common/compat/poll.cpp @@ -49,7 +49,7 @@ static int resize_poll_event(struct lttng_poll_event *events, LTTNG_ASSERT(events); - ptr = realloc(events->events, new_size * sizeof(*ptr)); + ptr = (epoll_event *) realloc(events->events, new_size * sizeof(*ptr)); if (ptr == NULL) { PERROR("realloc epoll add"); goto error; @@ -100,7 +100,7 @@ int compat_epoll_create(struct lttng_poll_event *events, int size, int flags) events->epfd = ret; /* This *must* be freed by using lttng_poll_free() */ - events->events = zmalloc(size * sizeof(struct epoll_event)); + events->events = (epoll_event *) zmalloc(size * sizeof(struct epoll_event)); if (events->events == NULL) { PERROR("zmalloc epoll set"); goto error_close; diff --git a/src/common/filter-grammar-test.c b/src/common/filter-grammar-test.cpp similarity index 100% rename from src/common/filter-grammar-test.c rename to src/common/filter-grammar-test.cpp diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index e1e538657..a311bc3e4 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -78,7 +78,7 @@ TESTS += test_ust_data endif # URI unit tests -test_uri_SOURCES = test_uri.c +test_uri_SOURCES = test_uri.cpp test_uri_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBHASHTABLE) $(DL_LIBS) RELAYD_OBJS = $(top_builddir)/src/bin/lttng-relayd/backward-compatibility-group-by.$(OBJEXT) @@ -103,46 +103,46 @@ test_kernel_data_LDADD = $(LIBTAP) $(LIBLTTNG_SESSIOND_COMMON) $(DL_LIBS) # utils suffix for unit test # parse_size_suffix unit test -test_utils_parse_size_suffix_SOURCES = test_utils_parse_size_suffix.c +test_utils_parse_size_suffix_SOURCES = test_utils_parse_size_suffix.cpp test_utils_parse_size_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) $(DL_LIBS) # parse_time_suffix unit test -test_utils_parse_time_suffix_SOURCES = test_utils_parse_time_suffix.c +test_utils_parse_time_suffix_SOURCES = test_utils_parse_time_suffix.cpp test_utils_parse_time_suffix_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) # compat_poll unit test -test_utils_compat_poll_SOURCES = test_utils_compat_poll.c +test_utils_compat_poll_SOURCES = test_utils_compat_poll.cpp test_utils_compat_poll_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(DL_LIBS) \ $(top_builddir)/src/common/compat/libcompat.la $(LIBCOMMON) # compat_pthread unit test -test_utils_compat_pthread_SOURCES = test_utils_compat_pthread.c +test_utils_compat_pthread_SOURCES = test_utils_compat_pthread.cpp test_utils_compat_pthread_LDADD = $(LIBTAP) \ $(top_builddir)/src/common/compat/libcompat.la $(LIBCOMMON) # expand_path unit test -test_utils_expand_path_SOURCES = test_utils_expand_path.c +test_utils_expand_path_SOURCES = test_utils_expand_path.cpp test_utils_expand_path_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) $(DL_LIBS) # directory handle unit test -test_directory_handle_SOURCES = test_directory_handle.c +test_directory_handle_SOURCES = test_directory_handle.cpp test_directory_handle_LDADD = $(LIBTAP) $(LIBHASHTABLE) $(LIBCOMMON) $(DL_LIBS) # string utilities unit test -test_string_utils_SOURCES = test_string_utils.c +test_string_utils_SOURCES = test_string_utils.cpp test_string_utils_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBSTRINGUTILS) $(DL_LIBS) # Notification api -test_notification_SOURCES = test_notification.c +test_notification_SOURCES = test_notification.cpp test_notification_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(DL_LIBS) # Event rule api -test_event_rule_SOURCES = test_event_rule.c +test_event_rule_SOURCES = test_event_rule.cpp test_event_rule_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) \ $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT) # Condition api -test_condition_SOURCES = test_condition.c +test_condition_SOURCES = test_condition.cpp test_condition_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) # relayd backward compat for groou-by-session utilities @@ -151,42 +151,42 @@ test_relayd_backward_compat_group_by_session_LDADD = $(LIBTAP) $(LIBCOMMON) $(RE test_relayd_backward_compat_group_by_session_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/bin/lttng-relayd # rate policy object unit test -test_rate_policy_SOURCES = test_rate_policy.c +test_rate_policy_SOURCES = test_rate_policy.cpp test_rate_policy_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) \ $(top_builddir)/src/bin/lttng/lttng-loglevel.$(OBJEXT) # fd tracker unit test -test_fd_tracker_SOURCES = test_fd_tracker.c +test_fd_tracker_SOURCES = test_fd_tracker.cpp test_fd_tracker_LDADD = $(LIBTAP) $(LIBFDTRACKER) $(DL_LIBS) $(URCU_LIBS) $(LIBCOMMON) $(LIBHASHTABLE) # uuid unit test -test_uuid_SOURCES = test_uuid.c +test_uuid_SOURCES = test_uuid.cpp test_uuid_LDADD = $(LIBTAP) $(LIBCOMMON) # buffer view unit test -test_buffer_view_SOURCES = test_buffer_view.c +test_buffer_view_SOURCES = test_buffer_view.cpp test_buffer_view_LDADD = $(LIBTAP) $(LIBCOMMON) # payload unit test -test_payload_SOURCES = test_payload.c +test_payload_SOURCES = test_payload.cpp test_payload_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON) # unix socket test -test_unix_socket_SOURCES = test_unix_socket.c +test_unix_socket_SOURCES = test_unix_socket.cpp test_unix_socket_LDADD = $(LIBTAP) $(LIBSESSIOND_COMM) $(LIBCOMMON) # Kernel probe location api test -test_kernel_probe_SOURCES = test_kernel_probe.c +test_kernel_probe_SOURCES = test_kernel_probe.cpp test_kernel_probe_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) # # Event expression to bytecode test -test_event_expr_to_bytecode_SOURCES = test_event_expr_to_bytecode.c +test_event_expr_to_bytecode_SOURCES = test_event_expr_to_bytecode.cpp test_event_expr_to_bytecode_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(LIBCOMMON) # Log level rule api -test_log_level_rule_SOURCES = test_log_level_rule.c +test_log_level_rule_SOURCES = test_log_level_rule.cpp test_log_level_rule_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) # Action api -test_action_SOURCES = test_action.c +test_action_SOURCES = test_action.cpp test_action_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS) diff --git a/tests/unit/ini_config/Makefile.am b/tests/unit/ini_config/Makefile.am index 7f15f99c9..003969775 100644 --- a/tests/unit/ini_config/Makefile.am +++ b/tests/unit/ini_config/Makefile.am @@ -10,7 +10,7 @@ LIBHASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la noinst_PROGRAMS = ini_config EXTRA_DIST = test_ini_config sample.ini -ini_config_SOURCES = ini_config.c +ini_config_SOURCES = ini_config.cpp ini_config_LDADD = $(LIBTAP) $(LIBCONFIG) $(LIBCOMMON) $(LIBHASHTABLE) \ $(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la diff --git a/tests/unit/ini_config/ini_config.c b/tests/unit/ini_config/ini_config.cpp similarity index 100% rename from tests/unit/ini_config/ini_config.c rename to tests/unit/ini_config/ini_config.cpp diff --git a/tests/unit/test_action.c b/tests/unit/test_action.cpp similarity index 100% rename from tests/unit/test_action.c rename to tests/unit/test_action.cpp diff --git a/tests/unit/test_buffer_view.c b/tests/unit/test_buffer_view.cpp similarity index 100% rename from tests/unit/test_buffer_view.c rename to tests/unit/test_buffer_view.cpp diff --git a/tests/unit/test_condition.c b/tests/unit/test_condition.cpp similarity index 100% rename from tests/unit/test_condition.c rename to tests/unit/test_condition.cpp diff --git a/tests/unit/test_directory_handle.c b/tests/unit/test_directory_handle.cpp similarity index 100% rename from tests/unit/test_directory_handle.c rename to tests/unit/test_directory_handle.cpp diff --git a/tests/unit/test_event_expr_to_bytecode.c b/tests/unit/test_event_expr_to_bytecode.cpp similarity index 100% rename from tests/unit/test_event_expr_to_bytecode.c rename to tests/unit/test_event_expr_to_bytecode.cpp diff --git a/tests/unit/test_event_rule.c b/tests/unit/test_event_rule.cpp similarity index 100% rename from tests/unit/test_event_rule.c rename to tests/unit/test_event_rule.cpp diff --git a/tests/unit/test_fd_tracker.c b/tests/unit/test_fd_tracker.cpp similarity index 100% rename from tests/unit/test_fd_tracker.c rename to tests/unit/test_fd_tracker.cpp diff --git a/tests/unit/test_kernel_probe.c b/tests/unit/test_kernel_probe.cpp similarity index 100% rename from tests/unit/test_kernel_probe.c rename to tests/unit/test_kernel_probe.cpp diff --git a/tests/unit/test_log_level_rule.c b/tests/unit/test_log_level_rule.cpp similarity index 100% rename from tests/unit/test_log_level_rule.c rename to tests/unit/test_log_level_rule.cpp diff --git a/tests/unit/test_notification.c b/tests/unit/test_notification.cpp similarity index 100% rename from tests/unit/test_notification.c rename to tests/unit/test_notification.cpp diff --git a/tests/unit/test_payload.c b/tests/unit/test_payload.cpp similarity index 100% rename from tests/unit/test_payload.c rename to tests/unit/test_payload.cpp diff --git a/tests/unit/test_rate_policy.c b/tests/unit/test_rate_policy.cpp similarity index 100% rename from tests/unit/test_rate_policy.c rename to tests/unit/test_rate_policy.cpp diff --git a/tests/unit/test_string_utils.c b/tests/unit/test_string_utils.cpp similarity index 98% rename from tests/unit/test_string_utils.c rename to tests/unit/test_string_utils.cpp index d2b0d905d..e20f88f7a 100644 --- a/tests/unit/test_string_utils.c +++ b/tests/unit/test_string_utils.cpp @@ -38,8 +38,8 @@ static void test_one_split(const char *input, char delim, int escape_delim, for (i = 0; i < string_count; i++) { const char *expected_substring = va_arg(vl, const char *); const char *substring = - lttng_dynamic_pointer_array_get_pointer( - &strings, i); + (const char *) lttng_dynamic_pointer_array_get_pointer( + &strings, i); diag(" got `%s`, expecting `%s`", substring, expected_substring); diff --git a/tests/unit/test_unix_socket.c b/tests/unit/test_unix_socket.cpp similarity index 99% rename from tests/unit/test_unix_socket.c rename to tests/unit/test_unix_socket.cpp index 8752ba941..2d59ba8ee 100644 --- a/tests/unit/test_unix_socket.c +++ b/tests/unit/test_unix_socket.cpp @@ -5,6 +5,7 @@ * */ +#include #include #include #include @@ -443,7 +444,8 @@ static void test_receive_in_chunks( } do { - const ssize_t to_receive_this_pass = min(max_recv_size, + const ssize_t to_receive_this_pass = + std::min(max_recv_size, sent_payload.buffer.size - received); sock_ret = lttcomm_recv_unix_sock(sockets[1], diff --git a/tests/unit/test_uri.c b/tests/unit/test_uri.cpp similarity index 100% rename from tests/unit/test_uri.c rename to tests/unit/test_uri.cpp diff --git a/tests/unit/test_utils_compat_poll.c b/tests/unit/test_utils_compat_poll.cpp similarity index 98% rename from tests/unit/test_utils_compat_poll.c rename to tests/unit/test_utils_compat_poll.cpp index 2581f57dd..eb6d94a5e 100644 --- a/tests/unit/test_utils_compat_poll.c +++ b/tests/unit/test_utils_compat_poll.cpp @@ -184,7 +184,7 @@ static void test_mod_wait(void) static void destroy_pipe(void *pipe) { - lttng_pipe_destroy(pipe); + lttng_pipe_destroy((lttng_pipe *) pipe); } static int run_active_set_combination(unsigned int fd_count, @@ -244,11 +244,13 @@ static int run_active_set_combination(unsigned int fd_count, continue; } - borrowed_pipe = lttng_dynamic_pointer_array_get_pointer( + borrowed_pipe = + (lttng_pipe *) lttng_dynamic_pointer_array_get_pointer( &pipes, i); + char c = 'a'; ret = lttng_pipe_write( - borrowed_pipe, &(char){'a'}, sizeof(char)); + borrowed_pipe, &c, sizeof(char)); if (ret != sizeof(char)) { diag("Failed to write to pipe"); ret = -1; diff --git a/tests/unit/test_utils_compat_pthread.c b/tests/unit/test_utils_compat_pthread.cpp similarity index 100% rename from tests/unit/test_utils_compat_pthread.c rename to tests/unit/test_utils_compat_pthread.cpp diff --git a/tests/unit/test_utils_expand_path.c b/tests/unit/test_utils_expand_path.cpp similarity index 98% rename from tests/unit/test_utils_expand_path.c rename to tests/unit/test_utils_expand_path.cpp index a55d7cf38..428acad22 100644 --- a/tests/unit/test_utils_expand_path.c +++ b/tests/unit/test_utils_expand_path.cpp @@ -131,14 +131,14 @@ static int prepare_valid_results(void) } /* allocate memory for the expected results */ - valid_tests_expected_results = zmalloc(sizeof(char *) * num_valid_tests); + valid_tests_expected_results = (char **) zmalloc(sizeof(char *) * num_valid_tests); if (!valid_tests_expected_results) { PRINT_ERR("out of memory"); ret = -1; goto end; } for (i = 0; i < num_valid_tests; i++) { - valid_tests_expected_results[i] = malloc(PATH_MAX); + valid_tests_expected_results[i] = (char *) malloc(PATH_MAX); if (valid_tests_expected_results[i] == NULL) { PRINT_ERR("malloc expected results"); ret = -1; diff --git a/tests/unit/test_utils_parse_size_suffix.c b/tests/unit/test_utils_parse_size_suffix.cpp similarity index 100% rename from tests/unit/test_utils_parse_size_suffix.c rename to tests/unit/test_utils_parse_size_suffix.cpp diff --git a/tests/unit/test_utils_parse_time_suffix.c b/tests/unit/test_utils_parse_time_suffix.cpp similarity index 100% rename from tests/unit/test_utils_parse_time_suffix.c rename to tests/unit/test_utils_parse_time_suffix.cpp diff --git a/tests/unit/test_uuid.c b/tests/unit/test_uuid.cpp similarity index 100% rename from tests/unit/test_uuid.c rename to tests/unit/test_uuid.cpp -- 2.34.1