This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH v2 1/5] Add nonnull annotation to posix_memalign.
- From: Peter Foley <pefoley2 at pefoley dot com>
- To: cygwin-patches at cygwin dot com
- Cc: Peter Foley <pefoley2 at pefoley dot com>
- Date: Mon, 21 Mar 2016 13:15:42 -0400
- Subject: [PATCH v2 1/5] Add nonnull annotation to posix_memalign.
- Authentication-results: sourceware.org; auth=none
- References: <1458409557-13156-1-git-send-email-pefoley2 at pefoley dot com> <1458409557-13156-5-git-send-email-pefoley2 at pefoley dot com> <20160320111558 dot GG25241 at calimero dot vinschen dot de> <CAOFdcFPxwdnyjbtAm5FVD6d4DhZB9Cm80kPzzNVaCPKfN9yX9Q at mail dot gmail dot com>
GCC 6.0+ asserts that the memptr argument to the builtin function
posix_memalign is nonnull.
Add the necessary annotation to the prototype and
remove the now unnecessary check to fix a warning.
newlib/Changelog
newlib/libc/include/stdlib.h: Annotate arg to posix_memalign as
non-null.
winsup/cygwin/ChangeLog
malloc_wrapper.cc (posix_memalign): Remove always true nonnull check.
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
---
newlib/libc/include/stdlib.h | 2 +-
winsup/cygwin/malloc_wrapper.cc | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index f4b2626..7d4ae76 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -253,7 +253,7 @@ int _EXFUN(_unsetenv_r,(struct _reent *, const char *__string));
#ifdef __rtems__
#if __POSIX_VISIBLE >= 200112
-int _EXFUN(posix_memalign,(void **, size_t, size_t));
+int _EXFUN(__nonnull (1) posix_memalign,(void **, size_t, size_t));
#endif
#endif
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 43b8144..0db5de8 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -126,8 +126,7 @@ posix_memalign (void **memptr, size_t alignment, size_t bytes)
__malloc_unlock ();
if (!res)
return ENOMEM;
- if (memptr)
- *memptr = res;
+ *memptr = res;
return 0;
}
--
2.7.4