Commit 450ac186 by Jakob Pfender Committed by Vicent Marti

unix/map.c: Move to new error handling mechanism

parent 57435a6d
...@@ -13,7 +13,7 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o ...@@ -13,7 +13,7 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o
if ((out == NULL) || (len == 0)) { if ((out == NULL) || (len == 0)) {
errno = EINVAL; errno = EINVAL;
return GIT_ERROR; return git__throw(GIT_ERROR, "Failed to mmap. No map or zero length");
} }
out->data = NULL; out->data = NULL;
...@@ -25,7 +25,7 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o ...@@ -25,7 +25,7 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o
mprot = PROT_READ; mprot = PROT_READ;
else { else {
errno = EINVAL; errno = EINVAL;
return GIT_ERROR; return git__throw(GIT_ERROR, "Failed to mmap. Invalid protection parameters");
} }
if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED) if ((flags & GIT_MAP_TYPE) == GIT_MAP_SHARED)
...@@ -35,12 +35,12 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o ...@@ -35,12 +35,12 @@ int git__mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t o
if (flags & GIT_MAP_FIXED) { if (flags & GIT_MAP_FIXED) {
errno = EINVAL; errno = EINVAL;
return GIT_ERROR; return git__throw(GIT_ERROR, "Failed to mmap. FIXED not set");
} }
out->data = mmap(NULL, len, mprot, mflag, fd, offset); out->data = mmap(NULL, len, mprot, mflag, fd, offset);
if (!out->data || out->data == MAP_FAILED) if (!out->data || out->data == MAP_FAILED)
return GIT_EOSERR; return git__throw(GIT_EOSERR, "Failed to mmap. Could not write data");
out->len = len; out->len = len;
return GIT_SUCCESS; return GIT_SUCCESS;
...@@ -51,7 +51,7 @@ int git__munmap(git_map *map) ...@@ -51,7 +51,7 @@ int git__munmap(git_map *map)
assert(map != NULL); assert(map != NULL);
if (!map) if (!map)
return GIT_ERROR; return git__throw(GIT_ERROR, "Failed to munmap. Map does not exist");
munmap(map->data, map->len); munmap(map->data, map->len);
......
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