aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index b2dab5c34..4cc8d9979 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -126,6 +126,7 @@ tor_mmap_file(const char *filename)
return NULL;
}
+ /* XXXX why not just do fstat here? */
size = filesize = (size_t) lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
/* ensure page alignment */
@@ -294,7 +295,7 @@ tor_vsnprintf(char *str, size_t size, const char *format, va_list args)
int r;
if (size == 0)
return -1; /* no place for the NUL */
- if (size > SSIZE_T_MAX-16)
+ if (size > SIZE_T_CEILING)
return -1;
#ifdef MS_WINDOWS
r = _vsnprintf(str, size, format, args);
@@ -430,7 +431,7 @@ tor_fix_source_file(const char *fname)
* unaligned memory access.
*/
uint16_t
-get_uint16(const char *cp)
+get_uint16(const void *cp)
{
uint16_t v;
memcpy(&v,cp,2);
@@ -442,7 +443,7 @@ get_uint16(const char *cp)
* unaligned memory access.
*/
uint32_t
-get_uint32(const char *cp)
+get_uint32(const void *cp)
{
uint32_t v;
memcpy(&v,cp,4);
@@ -454,7 +455,7 @@ get_uint32(const char *cp)
* unaligned memory access.
*/
uint64_t
-get_uint64(const char *cp)
+get_uint64(const void *cp)
{
uint64_t v;
memcpy(&v,cp,8);
@@ -466,7 +467,7 @@ get_uint64(const char *cp)
* *(uint16_t*)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void
-set_uint16(char *cp, uint16_t v)
+set_uint16(void *cp, uint16_t v)
{
memcpy(cp,&v,2);
}
@@ -475,7 +476,7 @@ set_uint16(char *cp, uint16_t v)
* *(uint32_t*)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void
-set_uint32(char *cp, uint32_t v)
+set_uint32(void *cp, uint32_t v)
{
memcpy(cp,&v,4);
}
@@ -484,7 +485,7 @@ set_uint32(char *cp, uint32_t v)
* *(uint64_t*)(cp) = v, but will not cause segfaults on platforms that forbid
* unaligned memory access. */
void
-set_uint64(char *cp, uint64_t v)
+set_uint64(void *cp, uint64_t v)
{
memcpy(cp,&v,8);
}