diff options
| author | lhchavez <lhchavez@lhchavez.com> | 2021-07-30 06:53:49 -0700 |
|---|---|---|
| committer | lhchavez <lhchavez@lhchavez.com> | 2021-08-08 19:08:59 -0700 |
| commit | b060080e9f036ab45b86d5d37473a8ec49c29acf (patch) | |
| tree | cfa07c05436daf26745f8f847d9c76537fe45524 | |
| parent | 4e8376a98cedf82f9e5f5e1acbabba031ed7130c (diff) | |
| download | libgit2-b060080e9f036ab45b86d5d37473a8ec49c29acf.tar.gz | |
Get Win32 builds to build
Previously, the location of `GIT_WARN_UNUSED_RESULT` was causing it to
be included _after_ a bunch of other headers (namely `src/vector.h`),
which broke the build.
This change does two things:
* Moves the `GIT_WARN_UNUSED_RESULT` above most of the `$include`s in
`src/common.h`.
* Stops including `vector.h` from `src/win32/path_w32.c` since the
header itself does not use it.
| -rw-r--r-- | src/common.h | 36 | ||||
| -rw-r--r-- | src/win32/path_w32.h | 1 |
2 files changed, 18 insertions, 19 deletions
diff --git a/src/common.h b/src/common.h index a7c6e8e29..9bb1116b5 100644 --- a/src/common.h +++ b/src/common.h @@ -30,6 +30,24 @@ # define __has_builtin(x) 0 #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 + #include <assert.h> #include <errno.h> #include <limits.h> @@ -136,24 +154,6 @@ 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. */ GIT_INLINE(void) git__init_structure(void *structure, size_t len, unsigned int version) diff --git a/src/win32/path_w32.h b/src/win32/path_w32.h index dab8b96fa..4fadf8d08 100644 --- a/src/win32/path_w32.h +++ b/src/win32/path_w32.h @@ -8,7 +8,6 @@ #define INCLUDE_win32_path_w32_h__ #include "common.h" -#include "vector.h" /** * Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given |
