Fix errors pointed out by clang

This commit is contained in:
MysterD 2022-03-27 17:25:39 -07:00
parent d78c87c06e
commit 61a1d1fc9c
12 changed files with 26 additions and 16 deletions

View file

@ -62,7 +62,11 @@ static void PrintString(const Label& aLabel, s32 aX, s32 aY, u32 aFrontColorRGBA
} }
static void PrintBox(s32 aX, s32 aY, s32 aWidth, s32 aHeight, u32 aColorRGBA, bool aAlignLeft) { static void PrintBox(s32 aX, s32 aY, s32 aWidth, s32 aHeight, u32 aColorRGBA, bool aAlignLeft) {
#ifdef COOP
if ((aColorRGBA & 0xFF) != 0) {
#else
if ((aColorRGBA && 0xFF) != 0) { if ((aColorRGBA && 0xFF) != 0) {
#endif
Mtx *_Matrix = (Mtx *) alloc_display_list(sizeof(Mtx)); Mtx *_Matrix = (Mtx *) alloc_display_list(sizeof(Mtx));
if (!_Matrix) return; if (!_Matrix) return;
if (aAlignLeft) { if (aAlignLeft) {

View file

@ -183,8 +183,8 @@ s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104,
struct AdsrEnvelope gDefaultEnvelope[] = { struct AdsrEnvelope gDefaultEnvelope[] = {
{ BE_TO_HOST16(4), BE_TO_HOST16(32000) }, // go from 0 to 32000 over the course of 16ms { BE_TO_HOST16(4), BE_TO_HOST16(32000) }, // go from 0 to 32000 over the course of 16ms
{ BE_TO_HOST16(1000), BE_TO_HOST16(32000) }, // stay there for 4.16 seconds { (s16)BE_TO_HOST16(1000), BE_TO_HOST16(32000) }, // stay there for 4.16 seconds
{ BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there { (s16)BE_TO_HOST16(ADSR_HANG), 0 } // then continue staying there
}; };
#endif #endif

View file

@ -1714,6 +1714,7 @@ struct ParallelTrackingPoint sBBHLibraryParTrackPath[] = {
}; };
s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) {
return 0;
} }
static void stub_camera_1(UNUSED s32 unused) { static void stub_camera_1(UNUSED s32 unused) {
@ -2039,6 +2040,7 @@ void mode_behind_mario_camera(struct Camera *c) {
} }
s32 nop_update_water_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) { s32 nop_update_water_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNUSED Vec3f pos) {
return 0;
} }
/** /**
@ -5435,7 +5437,7 @@ void determine_pushing_or_pulling_door(s16 *rotation) {
if (sMarioCamState->action == ACT_PULLING_DOOR) { if (sMarioCamState->action == ACT_PULLING_DOOR) {
*rotation = 0; *rotation = 0;
} else { } else {
*rotation = DEGREES(180); *rotation = (s16)DEGREES(180);
} }
} }
@ -9606,8 +9608,8 @@ s32 intro_peach_move_camera_start_to_pipe(struct Camera *c, struct CutsceneSplin
// The two splines used by this function are reflected in the horizontal plane for some reason, // The two splines used by this function are reflected in the horizontal plane for some reason,
// so they are rotated every frame. Why do this, Nintendo? // so they are rotated every frame. Why do this, Nintendo?
rotate_in_xz(c->focus, c->focus, DEGREES(180)); rotate_in_xz(c->focus, c->focus, (s16)DEGREES(180));
rotate_in_xz(c->pos, c->pos, DEGREES(180)); rotate_in_xz(c->pos, c->pos, (s16)DEGREES(180));
vec3f_set(offset, -1328.f, 260.f, 4664.f); vec3f_set(offset, -1328.f, 260.f, 4664.f);
vec3f_add(c->focus, offset); vec3f_add(c->focus, offset);

View file

@ -77,11 +77,11 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) {
#pragma GCC diagnostic ignored "-Wtype-limits" #pragma GCC diagnostic ignored "-Wtype-limits"
//! Never true //! Never true
if (m->actionState == ACT_GROUND_POUND) { /*if (m->actionState == ACT_GROUND_POUND) {
damageHeight = 600.0f; damageHeight = 600.0f;
} else { } else {*/
damageHeight = 1150.0f; damageHeight = 1150.0f;
} //}
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View file

@ -108,7 +108,7 @@ s32 detect_object_hitbox_overlap(struct Object *a, struct Object *b) {
return 1; return 1;
} }
//! no return value return 0;
} }
s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) { s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) {
@ -140,7 +140,7 @@ s32 detect_object_hurtbox_overlap(struct Object *a, struct Object *b) {
return 1; return 1;
} }
//! no return value return 0;
} }
void clear_object_collision(struct Object *a) { void clear_object_collision(struct Object *a) {

View file

@ -280,6 +280,7 @@ f32 painting_ripple_y(struct Painting *painting, s8 ySource) {
return painting->size / 2.0; // some concentric ripples don't care about Mario return painting->size / 2.0; // some concentric ripples don't care about Mario
break; break;
} }
return painting->size / 2.0;
} }
/** /**
@ -305,6 +306,7 @@ f32 painting_nearest_4th(struct Painting *painting) {
} else if (painting->floorEntered & ENTER_RIGHT) { } else if (painting->floorEntered & ENTER_RIGHT) {
return thirdQuarter; return thirdQuarter;
} }
return thirdQuarter;
} }
/** /**
@ -336,6 +338,7 @@ f32 painting_ripple_x(struct Painting *painting, s8 xSource) {
return painting->size / 2.0; return painting->size / 2.0;
break; break;
} }
return painting->size / 2.0;
} }
/** /**

View file

@ -324,6 +324,7 @@ s32 render_screen_transition(s8 fadeTimer, s8 transType, u8 transTime, struct Wa
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR); return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
break; break;
} }
return render_textured_transition(fadeTimer, transTime, transData, TEX_TRANS_BOWSER, TRANS_TYPE_MIRROR);
} }
Gfx *render_cannon_circle_base(void) { Gfx *render_cannon_circle_base(void) {

View file

@ -188,8 +188,7 @@ f32 get_water_level_below_shadow(struct Shadow *s) {
gShadowAboveWaterOrLava = TRUE; gShadowAboveWaterOrLava = TRUE;
return waterLevel; return waterLevel;
} }
//! @bug Missing return statement. This compiles to return `waterLevel` return waterLevel;
//! incidentally.
} }
/** /**

View file

@ -2845,7 +2845,7 @@ void stub_renderer_6(UNUSED struct GdObj *obj) {
* @return an identifier of the menu just defined * @return an identifier of the menu just defined
*/ */
long defpup(UNUSED const char *menufmt, ...) { long defpup(UNUSED const char *menufmt, ...) {
//! @bug no return; function was stubbed return 0;
} }
/** /**

View file

@ -172,6 +172,7 @@ static const char *shader_item_to_str(uint32_t item, bool with_alpha, bool only_
return "texVal1.a"; return "texVal1.a";
} }
} }
return "unknown";
} }
static void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) { static void append_formula(char *buf, size_t *len, uint8_t c[2][4], bool do_single, bool do_multiply, bool do_mix, bool with_alpha, bool only_alpha, bool opt_alpha) {

View file

@ -76,11 +76,11 @@ static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum Mod
} }
struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) { struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true); return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true);
} }
struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) { struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false); return spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, false);
} }
s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId) { s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId) {

View file

@ -246,7 +246,7 @@ bool directory_sanity_check(struct dirent* dir, char* dirPath, char* outPath) {
if (strchr(dir->d_name, '\\') != NULL) { return false; } if (strchr(dir->d_name, '\\') != NULL) { return false; }
// skip anything that starts with . // skip anything that starts with .
if (dir->d_name == NULL || dir->d_name[0] == '.') { return false; } if (dir->d_name[0] == '.') { return false; }
// build path // build path
if (!concat_path(outPath, dirPath, dir->d_name)) { if (!concat_path(outPath, dirPath, dir->d_name)) {