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 9 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
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ 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
build/src/overlays/%.o: CHECK_WARNINGS += -Wno-unused-parameter
Dragorn421 marked this conversation as resolved.
Show resolved Hide resolved

CPP := cpp
MKLDSCRIPT := tools/mkldscript
Expand Down
259 changes: 115 additions & 144 deletions include/functions.h

Large diffs are not rendered by default.

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
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -65,6 +66,6 @@ typedef struct {
} Scheduler; // size = 0x258

void Sched_Notify(Scheduler* sc);
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr);
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, UNUSED UNK_TYPE arg3, UNUSED UNK_TYPE arg4, IrqMgr* irqMgr);

#endif
11 changes: 6 additions & 5 deletions include/z64curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "ultra64/types.h"
#include "z64math.h"
#include "macros.h"

struct PlayState;

Expand Down Expand Up @@ -50,13 +51,13 @@ typedef void (*PostCurveLimbDraw)(struct PlayState* play, SkelCurve* skelCuve, s
f32 Curve_Interpolate(f32 x, CurveInterpKnot* knots, s32 knotCount);

void SkelCurve_Clear(SkelCurve* skelCurve);
s32 SkelCurve_Init(struct PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg,
CurveAnimationHeader* animation);
void SkelCurve_Destroy(struct PlayState* play, SkelCurve* skelCurve);
s32 SkelCurve_Init(UNUSED struct PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg,
UNUSED CurveAnimationHeader* animation);
void SkelCurve_Destroy(UNUSED struct PlayState* play, SkelCurve* skelCurve);
void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f32 arg2, f32 endFrame, f32 curFrame,
f32 playSpeed);
s32 SkelCurve_Update(struct PlayState* play, SkelCurve* skelCurve);
void SkelCurve_Draw(Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
s32 SkelCurve_Update(UNUSED struct PlayState* play, SkelCurve* skelCurve);
void SkelCurve_Draw(UNUSED Actor* actor, struct PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
PostCurveLimbDraw postLimbDraw, s32 lod, void* data);

// ZAPD compatibility typedefs
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