diff options
author | Omar Polo <op@omarpolo.com> | 2022-03-19 14:52:11 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2022-03-19 14:52:11 +0000 |
commit | c7949fd545996cd4ecb5d67e62b3956677a5a991 (patch) | |
tree | dabd5150400b2a2af88d6fe069d247cef0ac6f56 /compat | |
parent | e5d82d9472513ef742dbb0b5ac451337625feb58 (diff) |
sync recallocarary.c
original commit from claudio@:
Type-cast getpagesize() from int to size_t for the comparison with d.
getpagesize() will only return positive numbers (there is no negative
page size system) and it can not fail.
Should fix some compiler warnings seen in -portable projects.
OK otto@
Diffstat (limited to 'compat')
-rw-r--r-- | compat/recallocarray.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compat/recallocarray.c b/compat/recallocarray.c index aa3b992..3311be1 100644 --- a/compat/recallocarray.c +++ b/compat/recallocarray.c @@ -1,3 +1,4 @@ +/* $OpenBSD: recallocarray.c,v 1.2 2021/03/18 11:16:58 claudio Exp $ */ /* * Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net> * @@ -66,7 +67,7 @@ recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) if (newsize <= oldsize) { size_t d = oldsize - newsize; - if (d < oldsize / 2 && d < getpagesize()) { + if (d < oldsize / 2 && d < (size_t)getpagesize()) { memset((char *)ptr + newsize, 0, d); return ptr; } |