mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Move GIT_WARN_UNUSED_RESULT from the public to the private API
This commit is contained in:
@@ -71,24 +71,6 @@ typedef size_t size_t;
|
||||
# define GIT_FORMAT_PRINTF(a,b) /* empty */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Declare that a function's return value must be used.
|
||||
*
|
||||
* Used mostly to guard against potential silent bugs at runtime. This is
|
||||
* recommended to be added to functions that:
|
||||
*
|
||||
* - Allocate / reallocate memory. This prevents memory leaks or errors where
|
||||
* buffers are expected to have grown to a certain size, but could not be
|
||||
* resized.
|
||||
* - Acquire locks. When a lock cannot be acquired, that will almost certainly
|
||||
* cause a data race / undefined behavior.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define GIT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
#if (defined(_WIN32)) && !defined(__CYGWIN__)
|
||||
#define GIT_WIN32 1
|
||||
#endif
|
||||
|
||||
18
src/common.h
18
src/common.h
@@ -135,6 +135,24 @@ GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int exp
|
||||
}
|
||||
#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
|
||||
|
||||
/**
|
||||
* Declare that a function's return value must be used.
|
||||
*
|
||||
* Used mostly to guard against potential silent bugs at runtime. This is
|
||||
* recommended to be added to functions that:
|
||||
*
|
||||
* - Allocate / reallocate memory. This prevents memory leaks or errors where
|
||||
* buffers are expected to have grown to a certain size, but could not be
|
||||
* resized.
|
||||
* - Acquire locks. When a lock cannot be acquired, that will almost certainly
|
||||
* cause a data race / undefined behavior.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define GIT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize a structure with a version.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user