summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-11-22 09:43:06 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2020-11-25 11:42:07 +0000
commit7b185b83dddde4aa6d1fd6c158c115b618e0814d (patch)
tree91f8db499feb0e2e60994fc506cf690943b2a724
parentc7d607992319c0b117f07960b973bf7cd63fe90f (diff)
downloadlibgit2-ethomson/assert.tar.gz
win32: use GIT_ASSERTethomson/assert
-rw-r--r--src/unix/map.c2
-rw-r--r--src/win32/findfile.c6
-rw-r--r--src/win32/map.c2
-rw-r--r--src/win32/path_w32.c14
-rw-r--r--src/win32/precompiled.h1
-rw-r--r--src/win32/thread.c13
-rw-r--r--src/win32/w32_buffer.c6
7 files changed, 20 insertions, 24 deletions
diff --git a/src/unix/map.c b/src/unix/map.c
index 7f9076e19..62c52578b 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -66,7 +66,7 @@ int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset
int p_munmap(git_map *map)
{
- assert(map != NULL);
+ GIT_ASSERT_ARG(map);
munmap(map->data, map->len);
return 0;
diff --git a/src/win32/findfile.c b/src/win32/findfile.c
index 7f077e154..f541a03d4 100644
--- a/src/win32/findfile.c
+++ b/src/win32/findfile.c
@@ -53,7 +53,9 @@ static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen)
{
wchar_t term, *base = path;
- assert(path && buf && buflen);
+ GIT_ASSERT_ARG_WITH_RETVAL(path, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(buf, NULL);
+ GIT_ASSERT_ARG_WITH_RETVAL(buflen, NULL);
term = (*path == L'"') ? *path++ : L';';
@@ -109,7 +111,7 @@ static int win32_find_git_in_registry(
HKEY hKey;
int error = GIT_ENOTFOUND;
- assert(buf);
+ GIT_ASSERT_ARG(buf);
if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) {
DWORD dwType, cbData;
diff --git a/src/win32/map.c b/src/win32/map.c
index e2ce737de..2aabc9b15 100644
--- a/src/win32/map.c
+++ b/src/win32/map.c
@@ -117,7 +117,7 @@ int p_munmap(git_map *map)
{
int error = 0;
- assert(map != NULL);
+ GIT_ASSERT_ARG(map);
if (map->data) {
if (!UnmapViewOfFile(map->data)) {
diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c
index 9faddcf3b..23efd9269 100644
--- a/src/win32/path_w32.c
+++ b/src/win32/path_w32.c
@@ -492,14 +492,12 @@ size_t git_win32_path_remove_namespace(wchar_t *str, size_t len)
prefix_len = CONST_STRLEN(unc_prefix);
}
- if (remainder) {
- /*
- * Sanity check that the new string isn't longer than the old one.
- * (This could only happen due to programmer error introducing a
- * prefix longer than the namespace it replaces.)
- */
- assert(len >= remainder_len + prefix_len);
-
+ /*
+ * Sanity check that the new string isn't longer than the old one.
+ * (This could only happen due to programmer error introducing a
+ * prefix longer than the namespace it replaces.)
+ */
+ if (remainder && len >= remainder_len + prefix_len) {
if (prefix)
memmove(str, prefix, prefix_len * sizeof(wchar_t));
diff --git a/src/win32/precompiled.h b/src/win32/precompiled.h
index 314383d31..806b1698a 100644
--- a/src/win32/precompiled.h
+++ b/src/win32/precompiled.h
@@ -1,6 +1,5 @@
#include "common.h"
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 51b005bc8..f5cacd320 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -94,10 +94,7 @@ int git_thread_join(
/* Check for the thread having exited uncleanly. If exit was unclean,
* then we don't have a return value to give back to the caller. */
- if (exit != CLEAN_THREAD_EXIT) {
- assert(false);
- thread->result = NULL;
- }
+ GIT_ASSERT(exit == CLEAN_THREAD_EXIT);
if (value_ptr)
*value_ptr = thread->result;
@@ -149,7 +146,7 @@ int git_cond_init(git_cond *cond)
{
/* This is an auto-reset event. */
*cond = CreateEventW(NULL, FALSE, FALSE, NULL);
- assert(*cond);
+ GIT_ASSERT(*cond);
/* If we can't create the event, claim that the reason was out-of-memory.
* The actual reason can be fetched with GetLastError(). */
@@ -164,7 +161,7 @@ int git_cond_free(git_cond *cond)
return EINVAL;
closed = CloseHandle(*cond);
- assert(closed);
+ GIT_ASSERT(closed);
GIT_UNUSED(closed);
*cond = NULL;
@@ -186,7 +183,7 @@ int git_cond_wait(git_cond *cond, git_mutex *mutex)
return error;
wait_result = WaitForSingleObject(*cond, INFINITE);
- assert(WAIT_OBJECT_0 == wait_result);
+ GIT_ASSERT(WAIT_OBJECT_0 == wait_result);
GIT_UNUSED(wait_result);
return git_mutex_lock(mutex);
@@ -200,7 +197,7 @@ int git_cond_signal(git_cond *cond)
return EINVAL;
signaled = SetEvent(*cond);
- assert(signaled);
+ GIT_ASSERT(signaled);
GIT_UNUSED(signaled);
return 0;
diff --git a/src/win32/w32_buffer.c b/src/win32/w32_buffer.c
index b78a7e6f3..f270a1e6a 100644
--- a/src/win32/w32_buffer.c
+++ b/src/win32/w32_buffer.c
@@ -32,13 +32,13 @@ int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w)
return -1;
}
- assert(string_w);
+ GIT_ASSERT(string_w);
/* Measure the string necessary for conversion */
if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, NULL, 0, NULL, NULL)) == 0)
return 0;
- assert(utf8_len > 0);
+ GIT_ASSERT(utf8_len > 0);
GIT_ERROR_CHECK_ALLOC_ADD(&new_size, buf->size, (size_t)utf8_len);
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)
CP_UTF8, WC_ERR_INVALID_CHARS, string_w, (int)len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0)
return handle_wc_error();
- assert(utf8_write_len == utf8_len);
+ GIT_ASSERT(utf8_write_len == utf8_len);
buf->size += utf8_write_len;
buf->ptr[buf->size] = '\0';