diff options
author | Max Kellermann <max@duempel.org> | 2009-12-15 17:31:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-15 15:31:00 +0100 |
commit | f1ecd9eac8ff3cabc24a16e394219dda6355c3eb (patch) | |
tree | fd9986067cf4ad82cc06a7d4182490c94ff98156 | |
parent | 243c96304b02f57f29b5e8d217a55fed752a5cb7 (diff) | |
download | mpd-f1ecd9eac8ff3cabc24a16e394219dda6355c3eb.tar.gz mpd-f1ecd9eac8ff3cabc24a16e394219dda6355c3eb.tar.xz mpd-f1ecd9eac8ff3cabc24a16e394219dda6355c3eb.zip |
archive_list: iterate with NULL check
Don't use num_archive_plugins.
Diffstat (limited to '')
-rw-r--r-- | src/archive_list.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/archive_list.c b/src/archive_list.c index 9343e63b0..007f4a350 100644 --- a/src/archive_list.c +++ b/src/archive_list.c @@ -42,22 +42,16 @@ static const struct archive_plugin *const archive_plugins[] = { NULL }; -enum { - num_archive_plugins = G_N_ELEMENTS(archive_plugins)-1, -}; - /** which plugins have been initialized successfully? */ -static bool archive_plugins_enabled[num_archive_plugins+1]; +static bool archive_plugins_enabled[G_N_ELEMENTS(archive_plugins) - 1]; const struct archive_plugin * archive_plugin_from_suffix(const char *suffix) { - unsigned i; - if (suffix == NULL) return NULL; - for (i=0; i < num_archive_plugins; ++i) { + for (unsigned i = 0; archive_plugins[i] != NULL; ++i) { const struct archive_plugin *plugin = archive_plugins[i]; if (archive_plugins_enabled[i] && plugin->suffixes != NULL && @@ -72,7 +66,7 @@ archive_plugin_from_suffix(const char *suffix) const struct archive_plugin * archive_plugin_from_name(const char *name) { - for (unsigned i = 0; i < num_archive_plugins; ++i) { + for (unsigned i = 0; archive_plugins[i] != NULL; ++i) { const struct archive_plugin *plugin = archive_plugins[i]; if (archive_plugins_enabled[i] && strcmp(plugin->name, name) == 0) @@ -85,7 +79,7 @@ void archive_plugin_print_all_suffixes(FILE * fp) { const char *const*suffixes; - for (unsigned i = 0; i < num_archive_plugins; ++i) { + for (unsigned i = 0; archive_plugins[i] != NULL; ++i) { const struct archive_plugin *plugin = archive_plugins[i]; if (!archive_plugins_enabled[i]) continue; @@ -102,7 +96,7 @@ void archive_plugin_print_all_suffixes(FILE * fp) void archive_plugin_init_all(void) { - for (unsigned i = 0; i < num_archive_plugins; ++i) { + for (unsigned i = 0; archive_plugins[i] != NULL; ++i) { const struct archive_plugin *plugin = archive_plugins[i]; if (plugin->init == NULL || archive_plugins[i]->init()) archive_plugins_enabled[i] = true; @@ -111,7 +105,7 @@ void archive_plugin_init_all(void) void archive_plugin_deinit_all(void) { - for (unsigned i = 0; i < num_archive_plugins; ++i) { + for (unsigned i = 0; archive_plugins[i] != NULL; ++i) { const struct archive_plugin *plugin = archive_plugins[i]; if (archive_plugins_enabled[i] && plugin->finish != NULL) archive_plugins[i]->finish(); |