Please review these changes.
This fixes a couple of low-hanging fruit warnings: this fixes all instances of -Wlogical-op-parenteses, -Wimplicit-function-declaration, and -Wundefined-inline. The last two are actually valid in -std=gnu89, so I just set the standard in premake4.lua.
Code: Select all
diff --git a/premake4.lua b/premake4.lua
index e0f0bdd..684b574 100644
--- a/premake4.lua
+++ b/premake4.lua
@@ -79,6 +79,7 @@ configuration "Debug"
defines { }
flags { "Symbols" }
buildoptions { "-ggdb" }
+ buildoptions { "-std=gnu89" }
-- buildoptions { "-O3" }
targetdir "bin/Debug"
if _OPTIONS.luaassert then defines {"LUA_USE_APICHECK"} end
@@ -88,6 +89,7 @@ configuration "Release"
defines { "NDEBUG=1" }
flags { "Optimize", "NoFramePointer" }
buildoptions { "-O2" }
+ buildoptions { "-std=gnu89" }
targetdir "bin/Release"
diff --git a/src/fov.c b/src/fov.c
index 4683113..188a634 100644
--- a/src/fov.c
+++ b/src/fov.c
@@ -648,7 +648,7 @@ static int lua_fov_line_step(lua_State *L)
fov_line_data *line = &(lua_line->line);
bool dont_stop_at_end = lua_toboolean(L, 2);
- if (!dont_stop_at_end && line->dest_t == line->t || line->dest_t == 0) return 0;
+ if ((!dont_stop_at_end && line->dest_t == line->t) || line->dest_t == 0) return 0;
bool is_corner_blocked = false;
float fx, fy, x0, y0, fx2, fy2, dx, dy;
@@ -1194,7 +1194,7 @@ static int lua_hex_fov_line_step(lua_State *L)
hex_fov_line_data *line = &(lua_line->line);
bool dont_stop_at_end = lua_toboolean(L, 2);
- if (!dont_stop_at_end && line->dest_t == line->t || line->dest_t == 0) return 0;
+ if ((!dont_stop_at_end && line->dest_t == line->t) || line->dest_t == 0) return 0;
line->t += 1;
float fx = INV_SQRT_3_2 * (line->source_x + (float)line->t * line->step_x + line->eps_x);
diff --git a/src/fov/fov.c b/src/fov/fov.c
index 840a690..4c7b3d9 100644
--- a/src/fov/fov.c
+++ b/src/fov/fov.c
@@ -2687,7 +2687,7 @@ void fov_create_los_line(fov_settings_type *settings, void *map, void *source, f
}
/* being "pinched" isn't blocked, because one can still look diagonally */
- if (mb0 && b1 || b0 && mb1 ||
+ if ((mb0 && b1) || (b0 && mb1) ||
gabs * (lower_slope - upper_slope) > GRID_EPSILON ||
gy*((float)(sy - ty) + (float)(tx - sx)*lower_slope - gy*0.5f) > -GRID_EPSILON ||
gy*((float)(sy - ty) + (float)(tx - sx)*upper_slope + gy*0.5f) < GRID_EPSILON)
@@ -2808,7 +2808,7 @@ void fov_create_los_line(fov_settings_type *settings, void *map, void *source, f
}
/* being "pinched" isn't blocked, because one can still look diagonally */
- if (mb0 && b1 || b0 && mb1 ||
+ if ((mb0 && b1) || (b0 && mb1) ||
gabs * (lower_slope - upper_slope) > GRID_EPSILON ||
gx*((float)(sx - tx) + (float)(ty - sy)*lower_slope - gx*0.5f) > -GRID_EPSILON ||
gx*((float)(sx - tx) + (float)(ty - sy)*upper_slope + gx*0.5f) < GRID_EPSILON)
diff --git a/src/main.c b/src/main.c
index d8d4b81..558d157 100644
--- a/src/main.c
+++ b/src/main.c
@@ -350,13 +350,13 @@ void on_event(SDL_Event *event)
else if (wc < 0x800)
{
buf[0] = (0xC0 | wc>>6);
- buf[1] = (0x80 | wc & 0x3F);
+ buf[1] = (0x80 | (wc & 0x3F));
}
else
{
buf[0] = (0xE0 | wc>>12);
- buf[1] = (0x80 | wc>>6 & 0x3F);
- buf[2] = (0x80 | wc & 0x3F);
+ buf[1] = (0x80 | (wc>>6 & 0x3F));
+ buf[2] = (0x80 | (wc & 0x3F));
}
lua_pushstring(L, buf);