Skip to content

Commit c6ebdb2

Browse files
committed
win32: use GIT_ASSERT
1 parent 4f5f112 commit c6ebdb2

File tree

7 files changed

+20
-24
lines changed

7 files changed

+20
-24
lines changed

src/unix/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset
6666

6767
int p_munmap(git_map *map)
6868
{
69-
assert(map != NULL);
69+
GIT_ASSERT_ARG(map);
7070
munmap(map->data, map->len);
7171

7272
return 0;

src/win32/findfile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen)
5353
{
5454
wchar_t term, *base = path;
5555

56-
assert(path && buf && buflen);
56+
GIT_ASSERT_ARG_WITH_RETVAL(path, NULL);
57+
GIT_ASSERT_ARG_WITH_RETVAL(buf, NULL);
58+
GIT_ASSERT_ARG_WITH_RETVAL(buflen, NULL);
5759

5860
term = (*path == L'"') ? *path++ : L';';
5961

@@ -109,7 +111,7 @@ static int win32_find_git_in_registry(
109111
HKEY hKey;
110112
int error = GIT_ENOTFOUND;
111113

112-
assert(buf);
114+
GIT_ASSERT_ARG(buf);
113115

114116
if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) {
115117
DWORD dwType, cbData;

src/win32/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int p_munmap(git_map *map)
117117
{
118118
int error = 0;
119119

120-
assert(map != NULL);
120+
GIT_ASSERT_ARG(map);
121121

122122
if (map->data) {
123123
if (!UnmapViewOfFile(map->data)) {

src/win32/path_w32.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,12 @@ size_t git_win32_path_remove_namespace(wchar_t *str, size_t len)
492492
prefix_len = CONST_STRLEN(unc_prefix);
493493
}
494494

495-
if (remainder) {
496-
/*
497-
* Sanity check that the new string isn't longer than the old one.
498-
* (This could only happen due to programmer error introducing a
499-
* prefix longer than the namespace it replaces.)
500-
*/
501-
assert(len >= remainder_len + prefix_len);
502-
495+
/*
496+
* Sanity check that the new string isn't longer than the old one.
497+
* (This could only happen due to programmer error introducing a
498+
* prefix longer than the namespace it replaces.)
499+
*/
500+
if (remainder && len >= remainder_len + prefix_len) {
503501
if (prefix)
504502
memmove(str, prefix, prefix_len * sizeof(wchar_t));
505503

src/win32/precompiled.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22

3-
#include <assert.h>
43
#include <errno.h>
54
#include <limits.h>
65
#include <stdlib.h>

src/win32/thread.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ int git_thread_join(
9494

9595
/* Check for the thread having exited uncleanly. If exit was unclean,
9696
* then we don't have a return value to give back to the caller. */
97-
if (exit != CLEAN_THREAD_EXIT) {
98-
assert(false);
99-
thread->result = NULL;
100-
}
97+
GIT_ASSERT(exit == CLEAN_THREAD_EXIT);
10198

10299
if (value_ptr)
103100
*value_ptr = thread->result;
@@ -149,7 +146,7 @@ int git_cond_init(git_cond *cond)
149146
{
150147
/* This is an auto-reset event. */
151148
*cond = CreateEventW(NULL, FALSE, FALSE, NULL);
152-
assert(*cond);
149+
GIT_ASSERT(*cond);
153150

154151
/* If we can't create the event, claim that the reason was out-of-memory.
155152
* The actual reason can be fetched with GetLastError(). */
@@ -164,7 +161,7 @@ int git_cond_free(git_cond *cond)
164161
return EINVAL;
165162

166163
closed = CloseHandle(*cond);
167-
assert(closed);
164+
GIT_ASSERT(closed);
168165
GIT_UNUSED(closed);
169166

170167
*cond = NULL;
@@ -186,7 +183,7 @@ int git_cond_wait(git_cond *cond, git_mutex *mutex)
186183
return error;
187184

188185
wait_result = WaitForSingleObject(*cond, INFINITE);
189-
assert(WAIT_OBJECT_0 == wait_result);
186+
GIT_ASSERT(WAIT_OBJECT_0 == wait_result);
190187
GIT_UNUSED(wait_result);
191188

192189
return git_mutex_lock(mutex);
@@ -200,7 +197,7 @@ int git_cond_signal(git_cond *cond)
200197
return EINVAL;
201198

202199
signaled = SetEvent(*cond);
203-
assert(signaled);
200+
GIT_ASSERT(signaled);
204201
GIT_UNUSED(signaled);
205202

206203
return 0;

src/win32/w32_buffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
3232
return -1;
3333
}
3434

35-
assert(string_w);
35+
GIT_ASSERT(string_w);
3636

3737
/* Measure the string necessary for conversion */
3838
if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, NULL, 0, NULL, NULL)) == 0)
3939
return 0;
4040

41-
assert(utf8_len > 0);
41+
GIT_ASSERT(utf8_len > 0);
4242

4343
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, (size_t)utf8_len);
4444
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, new_size, 1);
@@ -50,7 +50,7 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
5050
CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0)
5151
return handle_wc_error();
5252

53-
assert(utf8_write_len == utf8_len);
53+
GIT_ASSERT(utf8_write_len == utf8_len);
5454

5555
buf->size += utf8_write_len;
5656
buf->ptr[buf->size] = '\0';

0 commit comments

Comments
 (0)