From 15fa780c99deaf4e6fb174c60c0ecce18ae8ee0e Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 31 Jan 2020 20:09:15 -0800 Subject: [PATCH] [clang-tidy] convert several loops to range based ones Found with modernize-loop-convert Signed-off-by: Rosen Penev --- src/command/AllCommands.cxx | 8 ++++---- src/decoder/plugins/MadDecoderPlugin.cxx | 4 ++-- src/neighbor/Glue.cxx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index 8943f44e0..86830ed90 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -246,8 +246,8 @@ static CommandResult PrintAvailableCommands(Response &r, const Partition &partition, unsigned permission) noexcept { - for (unsigned i = 0; i < num_commands; ++i) { - const struct command *cmd = &commands[i]; + for (const auto & i : commands) { + const struct command *cmd = &i; if (cmd->permission == (permission & cmd->permission) && command_available(partition, cmd)) @@ -260,8 +260,8 @@ PrintAvailableCommands(Response &r, const Partition &partition, static CommandResult PrintUnavailableCommands(Response &r, unsigned permission) noexcept { - for (unsigned i = 0; i < num_commands; ++i) { - const struct command *cmd = &commands[i]; + for (const auto & i : commands) { + const struct command *cmd = &i; if (cmd->permission != (permission & cmd->permission)) r.Format("command: %s\n", cmd->cmd); diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 8f8db69c0..e72841155 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -516,8 +516,8 @@ parse_xing(struct xing *xing, struct mad_bitptr *ptr, int *oldbitlen) noexcept if (xing->flags & XING_TOC) { if (bitlen < 800) return false; - for (unsigned i = 0; i < 100; ++i) - xing->toc[i] = mad_bit_read(ptr, 8); + for (unsigned char & i : xing->toc) + i = mad_bit_read(ptr, 8); bitlen -= 800; } diff --git a/src/neighbor/Glue.cxx b/src/neighbor/Glue.cxx index 69df3a195..992dab4dd 100644 --- a/src/neighbor/Glue.cxx +++ b/src/neighbor/Glue.cxx @@ -84,8 +84,8 @@ NeighborGlue::Open() void NeighborGlue::Close() noexcept { - for (auto i = explorers.begin(), end = explorers.end(); i != end; ++i) - i->explorer->Close(); + for (auto & explorer : explorers) + explorer.explorer->Close(); } NeighborGlue::List