From 8a35c6f10283f7448aaf0d84f9032badf14f5baa Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 23 Jul 2018 17:26:18 +0100 Subject: [PATCH 2/7] message-util: Make more functions static (and remove useless prefix) The naming convention dbus_internal_do_not_use_foo() was for functions that had to be exported by libdbus but called by the embedded tests. This is obsolete (in favour of _dbus_foo()) now that we have DBUS_PRIVATE_EXPORT, and is doubly useless in this case because these functions aren't even in libdbus - they're local to dbus-message-util.c. Signed-off-by: Simon McVittie --- dbus/dbus-message-util.c | 45 ++++++++++++++++++++++------------------ dbus/dbus-test.h | 14 ------------- 2 files changed, 25 insertions(+), 34 deletions(-) diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 7df28f11..29755a19 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -41,6 +41,14 @@ #include #endif +/* returns FALSE on fatal failure */ +typedef dbus_bool_t (* DBusForeachMessageFileFunc) (const DBusString *filename, + DBusValidity expected_validity, + void *data); + +static dbus_bool_t try_message_data (const DBusString *data, + DBusValidity expected_validity); + /** * @addtogroup DBusMessage * @{ @@ -417,9 +425,9 @@ check_loader_results (DBusMessageLoader *loader, * @param data string to load message into * @returns #TRUE if the message was loaded */ -dbus_bool_t -dbus_internal_do_not_use_load_message_file (const DBusString *filename, - DBusString *data) +static dbus_bool_t +load_message_file (const DBusString *filename, + DBusString *data) { dbus_bool_t retval; DBusError error = DBUS_ERROR_INIT; @@ -453,9 +461,9 @@ dbus_internal_do_not_use_load_message_file (const DBusString *filename, * @returns #TRUE if the message has the expected validity */ static dbus_bool_t -dbus_internal_do_not_use_try_message_file (const DBusString *filename, - DBusValidity expected_validity, - void *unused) +try_message_file (const DBusString *filename, + DBusValidity expected_validity, + void *unused) { DBusString data; dbus_bool_t retval; @@ -465,10 +473,10 @@ dbus_internal_do_not_use_try_message_file (const DBusString *filename, if (!_dbus_string_init (&data)) _dbus_test_fatal ("could not allocate string"); - if (!dbus_internal_do_not_use_load_message_file (filename, &data)) + if (!load_message_file (filename, &data)) goto failed; - retval = dbus_internal_do_not_use_try_message_data (&data, expected_validity); + retval = try_message_data (&data, expected_validity); failed: @@ -495,9 +503,9 @@ dbus_internal_do_not_use_try_message_file (const DBusString *filename, * @param expected_validity what the message has to be like to return #TRUE * @returns #TRUE if the message has the expected validity */ -dbus_bool_t -dbus_internal_do_not_use_try_message_data (const DBusString *data, - DBusValidity expected_validity) +static dbus_bool_t +try_message_data (const DBusString *data, + DBusValidity expected_validity) { DBusMessageLoader *loader; dbus_bool_t retval; @@ -710,10 +718,10 @@ process_test_subdir (const DBusString *test_base_dir, * @param user_data data for function * @returns #FALSE if there's a failure */ -dbus_bool_t -dbus_internal_do_not_use_foreach_message_file (const char *test_data_dir, - DBusForeachMessageFileFunc func, - void *user_data) +static dbus_bool_t +foreach_message_file (const char *test_data_dir, + DBusForeachMessageFileFunc func, + void *user_data) { DBusString test_directory; dbus_bool_t retval; @@ -1775,8 +1783,7 @@ _dbus_message_test (const char *test_data_dir) while (_dbus_message_data_iter_get_and_next (&diter, &mdata)) { - if (!dbus_internal_do_not_use_try_message_data (&mdata.data, - mdata.expected_validity)) + if (!try_message_data (&mdata.data, mdata.expected_validity)) { _dbus_test_fatal ("expected validity %d and did not get it", mdata.expected_validity); @@ -1802,9 +1809,7 @@ _dbus_message_test (const char *test_data_dir) initial_fds = _dbus_check_fdleaks_enter (); - if (!dbus_internal_do_not_use_foreach_message_file (test_data_dir, - dbus_internal_do_not_use_try_message_file, - NULL)) + if (!foreach_message_file (test_data_dir, try_message_file, NULL)) _dbus_test_fatal ("foreach_message_file test failed"); _dbus_check_fdleaks_leave (initial_fds); diff --git a/dbus/dbus-test.h b/dbus/dbus-test.h index dcffd8a1..89cb23b5 100644 --- a/dbus/dbus-test.h +++ b/dbus/dbus-test.h @@ -99,20 +99,6 @@ dbus_bool_t _dbus_credentials_test (const char *test_data_dir); void _dbus_run_tests (const char *test_data_dir, const char *specific_test); -dbus_bool_t dbus_internal_do_not_use_try_message_data (const DBusString *data, - DBusValidity expected_validity); -dbus_bool_t dbus_internal_do_not_use_load_message_file (const DBusString *filename, - DBusString *data); - - -/* returns FALSE on fatal failure */ -typedef dbus_bool_t (* DBusForeachMessageFileFunc) (const DBusString *filename, - DBusValidity expected_validity, - void *data); - -dbus_bool_t dbus_internal_do_not_use_foreach_message_file (const char *test_data_dir, - DBusForeachMessageFileFunc func, - void *user_data); dbus_bool_t dbus_internal_do_not_use_generate_bodies (int sequence, int byte_order, DBusString *signature, -- 2.18.0