From: Jérémie Galarneau Date: Fri, 31 Jan 2020 21:25:14 +0000 (-0500) Subject: Clean-up: remove instances of loop initial declarations X-Git-Tag: v2.12.0-rc1~18 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9df6c82a8ea4064f9868028b9fc3412f45adbb0a;p=lttng-tools.git Clean-up: remove instances of loop initial declarations Loop initial declarations are not permitted by the project's coding standard and cause the build to fail on Solaris platforms. tracker.c: In function 'lttng_tracker_ids_serialize': tracker.c:314:2: error: 'for' loop initial declarations are only allowed in C99 mode for (unsigned int i = 0; i < count; i++) { ^ Signed-off-by: Jérémie Galarneau Change-Id: I627974ef82ca26586c96d354f217f9943db9d67c --- diff --git a/src/common/tracker.c b/src/common/tracker.c index 312d7bce0..2c91d5d6e 100644 --- a/src/common/tracker.c +++ b/src/common/tracker.c @@ -284,11 +284,13 @@ end: void lttng_tracker_ids_destroy(struct lttng_tracker_ids *ids) { + int i; + if (!ids) { return; } - for (int i = 0; i < ids->count; i++) { + for (i = 0; i < ids->count; i++) { lttng_tracker_id_reset(&ids->id_array[i]); } free(ids->id_array); @@ -304,6 +306,7 @@ int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids, unsigned int count; enum lttng_tracker_id_status status; const struct lttng_tracker_id *id; + unsigned int i; status = lttng_tracker_ids_get_count(ids, &count); if (status != LTTNG_TRACKER_ID_STATUS_OK) { @@ -311,7 +314,7 @@ int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids, goto error; } - for (unsigned int i = 0; i < count; i++) { + for (i = 0; i < count; i++) { struct lttcomm_tracker_id_header id_hdr; size_t var_data_len = 0; diff --git a/tests/regression/tools/notification/notification.c b/tests/regression/tools/notification/notification.c index d8a88bf21..f0149bc2f 100644 --- a/tests/regression/tools/notification/notification.c +++ b/tests/regression/tools/notification/notification.c @@ -105,8 +105,9 @@ end: int stop_consumer(const char **argv) { - int ret = 0; - for (int i = named_pipe_args_start; i < nb_args; i++) { + int ret = 0, i; + + for (i = named_pipe_args_start; i < nb_args; i++) { ret = write_pipe(argv[i], 49); } return ret; @@ -114,8 +115,9 @@ int stop_consumer(const char **argv) int resume_consumer(const char **argv) { - int ret = 0; - for (int i = named_pipe_args_start; i < nb_args; i++) { + int ret = 0, i; + + for (i = named_pipe_args_start; i < nb_args; i++) { ret = write_pipe(argv[i], 0); } return ret; @@ -184,6 +186,7 @@ void test_triggers_buffer_usage_condition(const char *session_name, enum lttng_domain_type domain_type, enum lttng_condition_type condition_type) { + unsigned int test_vector_size = 5, i; enum lttng_condition_status condition_status; struct lttng_action *action; @@ -198,8 +201,8 @@ void test_triggers_buffer_usage_condition(const char *session_name, ok(lttng_register_trigger(NULL) == -LTTNG_ERR_INVALID, "Registering a NULL trigger fails as expected"); /* Test: register a trigger */ - unsigned int test_vector_size = 5; - for (unsigned int i = 0; i < pow(2,test_vector_size); i++) { + + for (i = 0; i < pow(2,test_vector_size); i++) { int loop_ret = 0; char *test_tuple_string = NULL; unsigned int mask_position = 0; diff --git a/tests/unit/test_relayd_backward_compat_group_by_session.c b/tests/unit/test_relayd_backward_compat_group_by_session.c index 1be8df045..769f8809e 100644 --- a/tests/unit/test_relayd_backward_compat_group_by_session.c +++ b/tests/unit/test_relayd_backward_compat_group_by_session.c @@ -115,11 +115,12 @@ static char *craft_expected(struct test *test) int main(int argc, char **argv) { + int i; int num_test = sizeof(tests) / sizeof(struct test); plan_tests(NUM_TESTS_PER_TEST * num_test); diag("Backward compatibility utils for lttng-relayd --group-by-session"); - for (int i = 0; i < num_test; i++) { + for (i = 0; i < num_test; i++) { char *expected = NULL; char *result = NULL;