Skip to content

Commit

Permalink
chore: Warn about unused return values
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioND committed Aug 11, 2024
1 parent d9c8159 commit 8fc9bd3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
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
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
1 change: 1 addition & 0 deletions include/nds/arm9/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ u16 *oamGetGfxPtr(OamState *oam, int gfxOffsetIndex);
///
/// @return
/// The address in VRAM of the allocated sprite.
WARN_UNUSED_RESULT
u16 *oamAllocateGfx(OamState *oam, SpriteSize size, SpriteColorFormat colorFormat);

/// Free VRAM memory obtained with oamAllocateGfx.
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
4 changes: 4 additions & 0 deletions include/nds/ndstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ extern "C" {
/// for the compiler.
#define COMPILER_MEMORY_BARRIER() asm volatile("" ::: "memory")

/// Makes the compiler output a warning if the return value of a function is
/// ignored.
#define WARN_UNUSED_RESULT __attribute__((warn_unused_result))

// Macros related to the bin2o macro of the Makefile
#define GETRAW(name) (name)
#define GETRAWSIZE(name) ((int)name##_size)
Expand Down

0 comments on commit 8fc9bd3

Please sign in to comment.