From ea215257af37e3dcfbfed2ca511138244ffecf63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Wed, 6 Nov 2024 02:01:42 +0000 Subject: [PATCH] chore: Warn about unused results that aren't that problematic --- include/fat.h | 1 + include/nds/arm9/console.h | 1 + include/nds/arm9/dldi.h | 1 + include/nds/arm9/dynamicArray.h | 3 +++ include/nds/arm9/keyboard.h | 1 + include/nds/arm9/linkedlist.h | 3 +++ include/nds/arm9/ndsmotion.h | 3 +++ include/nds/arm9/peripherals/slot2.h | 4 ++++ include/nds/arm9/videoGL.h | 8 ++++++++ include/nds/disc_io.h | 1 + include/nds/system.h | 3 +++ source/common/libnds_internal.h | 1 + 12 files changed, 30 insertions(+) diff --git a/include/fat.h b/include/fat.h index b610a9de..7fc3af61 100644 --- a/include/fat.h +++ b/include/fat.h @@ -86,6 +86,7 @@ char *fatGetDefaultCwd(void); /// /// @return /// Returns a string with the path. +WARN_UNUSED_RESULT const char *fatGetDefaultDrive(void); /// This function initializes a lookup cache on a given FAT file. diff --git a/include/nds/arm9/console.h b/include/nds/arm9/console.h index 93adca24..0d2bd9a2 100644 --- a/include/nds/arm9/console.h +++ b/include/nds/arm9/console.h @@ -344,6 +344,7 @@ void consoleSetWindow(PrintConsole *console, int x, int y, int width, int height /// /// @return /// A read-only pointer to the console with the default values. +WARN_UNUSED_RESULT const PrintConsole *consoleGetDefault(void); /// Make the specified console the render target. diff --git a/include/nds/arm9/dldi.h b/include/nds/arm9/dldi.h index 86356e10..7c42d623 100644 --- a/include/nds/arm9/dldi.h +++ b/include/nds/arm9/dldi.h @@ -103,6 +103,7 @@ void dldiFixDriverAddresses(DLDI_INTERFACE *io); /// Load a DLDI driver from a file and set up the bus permissions. /// /// This is not directly usable as a filesystem driver. +WARN_UNUSED_RESULT DLDI_INTERFACE *dldiLoadFromFile(const char *path); /// Free the memory used by the DLDI driver. diff --git a/include/nds/arm9/dynamicArray.h b/include/nds/arm9/dynamicArray.h index 01f9ffce..6439e1d0 100644 --- a/include/nds/arm9/dynamicArray.h +++ b/include/nds/arm9/dynamicArray.h @@ -35,6 +35,7 @@ typedef struct DynamicArray /// /// @return /// A pointer to the data, or NULL on error. +WARN_UNUSED_RESULT void *DynamicArrayInit(DynamicArray *v, unsigned int initialSize); /// Frees memory allocated by the dynamic array. @@ -52,6 +53,7 @@ void DynamicArrayDelete(DynamicArray *v); /// /// @return /// The data or NULL if v is NULL or the index is out of range. +WARN_UNUSED_RESULT void *DynamicArrayGet(DynamicArray *v, unsigned int index); /// Sets the entry to the supplied value. @@ -65,6 +67,7 @@ void *DynamicArrayGet(DynamicArray *v, unsigned int index); /// /// @return /// Returns false if v is NULL or there isn't enough memory, true otherwise. +WARN_UNUSED_RESULT bool DynamicArraySet(DynamicArray *v, unsigned int index, void *item); #ifdef __cplusplus diff --git a/include/nds/arm9/keyboard.h b/include/nds/arm9/keyboard.h index 3e2b8898..35837188 100644 --- a/include/nds/arm9/keyboard.h +++ b/include/nds/arm9/keyboard.h @@ -118,6 +118,7 @@ typedef enum /// /// @return /// Returns a read-only pointer to the default keyboard. +WARN_UNUSED_RESULT const Keyboard *keyboardGetDefault(void); /// Initializes the keyboard system with the supplied keyboard. diff --git a/include/nds/arm9/linkedlist.h b/include/nds/arm9/linkedlist.h index a27879d7..0d15f671 100644 --- a/include/nds/arm9/linkedlist.h +++ b/include/nds/arm9/linkedlist.h @@ -16,6 +16,8 @@ extern "C" { #endif +#include + /// A node of the linked list. typedef struct LinkedList { @@ -38,6 +40,7 @@ typedef struct LinkedList /// @return /// A pointer to the new node, which is also the new front, or NULL if there /// is not enough memory. +WARN_UNUSED_RESULT LinkedList *linkedlistAdd(LinkedList **front, void *data); /// Removes a node from a linked list. diff --git a/include/nds/arm9/ndsmotion.h b/include/nds/arm9/ndsmotion.h index d838f203..c591d9d7 100644 --- a/include/nds/arm9/ndsmotion.h +++ b/include/nds/arm9/ndsmotion.h @@ -17,6 +17,8 @@ #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -197,6 +199,7 @@ int motion_rotation(void); /// /// @return /// The calibration settings. +WARN_UNUSED_RESULT MotionCalibration *motion_get_calibration(void); /// This sets the calibration settings. diff --git a/include/nds/arm9/peripherals/slot2.h b/include/nds/arm9/peripherals/slot2.h index 8b989069..b189c5f9 100644 --- a/include/nds/arm9/peripherals/slot2.h +++ b/include/nds/arm9/peripherals/slot2.h @@ -16,6 +16,8 @@ extern "C" { #include #include +#include + // TODO: Peripherals marked as "TODO" are not currently detected. // In addition, the following are not listed due to insufficient information: // - Activity Meters @@ -72,6 +74,7 @@ bool peripheralSlot2IsDetected(void); /// /// @return /// Pointer to the string. Don't call free() with this pointer. +WARN_UNUSED_RESULT const char *peripheralSlot2GetName(void); /// Get the mask of SLOT2_PERIPHERALs supported by this device. @@ -99,6 +102,7 @@ void peripheralSlot2Close(void); /// /// @return /// A pointer to the start of the RAM space, or NULL. +WARN_UNUSED_RESULT uint16_t *peripheralSlot2RamStart(void); /// Return the size, in bytes, of Slot-2 RAM space; 0 if not detected. diff --git a/include/nds/arm9/videoGL.h b/include/nds/arm9/videoGL.h index 0cb5011e..eaf90b78 100644 --- a/include/nds/arm9/videoGL.h +++ b/include/nds/arm9/videoGL.h @@ -446,6 +446,7 @@ void glRotatef32i(int angle, int32_t x, int32_t y, int32_t z); /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glTexImage2D(int target, int empty1, GL_TEXTURE_TYPE_ENUM type, int sizeX, int sizeY, int empty2, int param, const void *texture); @@ -508,6 +509,7 @@ static inline enum GL_TEXTURE_SIZE_ENUM glTexSizeToEnum(int size) /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glColorTableEXT(int target, int empty1, uint16_t width, int empty2, int empty3, const void *table); @@ -529,6 +531,7 @@ int glColorTableEXT(int target, int empty1, uint16_t width, int empty2, /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glColorSubTableEXT(int target, int start, int count, int empty1, int empty2, const void *data); @@ -546,6 +549,7 @@ int glColorSubTableEXT(int target, int start, int count, int empty1, /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glGetColorTableEXT(int target, int empty1, int empty2, void *table); /// glAssignColorTable sets the active texture with a palette set with another @@ -562,6 +566,7 @@ int glGetColorTableEXT(int target, int empty1, int empty2, void *table); /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glAssignColorTable(int target, int name); /// Set parameters for the current texture. @@ -597,6 +602,7 @@ u32 glGetTexParameter(void); /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glGetColorTableParameterEXT(int target, int pname, int *params); /// Returns the address allocated to the texure named by name. @@ -649,6 +655,7 @@ int glBindTexture(int target, int name); /// /// @return /// 1 on success, 0 on failure. +WARN_UNUSED_RESULT int glGenTextures(int n, int *names); /// Deletes the specified number of textures (and associated palettes). @@ -1457,6 +1464,7 @@ static inline void glCutoffDepth(fixed12d3 wVal) /// /// @return /// 1 on success, 0 on failure +WARN_UNUSED_RESULT int glInit(void); /// Sets the color of the rear-plane (a.k.a clear color/plane) diff --git a/include/nds/disc_io.h b/include/nds/disc_io.h index da797a56..dcd9e318 100644 --- a/include/nds/disc_io.h +++ b/include/nds/disc_io.h @@ -102,6 +102,7 @@ typedef struct DISC_INTERFACE_STRUCT } DISC_INTERFACE; /// Return the internal DSi SD card interface. +WARN_UNUSED_RESULT const DISC_INTERFACE *get_io_dsisd(void); #ifdef __cplusplus diff --git a/include/nds/system.h b/include/nds/system.h index e2f6d09c..44924cb7 100644 --- a/include/nds/system.h +++ b/include/nds/system.h @@ -284,12 +284,14 @@ bool setCpuClock(bool speed); /// /// @return /// Returns a pointer to the start of the heap. +WARN_UNUSED_RESULT u8 *getHeapStart(void); /// Returns current end of heap space. /// /// @return /// Returns a pointer to the end of the heap. +WARN_UNUSED_RESULT u8 *getHeapEnd(void); /// Returns current heap limit. @@ -297,6 +299,7 @@ u8 *getHeapEnd(void); /// @return /// Returns a pointer to the limit of the heap. It won't grow past this /// address. +WARN_UNUSED_RESULT u8 *getHeapLimit(void); #endif // ARM9 diff --git a/source/common/libnds_internal.h b/source/common/libnds_internal.h index ed0ee1ab..c9ee496d 100644 --- a/source/common/libnds_internal.h +++ b/source/common/libnds_internal.h @@ -21,6 +21,7 @@ typedef struct __TransferRegion struct __bootstub *bootcode; } __TransferRegion, *__pTransferRegion; +WARN_UNUSED_RESULT static inline __TransferRegion volatile *__transferRegion(void) { // The transfer region address needs to be in an uncached mirror of main RAM