Remove BAD_RETURN

This commit is contained in:
Arceveti
2021-09-22 11:21:23 -07:00
parent 9e4a569cf6
commit f40a1978d9
11 changed files with 307 additions and 318 deletions

View File

@@ -8,17 +8,6 @@
#include "macros.h"
#include "config.h"
// Certain functions are marked as having return values, but do not
// actually return a value. This causes undefined behavior, which we'd rather
// avoid on modern GCC. This only impacts -O2 and can matter for both the function
// itself and functions that call it.
#ifdef AVOID_UB
#define BAD_RETURN(cmd) void
#else
#define BAD_RETURN(cmd) cmd
#endif
struct Config
{
f32 audioFrequency;

View File

@@ -104,7 +104,7 @@ struct AudioBankSample *func_sh_802f4978(s32 bankId, s32 idx);
s32 func_sh_802f47c8(s32 bankId, u8 idx, s8 *io);
void *func_sh_802f3f08(s32 poolIdx, s32 arg1, s32 arg2, s32 arg3, OSMesgQueue *retQueue);
void func_sh_802f41e4(s32 audioResetStatus);
BAD_RETURN(s32) func_sh_802f3368(s32 bankId);
void func_sh_802f3368(s32 bankId);
void *func_sh_802f3764(s32 arg0, s32 idx, s32 *arg2);
s32 func_sh_802f3024(s32 bankId, s32 instId, s32 arg2);
void func_sh_802f30f4(s32 arg0, s32 arg1, s32 arg2, OSMesgQueue *arg3);

View File

@@ -127,7 +127,7 @@ void func_sh_802f4dcc(s32 audioResetStatus);
void func_sh_802f4e50(struct PendingDmaAudioBank *audioBank, s32 audioResetStatus);
void func_sh_802f50ec(struct PendingDmaAudioBank *arg0, size_t len);
void func_sh_802f517c(uintptr_t devAddr, void *vAddr, size_t nbytes, s32 arg3);
BAD_RETURN(s32) func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *patchInfo, s32 arg3);
void func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *patchInfo, s32 arg3);
s32 func_sh_802f573c(s32 audioResetStatus);
void *func_sh_802f3564(s32 seqId);
s32 func_sh_802f3ec4(s32 arg0, uintptr_t *arg1);
@@ -452,7 +452,7 @@ void func_sh_802f3288(s32 idx) {
}
}
BAD_RETURN(s32) func_sh_802f3368(s32 bankId) {
void func_sh_802f3368(s32 bankId) {
struct SoundMultiPool *pool = &gBankLoadedPool;
struct TemporaryPool *temporary = &pool->temporary;
struct PersistentPool *persistent;
@@ -1428,7 +1428,7 @@ void patch_sound(struct AudioBankSound *sound, struct AudioBank *memBase, struct
#undef PATCH
}
BAD_RETURN(s32) func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *patchInfo, s32 arg3) {
void func_sh_802f5310(s32 bankId, struct AudioBank *mem, struct PatchStruct *patchInfo, s32 arg3) {
UNUSED u32 pad[2];
u8 *addr;
UNUSED u32 pad1[3];

File diff suppressed because it is too large Load Diff

View File

@@ -346,7 +346,7 @@ struct HandheldShakePoint
* A function that is called by CameraTriggers and cutscene shots.
* These are concurrent: multiple CameraEvents can occur on the same frame.
*/
typedef BAD_RETURN(s32) (*CameraEvent)(struct Camera *c);
typedef void (*CameraEvent)(struct Camera *c);
/**
* The same type as a CameraEvent, but because these are generally longer, and happen in sequential
* order, they're are called "shots," a term taken from cinematography.

View File

@@ -196,7 +196,7 @@ static u32 perform_water_step(struct MarioState *m) {
return stepResult;
}
static BAD_RETURN(u32) update_water_pitch(struct MarioState *m) {
static void update_water_pitch(struct MarioState *m) {
struct Object *marioObj = m->marioObj;
if (marioObj->header.gfx.angle[0] > 0) {

View File

@@ -22,7 +22,7 @@ void stub_mario_step_2(void);
void mario_bonk_reflection(struct MarioState *, u32);
void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2);
BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
void init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius);
u32 mario_update_quicksand(struct MarioState *, f32);
u32 mario_push_off_steep_floor(struct MarioState *, u32, u32);

View File

@@ -126,7 +126,7 @@ static s32 obj_is_near_to_and_facing_mario(f32 maxDist, s16 maxAngleDiff) {
//! Although having no return value, this function
//! must be u32 to match other functions on -O2.
static BAD_RETURN(u32) obj_perform_position_op(s32 op) {
static void obj_perform_position_op(s32 op) {
switch (op) {
case POS_OP_SAVE_POSITION:
sObjSavedPosX = o->oPosX;

View File

@@ -135,8 +135,8 @@ s32 count_objects_with_behavior(const BehaviorScript *behavior);
struct Object *cur_obj_find_nearby_held_actor(const BehaviorScript *behavior, f32 maxDist);
void cur_obj_change_action(s32 action);
void cur_obj_set_vel_from_mario_vel(f32 f12,f32 f14);
BAD_RETURN(s16) cur_obj_reverse_animation(void);
BAD_RETURN(s32) cur_obj_extend_animation_if_at_end(void);
void cur_obj_reverse_animation(void);
void cur_obj_extend_animation_if_at_end(void);
s32 cur_obj_check_if_near_animation_end(void);
s32 cur_obj_check_if_at_animation_end(void);
s32 cur_obj_check_anim_frame(s32 frame);

View File

@@ -337,7 +337,7 @@ void save_file_erase(s32 fileIndex) {
}
//! Needs to be s32 to match on -O2, despite no return value.
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
void save_file_copy(s32 srcFileIndex, s32 destFileIndex) {
UNUSED s32 pad;
touch_high_score_ages(destFileIndex);

View File

@@ -154,7 +154,7 @@ extern s8 gSaveFileModified;
void save_file_do_save(s32 fileIndex);
void save_file_erase(s32 fileIndex);
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex);
void save_file_copy(s32 srcFileIndex, s32 destFileIndex);
void save_file_load_all(void);
void save_file_reload(void);
void save_file_collect_star_or_key(s16 coinScore, s16 starIndex);