Darshit Shah wrote:
I hope everything is now in order this can be merged into master

Thanks, it's close enough. I installed it along with the attached minor 
cleanups.
From aa459ef443c756c28ce883fdd7f15c98fcefc7dc Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 13 Aug 2017 10:55:55 -0700
Subject: [PATCH 1/2] reallocarray: minor fixes

* doc/glibc-functions/reallocarray.texi: Update version numbers.
* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Don't trust _cv_ contents.
* modules/reallocarray (License): Change from GPL to LGPL.
* tests/test-reallocarray.c (main): Fix ENOMEM typo.
Indent properly and don't use tabs.
---
 ChangeLog                             |  9 +++++++++
 doc/glibc-functions/reallocarray.texi |  6 +++---
 m4/reallocarray.m4                    |  6 +++---
 modules/reallocarray                  |  4 ++--
 tests/test-reallocarray.c             | 22 ++++++++++++----------
 5 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a46d4c2..a07e172 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-08-13  Paul Eggert  <egg...@cs.ucla.edu>
+
+	reallocarray: minor fixes
+	* doc/glibc-functions/reallocarray.texi: Update version numbers.
+	* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Don't trust _cv_ contents.
+	* modules/reallocarray (License): Change from GPL to LGPL.
+	* tests/test-reallocarray.c (main): Fix ENOMEM typo.
+	Indent properly and don't use tabs.
+
 2017-08-13  Darshit Shah  <dar...@gnu.org>
 
 	reallocarray: New module
diff --git a/doc/glibc-functions/reallocarray.texi b/doc/glibc-functions/reallocarray.texi
index 6ce4a93..938a3d8 100644
--- a/doc/glibc-functions/reallocarray.texi
+++ b/doc/glibc-functions/reallocarray.texi
@@ -12,9 +12,9 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 This function is missing on many platforms:
-glibc 2.25, macOS 10.13, FreeBSD 11.0, NetBSD 7.1, OpenBSD 5.5, Minix 3.1.8,
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 11 2011-11, Cygwin, mingw,
-MSVC 14, Interix 3.5, BeOS.
+glibc 2.25, macOS 10.13, FreeBSD 10, NetBSD 7, OpenBSD 5.5, Minix 3.3.0,
+AIX 7.2, HP-UX 11, IRIX, Solaris 11.3, Tru64, Cygwin, mingw,
+MSVC 14, Interix, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/m4/reallocarray.m4 b/m4/reallocarray.m4
index 261df7a..ab542e2 100644
--- a/m4/reallocarray.m4
+++ b/m4/reallocarray.m4
@@ -1,4 +1,4 @@
-# reallocarray.m4 serial 1
+# reallocarray.m4 serial 2
 dnl Copyright (C) 2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,12 +6,12 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_REALLOCARRAY],
 [
-  dnl Persuade glibc <stdlib.h> to declare reallocarray().
+  dnl Persuade glibc <stdlib.h> to declare reallocarray.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_CHECK_FUNCS([reallocarray])
-  if test $ac_cv_func_reallocarray = no; then
+  if test "$ac_cv_func_reallocarray" = no; then
     HAVE_REALLOCARRAY=0
   fi
 ])
diff --git a/modules/reallocarray b/modules/reallocarray
index f833d46..11d32bb 100644
--- a/modules/reallocarray
+++ b/modules/reallocarray
@@ -1,5 +1,5 @@
 Description:
-reallocarray() function that is glibc compatible.
+reallocarray function that is glibc compatible.
 
 Files:
 lib/reallocarray.c
@@ -26,7 +26,7 @@ Include:
 <stdlib.h>
 
 License:
-GPLv3+
+LGPL
 
 Maintainer:
 all
diff --git a/tests/test-reallocarray.c b/tests/test-reallocarray.c
index 587c700..f91ede7 100644
--- a/tests/test-reallocarray.c
+++ b/tests/test-reallocarray.c
@@ -26,16 +26,18 @@ int
 main ()
 {
    size_t n;
-  /* Check that reallocarray fails when requested to allocate a block of memory
-     larger than SIZE_MAX bytes. */
+
+   /* Check that reallocarray fails when requested to allocate a block
+      of memory larger than SIZE_MAX bytes.  */
    for (n = 2; n != 0; n <<= 1)
-	{
-	  if (reallocarray (NULL, (size_t) -1 / n + 1, n))
-        return 1;
-
-	  /* Ensure that errno is correctly set */
-	  if (!errno == ENOMEM)
-		return 1;
-	}
+     {
+       if (reallocarray (NULL, (size_t) -1 / n + 1, n))
+         return 1;
+
+       /* Ensure that errno is correctly set.  */
+       if (errno != ENOMEM)
+         return 1;
+     }
+
    return 0;
 }
-- 
2.7.4

From 825e198de85f173e74500d2adb1ff3bb9276ad5a Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 13 Aug 2017 11:03:40 -0700
Subject: [PATCH 2/2] * lib/reallocarray.c: Fix layout.

---
 lib/reallocarray.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/reallocarray.c b/lib/reallocarray.c
index 05357a4..b4d7259 100644
--- a/lib/reallocarray.c
+++ b/lib/reallocarray.c
@@ -1,4 +1,4 @@
-/* reallocarray() function that is glibc compatible.
+/* reallocarray function that is glibc compatible.
 
    Copyright (C) 2017 Free Software Foundation, Inc.
 
@@ -25,13 +25,14 @@
 #include "xalloc-oversized.h"
 
 void *
-reallocarray(void *ptr, size_t nmemb, size_t size)
+reallocarray (void *ptr, size_t nmemb, size_t size)
 {
     if (xalloc_oversized (nmemb, size))
       {
         errno = ENOMEM;
         return NULL;
       }
-    /* We rely on using the semantics of the GNU realloc() function here. */
-    return realloc(ptr, nmemb * size);
+
+    /* Rely on the semantics of GNU realloc.  */
+    return realloc (ptr, nmemb * size);
 }
-- 
2.7.4

Reply via email to