From f319f88df4b51f48e208b44af7ca844a884d0bbd Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 23 Mar 2020 20:17:24 -0700 Subject: [PATCH] [cppcheck] use const for several variables Found with constVariable Signed-off-by: Rosen Penev --- src/decoder/plugins/SndfileDecoderPlugin.cxx | 8 ++++---- src/decoder/plugins/WavpackDecoderPlugin.cxx | 20 ++++++++++---------- src/event/PollGroupPoll.cxx | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx index 6aec0825f..803dd259b 100644 --- a/src/decoder/plugins/SndfileDecoderPlugin.cxx +++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx @@ -56,8 +56,8 @@ struct SndfileInputStream { static sf_count_t sndfile_vio_get_filelen(void *user_data) { - SndfileInputStream &sis = *(SndfileInputStream *)user_data; - const InputStream &is = sis.is; + const auto &sis = *(SndfileInputStream *)user_data; + const auto &is = sis.is; if (!is.KnownSize()) return -1; @@ -120,8 +120,8 @@ sndfile_vio_write([[maybe_unused]] const void *ptr, static sf_count_t sndfile_vio_tell(void *user_data) { - SndfileInputStream &sis = *(SndfileInputStream *)user_data; - const InputStream &is = sis.is; + const auto &sis = *(SndfileInputStream *)user_data; + const auto &is = sis.is; return is.GetOffset(); } diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index f1836ba3d..983c4e0f7 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -398,21 +398,21 @@ WavpackInput::ReadBytes(void *data, size_t bcount) static int64_t wavpack_input_get_pos(void *id) { - WavpackInput &wpi = *wpin(id); + const auto &wpi = *wpin(id); return wpi.GetPos(); } static int wavpack_input_set_pos_abs(void *id, int64_t pos) { - WavpackInput &wpi = *wpin(id); + auto &wpi = *wpin(id); return wpi.SetPosAbs(pos); } static int wavpack_input_set_pos_rel(void *id, int64_t delta, int mode) { - WavpackInput &wpi = *wpin(id); + auto &wpi = *wpin(id); return wpi.SetPosRel(delta, mode); } @@ -421,21 +421,21 @@ wavpack_input_set_pos_rel(void *id, int64_t delta, int mode) static uint32_t wavpack_input_get_pos(void *id) { - WavpackInput &wpi = *wpin(id); + const auto &wpi = *wpin(id); return wpi.GetPos(); } static int wavpack_input_set_pos_abs(void *id, uint32_t pos) { - WavpackInput &wpi = *wpin(id); + auto &wpi = *wpin(id); return wpi.SetPosAbs(pos); } static int wavpack_input_set_pos_rel(void *id, int32_t delta, int mode) { - WavpackInput &wpi = *wpin(id); + auto &wpi = *wpin(id); return wpi.SetPosRel(delta, mode); } @@ -444,7 +444,7 @@ wavpack_input_set_pos_rel(void *id, int32_t delta, int mode) static int wavpack_input_push_back_byte(void *id, int c) { - WavpackInput &wpi = *wpin(id); + auto &wpi = *wpin(id); return wpi.PushBackByte(c); } @@ -453,7 +453,7 @@ wavpack_input_push_back_byte(void *id, int c) static int64_t wavpack_input_get_length(void *id) { - WavpackInput &wpi = *wpin(id); + const auto &wpi = *wpin(id); return wpi.GetLength(); } @@ -462,7 +462,7 @@ wavpack_input_get_length(void *id) static uint32_t wavpack_input_get_length(void *id) { - WavpackInput &wpi = *wpin(id); + const auto &wpi = *wpin(id); return wpi.GetLength(); } @@ -471,7 +471,7 @@ wavpack_input_get_length(void *id) static int wavpack_input_can_seek(void *id) { - WavpackInput &wpi = *wpin(id); + const auto &wpi = *wpin(id); return wpi.CanSeek(); } diff --git a/src/event/PollGroupPoll.cxx b/src/event/PollGroupPoll.cxx index 1568108a4..69901e689 100644 --- a/src/event/PollGroupPoll.cxx +++ b/src/event/PollGroupPoll.cxx @@ -63,7 +63,7 @@ PollGroupPoll::Remove(int fd) noexcept { auto item_iter = items.find(fd); assert(item_iter != items.end()); - auto &item = item_iter->second; + const auto &item = item_iter->second; size_t index = item.index; size_t last_index = poll_events.size() - 1; if (index != last_index) {