Skip to content

Commit b060080

Browse files
committed
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.
1 parent 4e8376a commit b060080

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/common.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@
3030
# define __has_builtin(x) 0
3131
#endif
3232

33+
/**
34+
* Declare that a function's return value must be used.
35+
*
36+
* Used mostly to guard against potential silent bugs at runtime. This is
37+
* recommended to be added to functions that:
38+
*
39+
* - Allocate / reallocate memory. This prevents memory leaks or errors where
40+
* buffers are expected to have grown to a certain size, but could not be
41+
* resized.
42+
* - Acquire locks. When a lock cannot be acquired, that will almost certainly
43+
* cause a data race / undefined behavior.
44+
*/
45+
#if defined(__GNUC__)
46+
# define GIT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
47+
#else
48+
# define GIT_WARN_UNUSED_RESULT
49+
#endif
50+
3351
#include <assert.h>
3452
#include <errno.h>
3553
#include <limits.h>
@@ -135,24 +153,6 @@ GIT_INLINE(int) git_error__check_version(const void *structure, unsigned int exp
135153
}
136154
#define GIT_ERROR_CHECK_VERSION(S,V,N) if (git_error__check_version(S,V,N) < 0) return -1
137155

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-
156156
/**
157157
* Initialize a structure with a version.
158158
*/

src/win32/path_w32.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#define INCLUDE_win32_path_w32_h__
99

1010
#include "common.h"
11-
#include "vector.h"
1211

1312
/**
1413
* Create a Win32 path (in UCS-2 format) from a UTF-8 string. If the given

0 commit comments

Comments
 (0)