diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2012-11-27 14:17:19 -0800 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-11-27 14:17:19 -0800 |
commit | f919a0d337a1d2c586191cc5de2714cc631a5620 (patch) | |
tree | a3128ae8acceb18531b5845a8f1997802c1986fe | |
parent | 4e404c1582ccdd8ae19bb2e9bb632a87b3335b49 (diff) |
waffle: Declare loop iterators the C99 way
That is, declare all loop iterators like this:
for (int i = 0; ...)
rather than:
int i;
...
for (i = 0; ...)
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | examples/gl_basic.c | 9 | ||||
-rw-r--r-- | src/waffle/api/api_priv.c | 4 | ||||
-rw-r--r-- | src/waffle/api/waffle_attrib_list.c | 4 | ||||
-rw-r--r-- | src/waffle/api/waffle_init.c | 3 | ||||
-rw-r--r-- | src/waffle/core/wcore_config_attrs.c | 8 | ||||
-rw-r--r-- | tests/waffle_test/priv/wt_runner.c | 4 | ||||
-rw-r--r-- | tests/waffle_test/wt_main.c | 3 |
7 files changed, 10 insertions, 25 deletions
diff --git a/examples/gl_basic.c b/examples/gl_basic.c index 0f6a913..c3abc2f 100644 --- a/examples/gl_basic.c +++ b/examples/gl_basic.c @@ -197,9 +197,7 @@ enum_map_translate_str( const char *s, int *result) { - const struct enum_map *i; - - for (i = self; i->i != 0; ++i) { + for (const struct enum_map *i = self; i->i != 0; ++i) { if (!strncmp(s, i->s, strlen(i->s) + 1)) { *result = i->i; return true; @@ -311,7 +309,6 @@ parse_args(int argc, char *argv[], struct options *opts) static bool draw(struct waffle_window *window) { - int i, j; bool ok; unsigned char *colors; @@ -321,7 +318,7 @@ draw(struct waffle_window *window) .tv_nsec = 500000000, }; - for (i = 0; i < 3; ++i) { + for (int i = 0; i < 3; ++i) { switch (i) { case 0: glClearColor(1, 0, 0, 1); break; case 1: glClearColor(0, 1, 0, 1); break; @@ -336,7 +333,7 @@ draw(struct waffle_window *window) WINDOW_WIDTH, WINDOW_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, colors); - for (j = 0; j < WINDOW_WIDTH * WINDOW_HEIGHT * 4; j += 4) { + for (int j = 0; j < WINDOW_WIDTH * WINDOW_HEIGHT * 4; j += 4) { if ((colors[j] != (i == 0 ? 0xff : 0)) || (colors[j+1] != (i == 1 ? 0xff : 0)) || (colors[j+2] != (i == 2 ? 0xff : 0)) || diff --git a/src/waffle/api/api_priv.c b/src/waffle/api/api_priv.c index ac332a9..77417f8 100644 --- a/src/waffle/api/api_priv.c +++ b/src/waffle/api/api_priv.c @@ -42,8 +42,6 @@ struct wcore_platform *api_platform = 0; bool api_check_entry(const struct api_object *obj_list[], int length) { - int i; - wcore_error_reset(); if (!api_platform) { @@ -51,7 +49,7 @@ api_check_entry(const struct api_object *obj_list[], int length) return false; } - for (i = 0; i < length; ++i) { + for (int i = 0; i < length; ++i) { if (obj_list[i] == NULL) { wcore_errorf(WAFFLE_ERROR_BAD_PARAMETER, "null pointer"); return false; diff --git a/src/waffle/api/waffle_attrib_list.c b/src/waffle/api/waffle_attrib_list.c index 523cac6..479528c 100644 --- a/src/waffle/api/waffle_attrib_list.c +++ b/src/waffle/api/waffle_attrib_list.c @@ -53,14 +53,12 @@ waffle_attrib_list_get( int32_t key, int32_t *value) { - int i; - wcore_error_reset(); if (attrib_list == NULL) return false; - for (i = 0; attrib_list[i] != 0; i += 2) { + for (int i = 0; attrib_list[i] != 0; i += 2) { if (attrib_list[i] != key) continue; diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c index 5b17147..3b90293 100644 --- a/src/waffle/api/waffle_init.c +++ b/src/waffle/api/waffle_init.c @@ -45,10 +45,9 @@ waffle_init_parse_attrib_list( const int32_t attrib_list[], int *platform) { - const int32_t *i; bool found_platform = false; - for (i = attrib_list; *i != 0; i += 2) { + for (const int32_t *i = attrib_list; *i != 0; i += 2) { const int32_t attr = i[0]; const int32_t value = i[1]; diff --git a/src/waffle/core/wcore_config_attrs.c b/src/waffle/core/wcore_config_attrs.c index c59b9aa..1276e56 100644 --- a/src/waffle/core/wcore_config_attrs.c +++ b/src/waffle/core/wcore_config_attrs.c @@ -38,12 +38,10 @@ static bool check_keys(const int32_t attrib_list[]) { - int32_t i; - if (attrib_list == NULL) return true; - for (i = 0; attrib_list[i]; i += 2) { + for (int32_t i = 0; attrib_list[i]; i += 2) { int32_t key = attrib_list[i]; switch (key) { @@ -300,9 +298,7 @@ static bool parse_misc(struct wcore_config_attrs *attrs, const int32_t attrib_list[]) { - int32_t i; - - for (i = 0; attrib_list[i]; i += 2) { + for (int32_t i = 0; attrib_list[i]; i += 2) { int32_t key = attrib_list[i + 0]; int32_t value = attrib_list[i + 1]; diff --git a/tests/waffle_test/priv/wt_runner.c b/tests/waffle_test/priv/wt_runner.c index 6b3eedf..729c033 100644 --- a/tests/waffle_test/priv/wt_runner.c +++ b/tests/waffle_test/priv/wt_runner.c @@ -156,11 +156,9 @@ wt_runner_get_totals(int *pass, int *fail, int *ignore) void wt_runner_print_summary(void) { - int i; - if (self.num_fail > 0) { printf("test: failed tests:\n"); - for (i = 0; i < self.num_fail; ++i) { + for (int i = 0; i < self.num_fail; ++i) { struct wt_testname *name = &self.fail_names[i]; printf(" %s.%s\n", name->group, name->name); } diff --git a/tests/waffle_test/wt_main.c b/tests/waffle_test/wt_main.c index 7a8a461..205c83c 100644 --- a/tests/waffle_test/wt_main.c +++ b/tests/waffle_test/wt_main.c @@ -29,12 +29,11 @@ int wt_main(int *argc, char **argv, void (*test_suites[])(void)) { - int i; int num_fail; wt_runner_init(); - for (i = 0; test_suites[i] != 0; ++i) + for (int i = 0; test_suites[i] != 0; ++i) test_suites[i](); wt_runner_print_summary(); |