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

chore: Warn about unused return values #125

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions include/nds/arm9/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions include/nds/arm9/dldi.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static inline 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.
Expand Down
3 changes: 3 additions & 0 deletions include/nds/arm9/dynamicArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/nds/arm9/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions include/nds/arm9/linkedlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
extern "C" {
#endif

#include <nds/ndstypes.h>

/// A node of the linked list.
typedef struct LinkedList
{
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions include/nds/arm9/ndsmotion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <stdbool.h>

#include <nds/ndstypes.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions include/nds/arm9/peripherals/slot2.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ extern "C" {
#include <stdbool.h>
#include <stdint.h>

#include <nds/ndstypes.h>

// TODO: Peripherals marked as "TODO" are not currently detected.
// In addition, the following are not listed due to insufficient information:
// - Activity Meters
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions include/nds/arm9/videoGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions include/nds/disc_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions include/nds/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,19 +284,22 @@ 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.
///
/// @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
Expand Down
1 change: 1 addition & 0 deletions source/common/libnds_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ typedef struct __TransferRegion

static_assert(sizeof(__TransferRegion) <= 0x1000, "Transfer region is too big");

WARN_UNUSED_RESULT
static inline __TransferRegion volatile *__transferRegion(void)
{
// The transfer region address needs to be in an uncached mirror of main RAM
Expand Down