Commit c6ebdb29 by Edward Thomson

win32: use GIT_ASSERT

parent 4f5f1127
......@@ -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;
......
......@@ -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;
......
......@@ -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)) {
......
......@@ -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));
......
#include "common.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
......
......@@ -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;
......
......@@ -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';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment