Skip to content

Commit 4e8376a

Browse files
committed
Move GIT_WARN_UNUSED_RESULT from the public to the private API
1 parent c4cbab3 commit 4e8376a

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

include/git2/common.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,6 @@ typedef size_t size_t;
7171
# define GIT_FORMAT_PRINTF(a,b) /* empty */
7272
#endif
7373

74-
/**
75-
* Declare that a function's return value must be used.
76-
*
77-
* Used mostly to guard against potential silent bugs at runtime. This is
78-
* recommended to be added to functions that:
79-
*
80-
* - Allocate / reallocate memory. This prevents memory leaks or errors where
81-
* buffers are expected to have grown to a certain size, but could not be
82-
* resized.
83-
* - Acquire locks. When a lock cannot be acquired, that will almost certainly
84-
* cause a data race / undefined behavior.
85-
*/
86-
#if defined(__GNUC__)
87-
# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
88-
#else
89-
# define GIT_WARN_UNUSED_RESULT
90-
#endif
91-
9274
#if (defined(_WIN32)) && !defined(__CYGWIN__)
9375
#define GIT_WIN32 1
9476
#endif

src/common.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int exp
135135
}
136136
#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
137137

138+
/**
139+
* Declare that a function's return value must be used.
140+
*
141+
* Used mostly to guard against potential silent bugs at runtime. This is
142+
* recommended to be added to functions that:
143+
*
144+
* - Allocate / reallocate memory. This prevents memory leaks or errors where
145+
* buffers are expected to have grown to a certain size, but could not be
146+
* resized.
147+
* - Acquire locks. When a lock cannot be acquired, that will almost certainly
148+
* cause a data race / undefined behavior.
149+
*/
150+
#if defined(__GNUC__)
151+
# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
152+
#else
153+
# define GIT_WARN_UNUSED_RESULT
154+
#endif
155+
138156
/**
139157
* Initialize a structure with a version.
140158
*/

0 commit comments

Comments
 (0)