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

Unused variable/parameter cleanup #1321

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ EMU_FLAGS = --noosd
INC := -Iinclude -Isrc -Ibuild -I.

# Check code syntax with host compiler
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-variable -Wno-missing-braces
CHECK_WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unknown-pragmas -Wno-missing-braces
# Actors and effets are mostly callback functions and often don't use all arguments,
# ignore those warnings entirely instead of bloating their source with UNUSED.
build/src/overlays/actors/%.o: CHECK_WARNINGS += -Wno-unused-parameter
build/src/overlays/effects/%.o: CHECK_WARNINGS += -Wno-unused-parameter

CPP := cpp
MKLDSCRIPT := tools/mkldscript
Expand Down
41 changes: 6 additions & 35 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ u8 Actor_ApplyDamage(Actor* actor);
void Actor_SetDropFlag(Actor* actor, ColliderInfo* colInfo, s32 freezeFlag);
void Actor_SetDropFlagJntSph(Actor* actor, ColliderJntSph* jntSph, s32 freezeFlag);
void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3);
Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused,
Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* arg5,
PlayState* play, s16 params, Gfx* dList);
void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2);
s32 Flags_GetEventChkInf(s32 flag);
Expand Down Expand Up @@ -822,7 +822,7 @@ void Font_LoadOrderedFont(Font* font);
s32 Environment_ZBufValToFixedPoint(s32 zBufferVal);
u16 Environment_GetPixelDepth(s32 x, s32 y);
void Environment_GraphCallback(GraphicsContext* gfxCtx, void* param);
void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused);
void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 arg2);
u8 Environment_SmoothStepToU8(u8* pvalue, u8 target, u8 scale, u8 step, u8 minStep);
u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minStep);
f32 Environment_LerpWeight(u16 max, u16 min, u16 val);
Expand All @@ -835,16 +835,16 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
GraphicsContext* gfxCtx);
void Environment_DrawSunAndMoon(PlayState* play);
void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view,
GraphicsContext* gfxCtx, Vec3f pos, s32 unused);
GraphicsContext* gfxCtx, Vec3f pos, s32 arg5);
void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view,
GraphicsContext* gfxCtx, Vec3f pos, s32 unused, s16 scale, f32 colorIntensity,
GraphicsContext* gfxCtx, Vec3f pos, s32 arg5, s16 scale, f32 colorIntensity,
s16 glareStrength, u8 isSun);
void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx);
void Environment_ChangeLightSetting(PlayState* play, u32 lightSetting);
void Environment_DrawSkyboxFilters(PlayState* play);
void Environment_UpdateLightningStrike(PlayState* play);
void Environment_AddLightningBolts(PlayState* play, u8 num);
void Environment_DrawLightning(PlayState* play, s32 unused);
void Environment_DrawLightning(PlayState* play, s32 arg1);
void Environment_PlaySceneSequence(PlayState* play);
void Environment_DrawCustomLensFlare(PlayState* play);
void Environment_InitGameOverLights(PlayState* play);
Expand Down Expand Up @@ -1360,39 +1360,10 @@ u32 Letterbox_GetSize(void);
void Letterbox_Init(void);
void Letterbox_Destroy(void);
void Letterbox_Update(s32 updateRate);
// ? DbCamera_AddVecGeoToVec3f(?);
// ? DbCamera_CalcUpFromPitchYawRoll(?);
// ? DbCamera_SetTextValue(?);
// ? DbCamera_Vec3SToF(?);
// ? DbCamera_Vec3FToS(?);
// ? DbCamera_CopyVec3f(?);
// ? DbCamera_Vec3SToF2(?);
// ? func_800B3F94(?);
// ? func_800B3FF4(?);
// ? func_800B404C(?);
// ? func_800B4088(?);
// ? func_800B41DC(?);
// ? func_800B42C0(?);
// ? func_800B4370(?);
// ? func_800B44E0(?);
// ? DbCamera_PrintPoints(?);
// ? DbCamera_PrintF32Bytes(?);
// ? DbCamera_PrintU16Bytes(?);
// ? DbCamera_PrintS16Bytes(?);
// ? DbCamera_PrintCutBytes(?);
void DbCamera_Init(DbCamera* dbCamera, Camera* cameraPtr);
void DbgCamera_Enable(DbCamera* dbCamera, Camera* cam);
void DbCamera_Update(DbCamera* dbCamera, Camera* cam);
// ? DbCamera_GetFirstAvailableLetter(?);
// ? DbCamera_InitCut(?);
// ? DbCamera_ResetCut(?);
// ? DbCamera_CalcMempakAllocSize(?);
// ? DbCamera_GetMempakAllocSize(?);
// ? DbCamera_DrawSlotLetters(?);
// ? DbCamera_PrintAllCuts(?);
// ? func_800B91B0(?);
void DbCamera_Reset(Camera* cam, DbCamera* dbCam);
// ? DbCamera_UpdateDemoControl(?);
void func_800BB0A0(f32 u, Vec3f* pos, f32* roll, f32* viewAngle, f32* point0, f32* point1, f32* point2, f32* point3);
s32 func_800BB2B4(Vec3f* pos, f32* roll, f32* fov, CutsceneCameraPoint* point, s16* keyFrame, f32* curFrame);
s32 Mempak_Init(s32 controllerNb);
Expand Down Expand Up @@ -1525,7 +1496,7 @@ void Graph_Init(GraphicsContext* gfxCtx);
void Graph_Destroy(GraphicsContext* gfxCtx);
void Graph_TaskSet00(GraphicsContext* gfxCtx);
void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState);
void Graph_ThreadEntry(void*);
void Graph_ThreadEntry(void* arg);
void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size);
void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size);
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line);
Expand Down
27 changes: 20 additions & 7 deletions include/macros.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef MACROS_H
#define MACROS_H

#ifndef GLUE
#define GLUE(a,b) a##b
#endif
#define GLUE2(a,b) GLUE(a,b)

#ifndef __GNUC__
#define __attribute__(x)
#endif
Expand All @@ -14,6 +19,14 @@
#define UNUSED __attribute__((unused))
#define FALLTHROUGH __attribute__((fallthrough))

#ifndef NON_MATCHING
#define STACK_PAD(type) UNUSED type GLUE2(__stack_pad_, __LINE__)
#define STACK_PADS(type, n) STACK_PAD(type) [(n)]
#else
#define STACK_PAD(type)
#define STACK_PADS(type, n)
#endif

#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))

Expand Down Expand Up @@ -138,7 +151,7 @@
} \
(void)0

extern GraphicsContext* __gfxCtx;
extern struct GraphicsContext* __gfxCtx;

#define WORK_DISP __gfxCtx->work.p
#define POLY_OPA_DISP __gfxCtx->polyOpa.p
Expand All @@ -147,12 +160,12 @@ extern GraphicsContext* __gfxCtx;

// __gfxCtx shouldn't be used directly.
// Use the DISP macros defined above when writing to display buffers.
#define OPEN_DISPS(gfxCtx, file, line) \
{ \
GraphicsContext* __gfxCtx; \
Gfx* dispRefs[4]; \
__gfxCtx = gfxCtx; \
(void)__gfxCtx; \
#define OPEN_DISPS(gfxCtx, file, line) \
{ \
struct GraphicsContext* __gfxCtx; \
Gfx* dispRefs[4]; \
__gfxCtx = gfxCtx; \
(void)__gfxCtx; \
Graph_OpenDisps(dispRefs, gfxCtx, file, line)

#define CLOSE_DISPS(gfxCtx, file, line) \
Expand Down
2 changes: 2 additions & 0 deletions include/message_data_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* The strings are used in the message_data_static files themselves, as you can only concat strings with other strings
*/

#ifndef GLUE
#define GLUE(a, b) a##b
#endif

#define STRINGIFY(s) #s
#define EXPAND_AND_STRINGIFY(s) STRINGIFY(s)
Expand Down
1 change: 1 addition & 0 deletions include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "ultra64.h"
#include "irqmgr.h"
#include "macros.h"
Thar0 marked this conversation as resolved.
Show resolved Hide resolved

#define OS_SC_NEEDS_RDP 0x0001 // Task uses the RDP
#define OS_SC_NEEDS_RSP 0x0002 // Task uses the RSP
Expand Down
4 changes: 2 additions & 2 deletions src/boot/is_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void rmonPrintf(const char* fmt, ...) {
va_end(args);
}

void* is_proutSyncPrintf(void* arg, const char* str, u32 count) {
void* is_proutSyncPrintf(UNUSED void* arg, const char* str, u32 count) {
u32 data;
s32 pos;
s32 start;
Expand Down Expand Up @@ -69,7 +69,7 @@ void* is_proutSyncPrintf(void* arg, const char* str, u32 count) {
u32 addr = (u32)&gISVDbgPrnAdrs->data + (start & 0xFFFFFFC);
s32 shift = ((3 - (start & 3)) * 8);

if (*str) {
if (*str != '\0') {
osEPiReadIo(sISVHandle, addr, &data);
osEPiWriteIo(sISVHandle, addr, (*str << shift) | (data & ~(0xFF << shift)));

Expand Down
2 changes: 1 addition & 1 deletion src/boot/yaz0.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ u32 sYaz0CurSize;
u8* sYaz0MaxPtr;

void* Yaz0_FirstDMA(void) {
s32 pad[2];
STACK_PADS(s32, 2);
u32 dmaSize;
u32 bufferSize;

Expand Down
8 changes: 4 additions & 4 deletions src/boot/z_std_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, u32 size) {
OSMesg msg;
s32 ret;
u32 buffSize = gDmaMgrDmaBuffSize;
s32 pad[2];
STACK_PADS(s32, 2);

if (buffSize == 0) {
buffSize = 0x2000;
Expand Down Expand Up @@ -309,7 +309,7 @@ void DmaMgr_ProcessMsg(DmaRequest* req) {
}
}

void DmaMgr_ThreadEntry(void* arg) {
void DmaMgr_ThreadEntry(UNUSED void* arg) {
OSMesg msg;
DmaRequest* req;

Expand All @@ -336,7 +336,7 @@ void DmaMgr_ThreadEntry(void* arg) {
osSyncPrintf("DMAマネージャスレッド実行終了\n");
}

s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, u32 unk, OSMesgQueue* queue,
s32 DmaMgr_SendRequestImpl(DmaRequest* req, void* ram, uintptr_t vrom, u32 size, UNUSED u32 unk, OSMesgQueue* queue,
OSMesg msg) {
static s32 sDmaMgrQueueFullLogged = 0;

Expand Down Expand Up @@ -440,7 +440,7 @@ s32 DmaMgr_SendRequest1(void* ram, uintptr_t vrom, u32 size, const char* file, s
s32 ret;
OSMesgQueue queue;
OSMesg msg;
s32 pad;
STACK_PAD(s32);

req.filename = file;
req.line = line;
Expand Down
6 changes: 3 additions & 3 deletions src/code/PreRender.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
s32 buffB[5 * 3];
s32 xi;
s32 yi;
s32 pad;
STACK_PAD(s32);
s32 pmaxR;
s32 pmaxG;
s32 pmaxB;
Expand Down Expand Up @@ -684,11 +684,11 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
void PreRender_DivotFilter(PreRender* this) {
s32 x;
s32 y;
s32 pad1;
STACK_PAD(s32);
u8* buffR = alloca(this->width);
u8* buffG = alloca(this->width);
u8* buffB = alloca(this->width);
s32 pad2[3];
STACK_PADS(s32, 3);
s32 pxR;
s32 pxG;
s32 pxB;
Expand Down
4 changes: 2 additions & 2 deletions src/code/__osMalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
ArenaNode* overNext2;
ArenaNode localCopy;
u32 blockSize;
s32 pad;
STACK_PAD(s32);

newSize = ALIGN16(newSize);
osSyncPrintf("__osRealloc(%08x, %d)\n", ptr, newSize);
Expand Down Expand Up @@ -645,7 +645,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
return ptr;
}

void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, s32 line) {
void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, UNUSED const char* file, UNUSED s32 line) {
return __osRealloc(arena, ptr, newSize);
}

Expand Down
2 changes: 1 addition & 1 deletion src/code/audioMgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
audioMgr->rspTask = rspTask;
}

void AudioMgr_HandlePreNMI(AudioMgr* audioMgr) {
void AudioMgr_HandlePreNMI(UNUSED AudioMgr* audioMgr) {
// "Audio manager received OS_SC_PRE_NMI_MSG"
osSyncPrintf("オーディオマネージャが OS_SC_PRE_NMI_MSG を受け取りました\n");
Audio_PreNMI();
Expand Down
2 changes: 1 addition & 1 deletion src/code/audio_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void Audio_NotePortamentoInit(Note* note) {
note->playbackState.portamento = note->playbackState.parentLayer->portamento;
}

void Audio_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, s16* volOut) {
void Audio_AdsrInit(AdsrState* adsr, EnvelopePoint* envelope, UNUSED s16* volOut) {
adsr->action.asByte = 0;
adsr->delay = 0;
adsr->envelope = envelope;
Expand Down
8 changes: 4 additions & 4 deletions src/code/audio_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) {
}
}

void AudioHeap_UpdateReverb(SynthesisReverb* reverb) {
void AudioHeap_UpdateReverb(UNUSED SynthesisReverb* reverb) {
}

void AudioHeap_UpdateReverbs(void) {
Expand Down Expand Up @@ -843,7 +843,7 @@ s32 AudioHeap_ResetStep(void) {
}

void AudioHeap_Init(void) {
s32 pad1[4];
STACK_PADS(s32, 4);
s16* ramAddr;
s32 persistentSize;
s32 temporarySize;
Expand All @@ -852,7 +852,7 @@ void AudioHeap_Init(void) {
OSIntMask intMask;
s32 i;
s32 j;
s32 pad2;
STACK_PAD(s32);
AudioSpec* spec = &gAudioSpecs[gAudioCtx.audioResetSpecIdToLoad]; // Audio Specifications

gAudioCtx.sampleDmaCount = 0;
Expand Down Expand Up @@ -1388,7 +1388,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) {
Instrument* inst;
SoundEffect* soundEffect;
u32* fakematch;
s32 pad[4];
STACK_PADS(s32, 4);

sampleBankTable = gAudioCtx.sampleBankTable;
numFonts = gAudioCtx.soundFontTable->numEntries;
Expand Down
Loading