From f81d360cae1a69d94cade5467dd536abf1b0b51b Mon Sep 17 00:00:00 2001 From: HybridDog Date: Fri, 21 Jul 2023 19:20:10 +0200 Subject: [PATCH] Code style changes to satisfy CppCheck * `heavy_coin` was of type `HeavyCoin * const` and not `const HeavyCoin *`. I've added asterisks to the other `auto`s for pointer types, too, for consistency. * void pointer arithmetic has undefined behaviour, so the return value of a unique_ptr's get method call in `StreamSoundSource::fillBufferAndQueue` needs to be converted to char*. --- src/audio/stream_sound_source.cpp | 4 ++-- src/badguy/crusher.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/audio/stream_sound_source.cpp b/src/audio/stream_sound_source.cpp index ee8a5e3cc59..2297a81c2d9 100644 --- a/src/audio/stream_sound_source.cpp +++ b/src/audio/stream_sound_source.cpp @@ -138,8 +138,8 @@ StreamSoundSource::fillBufferAndQueue(ALuint buffer) std::unique_ptr bufferdata(new char[STREAMFRAGMENTSIZE]); size_t bytesread = 0; do { - bytesread += m_file->read(bufferdata.get() + bytesread, - STREAMFRAGMENTSIZE - bytesread); + bytesread += m_file->read(static_cast(bufferdata.get()) + bytesread, + STREAMFRAGMENTSIZE - bytesread); // end of sound file if (bytesread < STREAMFRAGMENTSIZE) { if (m_looping) diff --git a/src/badguy/crusher.cpp b/src/badguy/crusher.cpp index c7af75e8544..7193dd7b8be 100644 --- a/src/badguy/crusher.cpp +++ b/src/badguy/crusher.cpp @@ -96,7 +96,7 @@ Crusher::on_type_change(int old_type) HitResponse Crusher::collision(GameObject& other, const CollisionHit& hit) { - auto player = dynamic_cast(&other); + auto* player = dynamic_cast(&other); // If the other object is the player, and the collision is at the // bottom of the crusher, hurt the player. @@ -110,12 +110,12 @@ Crusher::collision(GameObject& other, const CollisionHit& hit) return FORCE_MOVE; } - auto badguy = dynamic_cast(&other); + auto* badguy = dynamic_cast(&other); if (badguy && m_state == CRUSHING) { badguy->kill_fall(); } - const auto heavy_coin = dynamic_cast(&other); + const auto* heavy_coin = dynamic_cast(&other); if (heavy_coin) { return ABORT_MOVE; }