public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] libiberty: Fix C89-isms in configure tests
Date: Tue, 18 Oct 2022 12:05:49 +0200	[thread overview]
Message-ID: <87h701jvk2.fsf@oldenburg.str.redhat.com> (raw)

libiberty/

	* acinclude.m4 (check for working strncmp): Add missing
	int return type and parameter list to the definition of main.
	Include <string.h> for string functions.  Avoid calling
	undeclared exit function.
        (stack direction for C alloca): Avoid calling undeclared exit
        function.
	* configure: Regenerate.

---
 libiberty/acinclude.m4 | 12 +++++++-----
 libiberty/configure    | 12 +++++++-----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4
index 6bd127e9826..6e23ae906fc 100644
--- a/libiberty/acinclude.m4
+++ b/libiberty/acinclude.m4
@@ -24,6 +24,7 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
 [AC_TRY_RUN([
 /* Test by Jim Wilson and Kaveh Ghazi.
    Check whether strncmp reads past the end of its string parameters. */
+#include <string.h>
 #include <sys/types.h>
 
 #ifdef HAVE_FCNTL_H
@@ -51,7 +52,8 @@ AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
 
 #define MAP_LEN 0x10000
 
-main ()
+int
+main (void)
 {
 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
   char *p;
@@ -59,7 +61,7 @@ main ()
 
   dev_zero = open ("/dev/zero", O_RDONLY);
   if (dev_zero < 0)
-    exit (1);
+    return 1;
 
   p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		     MAP_ANON|MAP_PRIVATE, dev_zero, 0);
@@ -67,7 +69,7 @@ main ()
     p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		       MAP_ANON|MAP_PRIVATE, -1, 0);
   if (p == (char *)-1)
-    exit (2);
+    return 2;
   else
     {
       char *string = "__si_type_info";
@@ -79,7 +81,7 @@ main ()
       strncmp (r, q, 14);
     }
 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
-  exit (0);
+  return 0;
 }
 ], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
   ac_cv_func_strncmp_works=yes)
@@ -171,7 +173,7 @@ AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
 }
 main ()
 {
-  exit (find_stack_direction() < 0);
+  return find_stack_direction() < 0;
 }],
   ac_cv_c_stack_direction=1,
   ac_cv_c_stack_direction=-1,
diff --git a/libiberty/configure b/libiberty/configure
index 65fc5002002..c871cc559ca 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -6798,7 +6798,7 @@ find_stack_direction ()
 }
 main ()
 {
-  exit (find_stack_direction() < 0);
+  return find_stack_direction() < 0;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -7621,6 +7621,7 @@ else
 
 /* Test by Jim Wilson and Kaveh Ghazi.
    Check whether strncmp reads past the end of its string parameters. */
+#include <string.h>
 #include <sys/types.h>
 
 #ifdef HAVE_FCNTL_H
@@ -7648,7 +7649,8 @@ else
 
 #define MAP_LEN 0x10000
 
-main ()
+int
+main (void)
 {
 #if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
   char *p;
@@ -7656,7 +7658,7 @@ main ()
 
   dev_zero = open ("/dev/zero", O_RDONLY);
   if (dev_zero < 0)
-    exit (1);
+    return 1;
 
   p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		     MAP_ANON|MAP_PRIVATE, dev_zero, 0);
@@ -7664,7 +7666,7 @@ main ()
     p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
 		       MAP_ANON|MAP_PRIVATE, -1, 0);
   if (p == (char *)-1)
-    exit (2);
+    return 2;
   else
     {
       char *string = "__si_type_info";
@@ -7676,7 +7678,7 @@ main ()
       strncmp (r, q, 14);
     }
 #endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
-  exit (0);
+  return 0;
 }
 
 _ACEOF

base-commit: 54b316ff0d4f3bd823ad0b4d0011900948c5d40e


             reply	other threads:[~2022-10-18 10:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 10:05 Florian Weimer [this message]
2022-10-18 12:57 ` Jakub Jelinek
2022-10-18 14:06   ` Florian Weimer
2022-10-18 14:08     ` Jakub Jelinek
2022-10-18 14:14       ` Florian Weimer
2022-10-18 14:19         ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h701jvk2.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).