bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: [PATCH] rawmemchr: modernize and simplify
Date: Sun, 22 Aug 2021 00:36:42 +0200	[thread overview]
Message-ID: <6862331.lOV4Wx5bFT@omega> (raw)
In-Reply-To: <20210821022616.945879-1-eggert@cs.ucla.edu>

Hi Paul,

> * lib/rawmemchr.c (HAVE_RAWMEMCHR): Assume it’s not defined;
> otherwise this file would not be compiled.

Unfortunately, this assumption does not hold. This file, when used as
part of the 'relocatable-prog-wrapper' module, is compiled unconditionally.

$ ./gnulib-tool --find lib/rawmemchr.c
rawmemchr
relocatable-prog-wrapper

In build-aux/install-reloc lines 225..253 the compilation command compiles
this file always. The patch thus causes a definition of rawmemchr to be
included in the trampoline executables even on platforms that don't need it.

This patch should fix it.


2021-08-21  Bruno Haible  <bruno@clisp.org>

	rawmemchr: Fix use in relocatable-prog-wrapper (regression 2021-08-20).
	* lib/rawmemchr.c: Restore test of HAVE_RAWMEMCHR.
	* modules/relocatable-prog-wrapper (Depends-on): Add stdalign.

diff --git a/lib/rawmemchr.c b/lib/rawmemchr.c
index 469bfa3cd..e7a00b803 100644
--- a/lib/rawmemchr.c
+++ b/lib/rawmemchr.c
@@ -19,11 +19,14 @@
 /* Specification.  */
 #include <string.h>
 
-#include <limits.h>
-#include <stdalign.h>
-#include <stdint.h>
+/* A function definition is only needed if HAVE_RAWMEMCHR is not defined.  */
+#if !HAVE_RAWMEMCHR
 
-#include "verify.h"
+# include <limits.h>
+# include <stdalign.h>
+# include <stdint.h>
+
+# include "verify.h"
 
 /* Find the first occurrence of C in S.  */
 void *
@@ -118,3 +121,5 @@ rawmemchr (const void *s, int c_in)
     char_ptr++;
   return (void *) char_ptr;
 }
+
+#endif
diff --git a/modules/relocatable-prog-wrapper b/modules/relocatable-prog-wrapper
index d816033ee..fa5691621 100644
--- a/modules/relocatable-prog-wrapper
+++ b/modules/relocatable-prog-wrapper
@@ -64,6 +64,7 @@ largefile
 libc-config
 pathmax
 ssize_t
+stdalign
 stdbool
 stddef
 stdint





      reply	other threads:[~2021-08-21 22:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21  2:26 [PATCH] rawmemchr: modernize and simplify Paul Eggert
2021-08-21 22:36 ` Bruno Haible [this message]

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=6862331.lOV4Wx5bFT@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).