From: Daniel Karbach Date: Wed, 16 Nov 2016 12:44:55 +0000 (+0100) Subject: make gcc nag more X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=20d0a76d2519c71009c3b3babec0df27529f8142;p=blank.git make gcc nag more --- diff --git a/Makefile b/Makefile index 4a52c99..1b315a7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ TESTLIBS := $(shell pkg-config --libs cppunit) CPPFLAGS ?= CPPFLAGS += $(PKGFLAGS) CXXFLAGS ?= -CXXFLAGS += -Wall +CXXFLAGS += -Wall -Wextra -Werror #CXXFLAGS += -march=native LDXXFLAGS ?= LDXXFLAGS += $(PKGLIBS) diff --git a/src/ai/Spawner.cpp b/src/ai/Spawner.cpp index 2c5a94c..3433d0a 100644 --- a/src/ai/Spawner.cpp +++ b/src/ai/Spawner.cpp @@ -120,7 +120,7 @@ void Spawner::TrySpawn() { Spawn(player.GetEntity(), spawn_block.GetChunk().Position(), spawn_block.GetBlockCoords()); } -void Spawner::Spawn(Entity &reference, const glm::ivec3 &chunk, const glm::vec3 &pos) { +void Spawner::Spawn(Entity &, const glm::ivec3 &chunk, const glm::vec3 &pos) { Entity &e = world.AddEntity(); e.Position(chunk, pos); e.Bounds({ { -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f } }); diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index ef0fc23..95dc8f7 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -145,7 +145,7 @@ unsigned int AIController::Decide(unsigned int num_choices) noexcept { // chase -void ChaseState::Enter(AIController &ctrl, Entity &e) const { +void ChaseState::Enter(AIController &, Entity &e) const { e.GetSteering() .SetAcceleration(5.0f) .SetSpeed(4.0f) @@ -153,7 +153,7 @@ void ChaseState::Enter(AIController &ctrl, Entity &e) const { ; } -void ChaseState::Update(AIController &ctrl, Entity &e, float dt) const { +void ChaseState::Update(AIController &ctrl, Entity &e, float) const { Steering &steering = e.GetSteering(); // check if target still alive and in sight if ( @@ -176,7 +176,7 @@ void ChaseState::Update(AIController &ctrl, Entity &e, float dt) const { } } -void ChaseState::Exit(AIController &ctrl, Entity &e) const { +void ChaseState::Exit(AIController &, Entity &e) const { e.GetSteering().Disable(Steering::HALT | Steering::PURSUE_TARGET); } @@ -191,12 +191,12 @@ void FleeState::Enter(AIController &ctrl, Entity &e) const { ctrl.CueDecision(6.0f, 3.0f); } -void FleeState::Update(AIController &ctrl, Entity &e, float dt) const { +void FleeState::Update(AIController &ctrl, Entity &e, float) const { if (!ctrl.DecisionDue()) return; ctrl.SetState(idle, e); } -void FleeState::Exit(AIController &ctrl, Entity &e) const { +void FleeState::Exit(AIController &, Entity &e) const { e.GetSteering().Disable(Steering::EVADE_TARGET); } @@ -212,7 +212,7 @@ void IdleState::Enter(AIController &ctrl, Entity &e) const { ctrl.CueDecision(10.0f, 5.0f); } -void IdleState::Update(AIController &ctrl, Entity &e, float dt) const { +void IdleState::Update(AIController &ctrl, Entity &e, float) const { if (ctrl.MayThink()) { const Player *player = ctrl.ClosestVisiblePlayer(e); if (player) { @@ -238,7 +238,7 @@ void IdleState::Update(AIController &ctrl, Entity &e, float dt) const { ctrl.CueDecision(10.0f, 5.0f); } -void IdleState::Exit(AIController &ctrl, Entity &e) const { +void IdleState::Exit(AIController &, Entity &e) const { e.GetSteering().Disable(Steering::HALT | Steering::WANDER); } @@ -254,7 +254,7 @@ void RoamState::Enter(AIController &ctrl, Entity &e) const { ctrl.CueDecision(10.0f, 5.0f); } -void RoamState::Update(AIController &ctrl, Entity &e, float dt) const { +void RoamState::Update(AIController &ctrl, Entity &e, float) const { if (ctrl.MayThink()) { const Player *player = ctrl.ClosestVisiblePlayer(e); if (player) { @@ -274,7 +274,7 @@ void RoamState::Update(AIController &ctrl, Entity &e, float dt) const { ctrl.CueDecision(10.0f, 5.0f); } -void RoamState::Exit(AIController &ctrl, Entity &e) const { +void RoamState::Exit(AIController &, Entity &e) const { e.GetSteering().Disable(Steering::WANDER); } diff --git a/src/client/client.cpp b/src/client/client.cpp index b79c435..be62988 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -396,7 +396,7 @@ void MasterState::OnEnter() { } -void MasterState::Handle(const SDL_Event &event) { +void MasterState::Handle(const SDL_Event &) { } @@ -450,7 +450,7 @@ void MasterState::On(const Packet::Join &pack) { env.state.Push(state.get()); } -void MasterState::On(const Packet::Part &pack) { +void MasterState::On(const Packet::Part &) { Quit(); if (state) { // kicked diff --git a/src/client/net.cpp b/src/client/net.cpp index 5510872..f1e5553 100644 --- a/src/client/net.cpp +++ b/src/client/net.cpp @@ -244,10 +244,15 @@ IPaddress client_resolve(const char *host, Uint16 port) { } +// relying on {} zero intitialization for UDPpacket, because +// the type and number of fields is not well defined +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" Client::Client(const Config::Network &conf) : conn(client_resolve(conf.host.c_str(), conf.port)) , client_sock(client_bind(0)) , client_pack{ -1, nullptr, 0 } { +#pragma GCC diagnostic pop client_pack.data = new Uint8[sizeof(Packet)]; client_pack.maxlen = sizeof(Packet); // establish connection @@ -306,8 +311,8 @@ uint16_t Client::SendLogin(const string &name) { uint16_t Client::SendPlayerUpdate( const EntityState &prediction, const glm::vec3 &movement, - float pitch, - float yaw, + float, + float, uint8_t actions, uint8_t slot ) { @@ -359,7 +364,7 @@ bool NetworkedInput::UpdateImportant() const noexcept { return old_actions != actions || !iszero(old_movement - GetMovement()); } -void NetworkedInput::Update(Entity &, float dt) { +void NetworkedInput::Update(Entity &, float) { Invalidate(); UpdatePlayer(); } diff --git a/src/io/event.cpp b/src/io/event.cpp index 6989425..2d5cf3e 100644 --- a/src/io/event.cpp +++ b/src/io/event.cpp @@ -399,7 +399,7 @@ ostream &operator <<(ostream &out, const SDL_AudioDeviceEvent &evt) { } #endif -ostream &operator <<(ostream &out, const SDL_QuitEvent &evt) { +ostream &operator <<(ostream &out, const SDL_QuitEvent &) { out << "quit"; return out; } diff --git a/src/server/ServerState.cpp b/src/server/ServerState.cpp index 860b71f..d3001c1 100644 --- a/src/server/ServerState.cpp +++ b/src/server/ServerState.cpp @@ -85,7 +85,7 @@ void ServerState::Update(int dt) { } -void ServerState::Render(Viewport &viewport) { +void ServerState::Render(Viewport &) { } diff --git a/src/server/net.cpp b/src/server/net.cpp index e210fef..e88ca1f 100644 --- a/src/server/net.cpp +++ b/src/server/net.cpp @@ -665,6 +665,10 @@ void NetworkCLIFeedback::Broadcast(const string &msg) { } +// relying on {} zero intitialization for UDPpacket, because +// the type and number of fields is not well defined +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" Server::Server( const Config::Network &conf, World &world, @@ -679,6 +683,7 @@ Server::Server( , save(save) , player_model(nullptr) , cli(world) { +#pragma GCC diagnostic pop if (!serv_set) { throw NetError("SDLNet_AllocSocketSet"); } diff --git a/src/shared/cli.cpp b/src/shared/cli.cpp index d4cf525..9663cb2 100644 --- a/src/shared/cli.cpp +++ b/src/shared/cli.cpp @@ -63,7 +63,7 @@ CLI::Command::~Command() { } -void TeleportCommand::Execute(CLI &cli, CLIContext &ctx, TokenStreamReader &args) { +void TeleportCommand::Execute(CLI &, CLIContext &ctx, TokenStreamReader &args) { glm::vec3 pos(args.GetFloat(), args.GetFloat(), args.GetFloat()); EntityState state = ctx.GetPlayer().GetEntity().GetState(); state.pos = ExactLocation(pos).Sanitize(); diff --git a/src/shared/shared.cpp b/src/shared/shared.cpp index 3eebf43..06f6222 100644 --- a/src/shared/shared.cpp +++ b/src/shared/shared.cpp @@ -31,10 +31,10 @@ WorldResources::WorldResources() } -void WorldResources::Load(const AssetLoader &loader, const std::string &set) { - loader.LoadShapes("default", shapes); - loader.LoadBlockTypes("default", block_types, snd_index, tex_index, shapes); - loader.LoadModels("default", models, tex_index, shapes); +void WorldResources::Load(const AssetLoader &loader, const std::string &set_name) { + loader.LoadShapes(set_name, shapes); + loader.LoadBlockTypes(set_name, block_types, snd_index, tex_index, shapes); + loader.LoadModels(set_name, models, tex_index, shapes); } } diff --git a/src/shared/states.cpp b/src/shared/states.cpp index fc422bb..630d9a7 100644 --- a/src/shared/states.cpp +++ b/src/shared/states.cpp @@ -143,7 +143,7 @@ void MessageState::Handle(const SDL_Event &e) { } } -void MessageState::Update(int dt) { +void MessageState::Update(int) { } diff --git a/src/standalone/standalone.cpp b/src/standalone/standalone.cpp index 3c3487c..f364aa4 100644 --- a/src/standalone/standalone.cpp +++ b/src/standalone/standalone.cpp @@ -266,7 +266,7 @@ PreloadState::PreloadState(Environment &env, ChunkLoader &loader, ChunkRenderer } -void PreloadState::Update(int dt) { +void PreloadState::Update(int) { loader.LoadN(per_update); if (loader.ToLoad() <= 0) { env.state.Pop(); @@ -306,7 +306,7 @@ void UnloadState::Handle(const SDL_Event &) { // ignore everything } -void UnloadState::Update(int dt) { +void UnloadState::Update(int) { for (std::size_t i = 0; i < per_update && cur != end; ++i, ++cur, ++done) { if (cur->ShouldUpdateSave()) { save.Write(*cur); diff --git a/src/ui/widgets.cpp b/src/ui/widgets.cpp index bae54cb..08147f6 100644 --- a/src/ui/widgets.cpp +++ b/src/ui/widgets.cpp @@ -287,7 +287,8 @@ void TextInput::Handle(const SDL_TextInputEvent &e) { Insert(e.text); } -void TextInput::Handle(const SDL_TextEditingEvent &e) { +void TextInput::Handle(const SDL_TextEditingEvent &) { + } void TextInput::Refresh() { diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 7f2233e..a482adb 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -693,7 +693,7 @@ ChunkLoader::ChunkLoader( } -void ChunkLoader::Update(int dt) { +void ChunkLoader::Update(int) { // check if there's chunks waiting to be loaded // load until one of load or generation limits was hit constexpr int max_load = 10; diff --git a/src/world/world.cpp b/src/world/world.cpp index f0f9496..2292d15 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -136,7 +136,7 @@ glm::mat4 Entity::ViewTransform(const glm::ivec3 &reference) const noexcept { Ray Entity::Aim(const ExactLocation::Coarse &chunk_offset) const noexcept { glm::mat4 transform = ViewTransform(chunk_offset); - Ray ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]) }; + Ray ray{ glm::vec3(transform[3]), -glm::vec3(transform[2]), { } }; ray.Update(); return ray; } @@ -274,7 +274,7 @@ void Entity::OrientBody(float dt) noexcept { } } -void Entity::OrientHead(float dt) noexcept { +void Entity::OrientHead(float) noexcept { // maximum yaw of head (60°) constexpr float max_head_yaw = PI / 3.0f; // use local Y as up @@ -394,7 +394,7 @@ bool Player::SuitableSpawn(BlockLookup &spawn_block) const noexcept { return true; } -void Player::Update(int dt) { +void Player::Update(int) { chunks.Rebase(entity.ChunkCoords()); } @@ -623,7 +623,7 @@ glm::vec3 Steering::Wander(const EntityState &state) const noexcept { return TargetVelocity(state, glm::normalize(entity.Heading() * wander_dist + wander_pos) * speed); } -glm::vec3 Steering::ObstacleAvoidance(const EntityState &state) const noexcept { +glm::vec3 Steering::ObstacleAvoidance(const EntityState &) const noexcept { return obstacle_dir; } diff --git a/tst/geometry/IntersectionTest.cpp b/tst/geometry/IntersectionTest.cpp index 04980c6..ded47b9 100644 --- a/tst/geometry/IntersectionTest.cpp +++ b/tst/geometry/IntersectionTest.cpp @@ -21,7 +21,7 @@ void IntersectionTest::tearDown() { void IntersectionTest::testSimpleRayBoxIntersection() { - Ray ray{ { 0, 0, 0 }, { 1, 0, 0 } }; // at origin, pointing right + Ray ray{ { 0, 0, 0 }, { 1, 0, 0 }, { } }; // at origin, pointing right ray.Update(); AABB box{ { -1, -1, -1 }, { 1, 1, 1 } }; // 2x2x2 cube centered around origin @@ -68,7 +68,7 @@ void IntersectionTest::testSimpleRayBoxIntersection() { } void IntersectionTest::testRayBoxIntersection() { - Ray ray{ { 0, 0, 0 }, { 1, 0, 0 } }; // at origin, pointing right + Ray ray{ { 0, 0, 0 }, { 1, 0, 0 }, { } }; // at origin, pointing right AABB box{ { -1, -1, -1 }, { 1, 1, 1 } }; // 2x2x2 cube centered around origin glm::mat4 M(1); // no transformation