More compiler warning fixes (#273)
* fix small compile issue with coroutine.c and gcc * fix 'potential nullpointer dereference' warning * fix more potential nullpointers * fix more potential nullpointers - part 2 * a handful of small fixes to silence gcc compiler warnings, mostly potentiall null pointers and style deficiencies * PR changes, bump meson to 0.53.0 * fix potential null error in YoumuB * bump meson version, change initialization * no longer version-splitting meson
This commit is contained in:
parent
b5190e1634
commit
778146ed60
12 changed files with 34 additions and 36 deletions
|
@ -36,7 +36,7 @@ Build-only dependencies
|
|||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- Python >= 3.5
|
||||
- meson >= 0.48.0 (build system; >=0.49.0 recommended)
|
||||
- meson >= 0.53.0
|
||||
|
||||
Optional:
|
||||
|
||||
|
|
13
meson.build
13
meson.build
|
@ -1,7 +1,7 @@
|
|||
project('taisei', 'c',
|
||||
license : 'MIT',
|
||||
version : 'v1.4-dev',
|
||||
meson_version : '>=0.48.0',
|
||||
meson_version : '>=0.53.0',
|
||||
default_options : [
|
||||
# Should really be c11, but gnu11 is a safer default because everything is terrible.
|
||||
'c_std=gnu11',
|
||||
|
@ -29,17 +29,11 @@ project('taisei', 'c',
|
|||
]
|
||||
)
|
||||
|
||||
minimum_recommended_meson_version = '0.49.0'
|
||||
|
||||
if meson.version().version_compare('<@0@'.format(minimum_recommended_meson_version))
|
||||
warning('Old Meson version detected. Try upgrading to at least @0@ if the build fails.'.format(minimum_recommended_meson_version))
|
||||
endif
|
||||
|
||||
is_debug_build = get_option('debug')
|
||||
is_developer_build = (get_option('developer') == 'auto' ? is_debug_build : get_option('developer') == 'true')
|
||||
|
||||
cc = meson.get_compiler('c')
|
||||
python3 = import('python3').find_python()
|
||||
python = import('python').find_installation()
|
||||
macos_app_bundle = get_option('macos_bundle') and host_machine.system() == 'darwin'
|
||||
|
||||
subdir('scripts')
|
||||
|
@ -85,6 +79,7 @@ taisei_c_args = [
|
|||
'-Wparentheses',
|
||||
'-Wshadow=compatible-local',
|
||||
'-Wsometimes-uninitialized',
|
||||
'-Wstrict-overflow=0',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wtype-limits',
|
||||
'-Wunneeded-internal-declaration',
|
||||
|
@ -283,7 +278,7 @@ if macos_app_bundle
|
|||
|
||||
# arguments must be strings...
|
||||
meson.add_install_script(
|
||||
python3.path(),
|
||||
python.path(),
|
||||
join_paths(meson.source_root(), 'scripts', 'macos-install-dylibs.py'),
|
||||
':'.join(meson.get_cross_property('macos_lib_path', [])),
|
||||
':'.join(meson.get_cross_property('macos_tool_path', [])),
|
||||
|
|
|
@ -146,8 +146,8 @@ static struct {
|
|||
|
||||
#else // CO_TASK_STATS
|
||||
|
||||
#define STAT_VAL(name) (0)
|
||||
#define STAT_VAL_SET(name, value) (0)
|
||||
#define STAT_VAL(name) ((void)0)
|
||||
#define STAT_VAL_SET(name, value) ((void)0)
|
||||
|
||||
#endif // CO_TASK_STATS
|
||||
|
||||
|
|
|
@ -104,8 +104,9 @@ TASK(marisa_star_slave_projectile, {
|
|||
}) {
|
||||
MarisaBController *ctrl = ARGS.ctrl;
|
||||
Player *plr = ctrl->plr;
|
||||
MarisaBSlave *slave = NOT_NULL(ENT_UNBOX(ARGS.slave));
|
||||
|
||||
if(!ENT_UNBOX(ARGS.slave)->alive || !player_should_shoot(plr)) {
|
||||
if(!slave->alive || !player_should_shoot(plr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -126,7 +127,7 @@ TASK(marisa_star_slave_projectile, {
|
|||
cmplx next_pos = p->pos;
|
||||
|
||||
for(int t = 0;; ++t) {
|
||||
MarisaBSlave *slave = ENT_UNBOX(ARGS.slave);
|
||||
slave = ENT_UNBOX(ARGS.slave);
|
||||
|
||||
if(slave == NULL || !slave->alive || !player_should_shoot(plr)) {
|
||||
break;
|
||||
|
|
|
@ -214,7 +214,7 @@ static void reimu_spirit_bomb_impact_balls(cmplx pos, int count) {
|
|||
}
|
||||
|
||||
TASK(reimu_spirit_bomb_orb_impact, { BoxedProjectile orb; }) {
|
||||
cmplx pos = ENT_UNBOX(ARGS.orb)->pos;
|
||||
cmplx pos = NOT_NULL(ENT_UNBOX(ARGS.orb))->pos;
|
||||
|
||||
play_sfx("boom");
|
||||
play_sfx("spellend");
|
||||
|
@ -327,7 +327,7 @@ TASK(reimu_spirit_bomb_orb_visual, { BoxedProjectile orb; }) {
|
|||
TASK(reimu_spirit_bomb_orb, { BoxedPlayer plr; int index; real angle; }) {
|
||||
int index = ARGS.index;
|
||||
|
||||
Player *plr = ENT_UNBOX(ARGS.plr);
|
||||
Player *plr = NOT_NULL(ENT_UNBOX(ARGS.plr));
|
||||
Projectile *orb = TASK_BIND(PROJECTILE(
|
||||
.pos = plr->pos,
|
||||
.timeout = 160 + 20 * index,
|
||||
|
|
|
@ -229,7 +229,7 @@ TASK(youmu_haunting_shot_homing, { YoumuBController *ctrl; }) {
|
|||
}
|
||||
|
||||
TASK(youmu_orb_homing_spirit_expire, { BoxedProjectile p; }) {
|
||||
Projectile *p = ENT_UNBOX(ARGS.p);
|
||||
Projectile *p = NOT_NULL(ENT_UNBOX(ARGS.p));
|
||||
|
||||
PARTICLE(
|
||||
.sprite_ptr = p->sprite,
|
||||
|
@ -246,6 +246,7 @@ TASK(youmu_orb_homing_spirit_expire, { BoxedProjectile p; }) {
|
|||
}
|
||||
|
||||
static int youmu_orb_homing_spirit_timeout(Projectile *orb) {
|
||||
assume(orb != NULL);
|
||||
return orb->timeout - projectile_time(orb);
|
||||
}
|
||||
|
||||
|
@ -387,7 +388,7 @@ TASK(youmu_orb_update, { YoumuBController *ctrl; BoxedProjectile orb; }) {
|
|||
|
||||
TASK(youmu_orb_death, { BoxedProjectile orb; BoxedTask control_task; }) {
|
||||
CANCEL_TASK(ARGS.control_task);
|
||||
Projectile *orb = ENT_UNBOX(ARGS.orb);
|
||||
Projectile *orb = NOT_NULL(ENT_UNBOX(ARGS.orb));
|
||||
|
||||
PARTICLE(
|
||||
.proto = pp_blast,
|
||||
|
|
|
@ -317,20 +317,22 @@ static void load_animation_stage2(ResourceLoadState *st) {
|
|||
ani = NULL;
|
||||
}
|
||||
|
||||
if(ani->sprite_count != prev_sprite_count) {
|
||||
// remapping generated new flipped sprites - add them to our sprites array
|
||||
if(ani) {
|
||||
if(ani->sprite_count != prev_sprite_count) {
|
||||
// remapping generated new flipped sprites - add them to our sprites array
|
||||
|
||||
assume(ani->sprite_count > prev_sprite_count);
|
||||
assume(remap_state.num_flipped_sprites == ani->sprite_count - prev_sprite_count);
|
||||
assume(ani->local_sprites != NULL);
|
||||
ani->sprites = realloc(ani->sprites, sizeof(*ani->sprites) * ani->sprite_count);
|
||||
assume(ani->sprite_count > prev_sprite_count);
|
||||
assume(remap_state.num_flipped_sprites == ani->sprite_count - prev_sprite_count);
|
||||
assume(ani->local_sprites != NULL);
|
||||
ani->sprites = realloc(ani->sprites, sizeof(*ani->sprites) * ani->sprite_count);
|
||||
|
||||
for(int i = 0; i < remap_state.num_flipped_sprites; ++i) {
|
||||
ani->sprites[prev_sprite_count + i] = ani->local_sprites + i;
|
||||
for(int i = 0; i < remap_state.num_flipped_sprites; ++i) {
|
||||
ani->sprites[prev_sprite_count + i] = ani->local_sprites + i;
|
||||
}
|
||||
} else {
|
||||
assert(remap_state.num_flipped_sprites == 0);
|
||||
assert(ani->local_sprites == NULL);
|
||||
}
|
||||
} else {
|
||||
assert(remap_state.num_flipped_sprites == 0);
|
||||
assert(ani->local_sprites == NULL);
|
||||
}
|
||||
|
||||
done:
|
||||
|
|
|
@ -655,7 +655,7 @@ TASK(tritoss_fairy, { cmplx pos; cmplx velocity; cmplx end_velocity; }) {
|
|||
}
|
||||
|
||||
TASK(boss_appear, { BoxedBoss boss; }) {
|
||||
Boss *boss = ENT_UNBOX(ARGS.boss);
|
||||
Boss *boss = NOT_NULL(ENT_UNBOX(ARGS.boss));
|
||||
boss->move = move_towards(VIEWPORT_W/2.0 + 100.0*I, 0.05);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ TASK(amulet_fire_spinners, { BoxedEnemy core; BoxedProjectileArray *spinners; })
|
|||
|
||||
ENT_ARRAY_FOREACH(ARGS.spinners, Projectile *p, {
|
||||
int cnt = difficulty_value(12, 16, 22, 24);
|
||||
for(int i = 0; i < cnt; ++i) {
|
||||
cmplx ca = circle_dir(i, cnt);
|
||||
for(int x = 0; x < cnt; ++x) {
|
||||
cmplx ca = circle_dir(x, cnt);
|
||||
cmplx o = p->pos + 42 * ca;
|
||||
cmplx aim = cnormalize(o - core->pos);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ TASK(spinshot_fairy_attack, {
|
|||
)
|
||||
);
|
||||
|
||||
cmplx ref_pos;
|
||||
cmplx ref_pos = NOT_NULL(ENT_UNBOX(ARGS.e))->pos;
|
||||
Enemy *e;
|
||||
|
||||
for(int t = 0; t < ARGS.activate_time; ++t, YIELD) {
|
||||
|
@ -610,7 +610,7 @@ TASK(flea_swirls, {
|
|||
}
|
||||
|
||||
TASK(boss_appear, { BoxedBoss boss; }) {
|
||||
Boss *boss = ENT_UNBOX(ARGS.boss);
|
||||
Boss *boss = NOT_NULL(ENT_UNBOX(ARGS.boss));
|
||||
boss->move = move_towards(VIEWPORT_W/2 + 100.0*I, 0.05);
|
||||
|
||||
aniplayer_queue(&boss->ani, "guruguru", 2);
|
||||
|
|
|
@ -40,7 +40,6 @@ int strbuf_vprintf(StringBuffer *strbuf, const char *format, va_list args) {
|
|||
strbuf->buf_size = new_size;
|
||||
size_available = new_size - offset;
|
||||
|
||||
va_list args_copy;
|
||||
va_copy(args_copy, args);
|
||||
size_required = vsnprintf(strbuf->pos, size_available, format, args_copy);
|
||||
va_end(args_copy);
|
||||
|
|
|
@ -23,7 +23,7 @@ if host_machine.system() == 'windows'
|
|||
elif xdg_systems.contains(host_machine.system())
|
||||
vfs_platform_paths_src += files('cache_xdg.c')
|
||||
elif host_machine.system() == 'darwin'
|
||||
add_languages('objc', native : false)
|
||||
add_languages('objc')
|
||||
taisei_deps += dependency('appleframeworks', modules : 'foundation')
|
||||
vfs_platform_paths_src += files('cache_apple.m')
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue