Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More compiler warning fixes #273

Merged
merged 9 commits into from
Dec 25, 2020
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
13 changes: 4 additions & 9 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project('taisei', 'c',
license : 'MIT',
version : 'v1.4-dev',
meson_version : '>=0.48.0',
meson_version : '>=0.53.0',
StarWitch marked this conversation as resolved.
Show resolved Hide resolved
default_options : [
# Should really be c11, but gnu11 is a safer default because everything is terrible.
'c_std=gnu11',
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -85,6 +79,7 @@ taisei_c_args = [
'-Wparentheses',
'-Wshadow=compatible-local',
'-Wsometimes-uninitialized',
'-Wstrict-overflow=0',
'-Wstrict-prototypes',
'-Wtype-limits',
'-Wunneeded-internal-declaration',
Expand Down Expand Up @@ -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', [])),
Expand Down
4 changes: 2 additions & 2 deletions src/coroutine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions src/plrmodes/marisa_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/plrmodes/reimu_a.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions src/plrmodes/youmu_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}

Expand Down Expand Up @@ -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,
Expand Down
24 changes: 13 additions & 11 deletions src/resource/animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/stages/stage1/timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/stages/stage2/spells/amulet_of_harm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Akaricchi marked this conversation as resolved.
Show resolved Hide resolved
cmplx o = p->pos + 42 * ca;
cmplx aim = cnormalize(o - core->pos);

Expand Down
4 changes: 2 additions & 2 deletions src/stages/stage2/timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/util/strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/vfs/platform_paths/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down