archive/ArchiveList, input/Registry: avoid zero-sized array

Some more `-Wpedantic` fixups.
This commit is contained in:
Max Kellermann 2020-05-27 16:30:44 +02:00
parent 8fdc6dec44
commit caec384ed0
2 changed files with 10 additions and 2 deletions

View File

@ -43,8 +43,12 @@ const ArchivePlugin *const archive_plugins[] = {
nullptr
};
static constexpr std::size_t n_archive_plugins = std::size(archive_plugins) - 1;
/** which plugins have been initialized successfully? */
static bool archive_plugins_enabled[std::size(archive_plugins) - 1];
/* the std::max() is just here to avoid a zero-sized array, which is
forbidden in C++ */
static bool archive_plugins_enabled[std::max(n_archive_plugins, std::size_t(1))];
#define archive_plugins_for_each_enabled(plugin) \
archive_plugins_for_each(plugin) \

View File

@ -83,7 +83,11 @@ const InputPlugin *const input_plugins[] = {
nullptr
};
bool input_plugins_enabled[std::size(input_plugins) - 1];
static constexpr std::size_t n_input_plugins = std::size(input_plugins) - 1;
/* the std::max() is just here to avoid a zero-sized array, which is
forbidden in C++ */
bool input_plugins_enabled[std::max(n_input_plugins, std::size_t(1))];
bool
HasRemoteTagScanner(const char *uri) noexcept