Skip to content

Commit

Permalink
Fix warnings that turned into errors in GCC 14 and some more
Browse files Browse the repository at this point in the history
Principia now compiles without needing to downgrade any errors again!
  • Loading branch information
rollerozxa committed Jun 5, 2024
1 parent 7cd0ffa commit c604e53
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 251 deletions.
11 changes: 1 addition & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,7 @@ endif()

add_definitions(-DTMS_BACKEND_${TMS_FORMFACTOR} -DTMS_BACKEND_${TMS_BACKEND})

# Downgrade int-conversion and incompatible(-function)-pointer-types, which are errors
# in both GCC and Clang now, into regular warnings.

set(COMMON_FLAGS "-ffast-math -Wno-error=int-conversion")

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(COMMON_FLAGS "${COMMON_FLAGS} -Wno-error=incompatible-function-pointer-types")
else()
set(COMMON_FLAGS "${COMMON_FLAGS} -Wno-error=incompatible-pointer-types")
endif()
set(COMMON_FLAGS "-ffast-math")

set(COMMON_FLAGS_DEBUG "${COMMON_FLAGS} -O0 -ggdb -DDEBUG=1")
set(COMMON_FLAGS_RELEASE "${COMMON_FLAGS} -DNDEBUG=1 -fomit-frame-pointer")
Expand Down
4 changes: 2 additions & 2 deletions src/luasocket/inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
lua_pushstring(L, name);
Expand Down Expand Up @@ -285,7 +285,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
lua_pushstring(L, name);
Expand Down
2 changes: 2 additions & 0 deletions src/luasocket/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
\*=========================================================================*/
#ifdef _WIN32
#include "wsocket.h"
#define LUA_GAI_STRERROR gai_strerrorA
#else
#include "usocket.h"
#define LUA_GAI_STRERROR gai_strerror
#endif

/*=========================================================================*\
Expand Down
4 changes: 2 additions & 2 deletions src/luasocket/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int meth_sendto(lua_State *L) {
err = getaddrinfo(ip, port, &aihint, &ai);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
timeout_markstart(tm);
Expand Down Expand Up @@ -248,7 +248,7 @@ static int meth_receivefrom(lua_State *L)
INET6_ADDRSTRLEN, portstr, 6, NI_NUMERICHOST | NI_NUMERICSERV);
if (err) {
lua_pushnil(L);
lua_pushstring(L, gai_strerror(err));
lua_pushstring(L, LUA_GAI_STRERROR(err));
return 2;
}
lua_pushlstring(L, buffer, got);
Expand Down
2 changes: 1 addition & 1 deletion src/luasocket/usocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ const char *socket_gaistrerror(int err) {
case EAI_SERVICE: return "service not supported for socket type";
case EAI_SOCKTYPE: return "ai_socktype not supported";
case EAI_SYSTEM: return strerror(errno);
default: return gai_strerror(err);
default: return LUA_GAI_STRERROR(err);
}
}
#endif
2 changes: 1 addition & 1 deletion src/luasocket/wsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ const char *socket_gaistrerror(int err) {
#ifdef EAI_SYSTEM
case EAI_SYSTEM: return strerror(errno);
#endif
default: return gai_strerror(err);
default: return LUA_GAI_STRERROR(err);
}
}
#endif
1 change: 0 additions & 1 deletion src/src/fxemitter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ class break_effect : public base_effect
private:
struct piece pieces[3];
b2Vec2 trigger_point;
bool played_sound;

public:
break_effect(b2Vec2 pos, int layer);
Expand Down
4 changes: 4 additions & 0 deletions src/src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11442,6 +11442,8 @@ update_entity_id_changed(uint32_t old_id, uint32_t new_id, std::map<uint32_t, en
}
}

#ifdef DEBUG

void
game::clamp_entities()
{
Expand Down Expand Up @@ -11524,6 +11526,8 @@ game::clamp_entities()
of::_id = id;
}

#endif

int
game::post_render()
{
Expand Down
2 changes: 1 addition & 1 deletion src/src/game.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ class game : public pscreen

#ifdef DEBUG
std::set<game_debug_line*> debug_lines;
void clamp_entities();
#endif

void render_num(float x, float y, int iw, int ih, float num, int precision=2, float extra_scale=0.f, bool render_background=true);
Expand All @@ -1162,7 +1163,6 @@ class game : public pscreen
void restart_level();
void submit_score();
void destroy_possible_mover(entity *e);
void clamp_entities();

void render_help_icon(const std::set<entity*> &set, float off_x, float off_y);
bool check_click_help_icon(const std::set<entity*> &set, float off_x, float off_y, b2Vec2 click_pos, struct principia_action click_action);
Expand Down
21 changes: 7 additions & 14 deletions src/src/main.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "game.hh"
#include "main.hh"
#include "tms/core/err.h"
#include "version.hh"
#include "loading_screen.hh"
#include "soundmanager.hh"
Expand Down Expand Up @@ -89,7 +90,6 @@ static struct tms_fb *ao_fb;
static char featured_data_path[1024];
static char featured_data_time_path[1024];
static char cookie_file[1024];
static char username[256];

struct header_data {
char *error_message;
Expand Down Expand Up @@ -123,15 +123,17 @@ static uint32_t _publish_lvl_community_id;
static uint32_t _publish_lvl_id;
static bool _publish_lvl_with_pkg = false;
static bool _publish_lvl_set_locked = false;
static uint8_t _publish_lvl_pkg_index = 0;
static bool _publish_lvl_lock = false;
static volatile bool _publish_lvl_uploading = false;
static bool _publish_lvl_uploading_error = false;

#ifdef BUILD_PKGMGR
/* Publish PKG variables */
static uint8_t _publish_lvl_pkg_index = 0;
static uint32_t _publish_pkg_id;
static volatile bool _publish_pkg_done = false;
static bool _publish_pkg_error = false;
#endif

/* Submit score variables */
static bool _submit_score_done = false;
Expand Down Expand Up @@ -314,7 +316,9 @@ static int edit_loader(int step);
static int pkg_loader(int step);
static int publish_loader(int step);
static int submit_score_loader(int step);
#ifdef BUILD_PKGMGR
static int publish_pkg_loader(int step);
#endif
static int _publish_level(void *p);
static int _download_level(void *p);
static int _check_version_code(void *_unused);
Expand Down Expand Up @@ -1841,8 +1845,6 @@ _download_level(void *p)
_play_header_data.error_action = 0;

CURLcode res;
uint32_t crc=0;
struct stat file_stat;

int arg = (intptr_t)p;
int type = LEVEL_DB;
Expand Down Expand Up @@ -2221,7 +2223,6 @@ write_memory_cb(void *contents, size_t size, size_t nmemb, void *userp)
static int
_check_version_code(void *_unused)
{
int res = T_OK;
CURLcode r;

struct MemoryStruct chunk;
Expand Down Expand Up @@ -2258,11 +2259,9 @@ _check_version_code(void *_unused)
}
} else {
tms_errorf("could not check for latest version: %s", curl_easy_strerror(r));
res = 1;
}
}
} else {
tms_errorf("unable to initialize curl handle!");
res = 1;
}
unlock_curl("check_version_code");

Expand Down Expand Up @@ -2719,7 +2718,6 @@ _publish_level(void *p)
{
uint32_t level_id = _publish_lvl_id;
int community_id = 0;
int error = 0;

_publish_lvl_community_id = 0;
_publish_lvl_uploading_error = false;
Expand Down Expand Up @@ -2843,8 +2841,6 @@ _submit_score(void *p)
{
tms_assertf(W->is_playing(), "submit score called when the level was paused");

int error = 0;

CURLcode r;

char data_path[1024];
Expand Down Expand Up @@ -3058,7 +3054,6 @@ _register(void *p)
{
struct register_data *data = static_cast<struct register_data*>(p);
int res = T_OK;
int num_tries = 0;

CURLcode r;

Expand Down Expand Up @@ -3275,7 +3270,6 @@ submit_score_loader(int step)
#endif

static Uint32 loader_times[32] = {0,};
static Uint32 total_load = 0;

static const char *load_step_name[] = {
/* 0 */ "Initialize atlases",
Expand Down Expand Up @@ -3364,7 +3358,6 @@ initial_loader(int step)
static uint32_t last_time = SDL_GetTicks();

char tmp[512];
Uint32 ss = SDL_GetTicks();
int retval = LOAD_CONT;

switch (step) {
Expand Down
12 changes: 0 additions & 12 deletions src/src/noise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,6 @@ static float grad2( int hash, float x, float y ) {
return ((h&1)? -u : u) + ((h&2)? -2.0f*v : 2.0f*v);
}

/* A lookup table to traverse the simplex around a given point in 4D. */
/* Details can be found where this table is used, in the 4D noise method. */
/* TODO: This should not be required, backport it from Bill's GLSL code! */
static unsigned char simplex[64][4] = {
{0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0},
{0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0},
{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},
{1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0},
{1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0},
{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},
{2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0},
{2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0}};

void
_noise_init_perm(unsigned long seed)
Expand Down
12 changes: 6 additions & 6 deletions src/src/pkgman.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1269,10 +1269,10 @@ lvledit::print_gids()
state_size = lb.r_uint32(); /* state size */
}

float posx = lb.r_float(); /* pos.x */
float posy = lb.r_float(); /* pos.y */
float angle = lb.r_float(); /* angle */
uint8_t layer = (int)lb.r_uint8(); /* layer */
(void)lb.r_float(); /* pos.x */
(void)lb.r_float(); /* pos.y */
(void)lb.r_float(); /* angle */
(void)lb.r_uint8(); /* layer */

if (this->lvl.version >= LEVEL_VERSION_1_5) {
lb.r_uint64(); /* state flags */
Expand All @@ -1286,9 +1286,9 @@ lvledit::print_gids()
/* skip state buffer */
lb.rp += state_size;
} else {
(bool)lb.r_uint8(); /* axisrot */
(void)lb.r_uint8(); /* axisrot */
if (this->lvl.version >= 10) {
(bool)lb.r_uint8(); /* moveable */
(void)lb.r_uint8(); /* moveable */
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/src/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ _settings::init()
{
this->_data.clear();

/* calculate "optimal" shadow map resolution */
double w2 = log2((double)_tms.window_width);
double h2 = log2((double)_tms.window_height);

/** -Graphics **/
this->add("debug", S_BOOL, false);
this->add("postprocess", S_BOOL, false);
Expand All @@ -32,6 +28,10 @@ _settings::init()
this->add("blur_shadow_map", S_BOOL, false);
this->add("swap_shadow_map", S_BOOL, false);
#ifdef TMS_BACKEND_MOBILE
/* calculate "optimal" shadow map resolution */
double w2 = log2((double)_tms.window_width);
double h2 = log2((double)_tms.window_height);

int rw = (int)exp2(roundf(w2)) / 2;
int rh = (int)exp2(roundf(h2)) / 2;

Expand Down Expand Up @@ -161,7 +161,6 @@ _settings::load(void)
return false;
}

int r;
char buf[256];

while (fgets(buf, 256, fh) != NULL) {
Expand All @@ -174,8 +173,6 @@ _settings::load(void)
bool on_key = true;

for (int i = 0; i < sz; ++i) {
char *c = &buf[i];

if (buf[i] == '\n' || buf[i] == ' ') continue;

if (k == 62) {
Expand Down
4 changes: 2 additions & 2 deletions src/src/simplebg.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "entity.hh"

static uint32_t
static inline uint32_t
pack_rgba(float _r, float _g, float _b, float _a)
{
int r = _r * 255.f;
Expand All @@ -13,7 +13,7 @@ pack_rgba(float _r, float _g, float _b, float _a)
return (uint32_t)(r << 24 | g << 16 | b << 8 | a);
}

static void
static inline void
unpack_rgba(uint32_t color, float *r, float *g, float *b, float *a)
{
int _r = (color >> 24) & 0xFF;
Expand Down
10 changes: 8 additions & 2 deletions src/src/ui_gtk3.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

#ifdef TMS_BACKEND_PC

// fuckgtk3
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

Expand Down Expand Up @@ -572,7 +576,7 @@ struct gtk_level_property gtk_level_properties[] = {
"Disable the roaming robots ability to change layer." },
{ LVL_CHUNKED_LEVEL_LOADING,
"Chunked level loading",
"" },
"Splits up the level into chunks, leading to better performance for large levels." },
{ LVL_DISABLE_CAVEVIEW,
"Disable adventure caveview",
"Disable the caveview which appears when the adventure robot is in layer two, with terrain in front of him in layer three." },
Expand All @@ -581,7 +585,7 @@ struct gtk_level_property gtk_level_properties[] = {
"Disable the rocket from triggering any explosives when contact with its flames occurs." },
{ LVL_STORE_SCORE_ON_GAME_OVER,
"Store high score on game over",
"" },
"Allow players to submit a high score even if they did not win the level." },
{ LVL_ALLOW_HIGH_SCORE_SUBMISSIONS,
"Allow high score submissions",
"Allow players to submit their high scores to be displayed on your levels community page." },
Expand Down Expand Up @@ -11761,4 +11765,6 @@ ui::alert(const char *text, uint8_t alert_type/*=ALERT_INFORMATION*/)
gdk_display_flush(gdk_display_get_default());
}

#pragma GCC diagnostic pop

#endif
Loading

0 comments on commit c604e53

Please sign in to comment.