Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja authored and rubenwardy committed Apr 8, 2022
1 parent 3a87fab commit 5683bb7
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 51 deletions.
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -470,22 +470,24 @@ endif()
include_directories(
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/script
)
include_directories(SYSTEM
${ZLIB_INCLUDE_DIR}
${ZSTD_INCLUDE_DIR}
${SQLITE3_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${GMP_INCLUDE_DIR}
${JSON_INCLUDE_DIR}
${LUA_BIT_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/script
)

if(USE_GETTEXT)
include_directories(${GETTEXT_INCLUDE_DIR})
endif()

if(BUILD_CLIENT)
include_directories(
include_directories(SYSTEM
${FREETYPE_INCLUDE_DIRS}
${SOUND_INCLUDE_DIRS}
${X11_INCLUDE_DIR}
Expand Down
2 changes: 2 additions & 0 deletions src/client/clientlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ void ClientLauncher::speed_tests()
// volatile to avoid some potential compiler optimisations
volatile static s16 temp16;
volatile static f32 tempf;
// Silence compiler warning
(void)temp16;
static v3f tempv3f1;
static v3f tempv3f2;
static std::string tempstring;
Expand Down
10 changes: 5 additions & 5 deletions src/client/shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,6 @@ class MainShaderConstantSetter : public IShaderConstantSetter
MainShaderConstantSetter() :
m_world_view_proj("mWorldViewProj")
, m_world("mWorld")
#if ENABLE_GLES
, m_world_view("mWorldView")
, m_texture("mTexture")
, m_normal("mNormal")
#endif
, m_shadow_view_proj("m_ShadowViewProj")
, m_light_direction("v_LightDirection")
, m_texture_res("f_textureresolution")
Expand All @@ -261,6 +256,11 @@ class MainShaderConstantSetter : public IShaderConstantSetter
, m_perspective_bias1_pixel("xyPerspectiveBias1")
, m_perspective_zbias_vertex("zPerspectiveBias")
, m_perspective_zbias_pixel("zPerspectiveBias")
#if ENABLE_GLES
, m_world_view("mWorldView")
, m_texture("mTexture")
, m_normal("mNormal")
#endif
{}
~MainShaderConstantSetter() = default;

Expand Down
14 changes: 0 additions & 14 deletions src/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void decompressZlib(std::istream &is, std::ostream &os, size_t limit)
char output_buffer[bufsize];
int status = 0;
int ret;
int bytes_read = 0;
int bytes_written = 0;
int input_buffer_len = 0;

Expand All @@ -122,8 +121,6 @@ void decompressZlib(std::istream &is, std::ostream &os, size_t limit)

z.avail_in = 0;

//dstream<<"initial fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;

for(;;)
{
int output_size = bufsize;
Expand All @@ -147,19 +144,13 @@ void decompressZlib(std::istream &is, std::ostream &os, size_t limit)
is.read(input_buffer, bufsize);
input_buffer_len = is.gcount();
z.avail_in = input_buffer_len;
//dstream<<"read fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
}
if(z.avail_in == 0)
{
//dstream<<"z.avail_in == 0"<<std::endl;
break;
}

//dstream<<"1 z.avail_in="<<z.avail_in<<std::endl;
status = inflate(&z, Z_NO_FLUSH);
//dstream<<"2 z.avail_in="<<z.avail_in<<std::endl;
bytes_read += is.gcount() - z.avail_in;
//dstream<<"bytes_read="<<bytes_read<<std::endl;

if(status == Z_NEED_DICT || status == Z_DATA_ERROR
|| status == Z_MEM_ERROR)
Expand All @@ -168,16 +159,11 @@ void decompressZlib(std::istream &is, std::ostream &os, size_t limit)
throw SerializationError("decompressZlib: inflate failed");
}
int count = output_size - z.avail_out;
//dstream<<"count="<<count<<std::endl;
if(count)
os.write(output_buffer, count);
bytes_written += count;
if(status == Z_STREAM_END)
{
//dstream<<"Z_STREAM_END"<<std::endl;

//dstream<<"z.avail_in="<<z.avail_in<<std::endl;
//dstream<<"fail="<<is.fail()<<" bad="<<is.bad()<<std::endl;
// Unget all the data that inflate didn't take
is.clear(); // Just in case EOF is set
for(u32 i=0; i < z.avail_in; i++)
Expand Down
48 changes: 24 additions & 24 deletions src/server/player_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ class PlayerSAO : public UnitSAO
PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t peer_id_,
bool is_singleplayer);

ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_PLAYER; }
ActiveObjectType getSendType() const { return ACTIVEOBJECT_TYPE_GENERIC; }
std::string getDescription();
ActiveObjectType getType() const override { return ACTIVEOBJECT_TYPE_PLAYER; }
ActiveObjectType getSendType() const override { return ACTIVEOBJECT_TYPE_GENERIC; }
std::string getDescription() override;

/*
Active object <-> environment interface
*/

void addedToEnvironment(u32 dtime_s);
void removingFromEnvironment();
bool isStaticAllowed() const { return false; }
bool shouldUnload() const { return false; }
std::string getClientInitializationData(u16 protocol_version);
void getStaticData(std::string *result) const;
void step(float dtime, bool send_recommended);
void addedToEnvironment(u32 dtime_s) override;
void removingFromEnvironment() override;
bool isStaticAllowed() const override { return false; }
bool shouldUnload() const override { return false; }
std::string getClientInitializationData(u16 protocol_version) override;
void getStaticData(std::string *result) const override;
void step(float dtime, bool send_recommended) override;
void setBasePosition(const v3f &position);
void setPos(const v3f &pos);
void moveTo(v3f pos, bool continuous);
void setPos(const v3f &pos) override;
void moveTo(v3f pos, bool continuous) override;
void setPlayerYaw(const float yaw);
// Data should not be sent at player initialization
void setPlayerYawAndSend(const float yaw);
Expand All @@ -110,8 +110,8 @@ class PlayerSAO : public UnitSAO
*/

u32 punch(v3f dir, const ToolCapabilities *toolcap, ServerActiveObject *puncher,
float time_from_last_punch, u16 initial_wear = 0);
void rightClick(ServerActiveObject *clicker);
float time_from_last_punch, u16 initial_wear = 0) override;
void rightClick(ServerActiveObject *clicker) override;
void setHP(s32 hp, const PlayerHPChangeReason &reason) override
{
return setHP(hp, reason, false);
Expand All @@ -124,13 +124,13 @@ class PlayerSAO : public UnitSAO
/*
Inventory interface
*/
Inventory *getInventory() const;
InventoryLocation getInventoryLocation() const;
void setInventoryModified() {}
std::string getWieldList() const { return "main"; }
u16 getWieldIndex() const;
ItemStack getWieldedItem(ItemStack *selected, ItemStack *hand = nullptr) const;
bool setWieldedItem(const ItemStack &item);
Inventory *getInventory() const override;
InventoryLocation getInventoryLocation() const override;
void setInventoryModified() override {}
std::string getWieldList() const override { return "main"; }
u16 getWieldIndex() const override;
ItemStack getWieldedItem(ItemStack *selected, ItemStack *hand = nullptr) const override;
bool setWieldedItem(const ItemStack &item) override;

/*
PlayerSAO-specific
Expand Down Expand Up @@ -171,9 +171,9 @@ class PlayerSAO : public UnitSAO
m_is_singleplayer = is_singleplayer;
}

bool getCollisionBox(aabb3f *toset) const;
bool getSelectionBox(aabb3f *toset) const;
bool collideWithObjects() const { return true; }
bool getCollisionBox(aabb3f *toset) const override;
bool getSelectionBox(aabb3f *toset) const override;
bool collideWithObjects() const override { return true; }

void finalize(RemotePlayer *player, const std::set<std::string> &privs);

Expand Down
3 changes: 2 additions & 1 deletion src/terminal_chat_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include <inttypes.h>
#include "config.h"
#if USE_CURSES
#include "version.h"
Expand Down Expand Up @@ -398,7 +399,7 @@ void TerminalChatConsole::step(int ch)
minutes = (float)minutes / 1000 * 60;

if (m_game_time)
printw(" | Game %d Time of day %02d:%02d ",
printw(" | Game %" PRIu64 " Time of day %02d:%02d ",
m_game_time, hours, minutes);

// draw text
Expand Down
4 changes: 3 additions & 1 deletion src/unittest/test_irrptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ void TestIrrPtr::testRefCounting()

#if defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
#if __clang_major__ >= 7
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
#endif
#pragma GCC diagnostic ignored "-Wself-move"
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/unittest/test_voxelarea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void TestVoxelArea::test_extent()
VoxelArea v1(v3s16(-1337, -547, -789), v3s16(-147, 447, 669));
UASSERT(v1.getExtent() == v3s16(1191, 995, 1459));

VoxelArea v2(v3s16(32493, -32507, 32753), v3s16(32508, -32492, 32768));
VoxelArea v2(v3s16(32493, -32507, 32753), v3s16(32508, -32492, -32768));
UASSERT(v2.getExtent() == v3s16(16, 16, 16));
}

Expand All @@ -129,7 +129,7 @@ void TestVoxelArea::test_volume()
VoxelArea v1(v3s16(-1337, -547, -789), v3s16(-147, 447, 669));
UASSERTEQ(s32, v1.getVolume(), 1728980655);

VoxelArea v2(v3s16(32493, -32507, 32753), v3s16(32508, -32492, 32768));
VoxelArea v2(v3s16(32493, -32507, 32753), v3s16(32508, -32492, -32768));
UASSERTEQ(s32, v2.getVolume(), 4096);
}

Expand Down
4 changes: 2 additions & 2 deletions src/util/srp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static size_t hash_length(SRP_HashAlgorithm alg)
case SRP_SHA384: return SHA384_DIGEST_LENGTH;
case SRP_SHA512: return SHA512_DIGEST_LENGTH;
*/
default: return -1;
default: return 0;
};
}
// clang-format on
Expand Down Expand Up @@ -422,7 +422,7 @@ static SRP_Result H_nn(
}

static SRP_Result H_ns(mpz_t result, SRP_HashAlgorithm alg, const unsigned char *n,
size_t len_n, const unsigned char *bytes, uint32_t len_bytes)
size_t len_n, const unsigned char *bytes, size_t len_bytes)
{
unsigned char buff[SHA512_DIGEST_LENGTH];
size_t nbytes = len_n + len_bytes;
Expand Down

0 comments on commit 5683bb7

Please sign in to comment.