From e3c475107045cb89c53c114716bafebc7538433f Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Tue, 13 Mar 2012 14:23:24 -0700 Subject: Resolve comments from pull request This converts the map validation function into a macro, tweaks the GITERR_OS system error automatic appending, and adds a tentative new error access API and some quick unit tests for both the old and new error APIs. --- src/map.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/map.h') diff --git a/src/map.h b/src/map.h index d0ca1ee56..96d879547 100644 --- a/src/map.h +++ b/src/map.h @@ -31,7 +31,10 @@ typedef struct { /* memory mapped buffer */ #endif } git_map; -extern int validate_map_args(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); +#define GIT_MMAP_VALIDATE(out, len, prot, flags) do { \ + assert(out != NULL && len > 0); \ + assert((prot & GIT_PROT_WRITE) || (prot & GIT_PROT_READ)); \ + assert((flags & GIT_MAP_FIXED) == 0); } while (0) extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); extern int p_munmap(git_map *map); -- cgit v1.2.3