8a74d28
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8a74d28
From: Robbie Harwood <rharwood@redhat.com>
8a74d28
Date: Wed, 5 Jan 2022 16:42:11 -0500
8a74d28
Subject: [PATCH] Drop gnulib no-abort.patch
8a74d28
8a74d28
Originally added in db7337a3d353a817ffe9eb4a3702120527100be9, this
8a74d28
patched out all relevant invocations of abort() in gnulib.  While it was
8a74d28
not documented why at the time, testing suggests that there's no abort()
8a74d28
implementation available for gnulib to use.
8a74d28
8a74d28
gnulib's position is that the use of abort() is correct here, since it
8a74d28
happens when input violates a "shall" from POSIX.  Additionally, the
8a74d28
code in question is probably not reachable.  Since abort() is more
8a74d28
friendly to user-space, they prefer to make no change, so we can just
8a74d28
carry a define instead.  (Suggested by Paul Eggert.)
8a74d28
8a74d28
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
8a74d28
(cherry picked from commit 5137c8eb3ec11c3217acea1a93a3f88f3fa4cbca)
8a74d28
---
8a74d28
 bootstrap.conf                              |  2 +-
8a74d28
 conf/Makefile.extra-dist                    |  1 -
8a74d28
 config.h.in                                 |  3 +++
8a74d28
 grub-core/lib/gnulib-patches/no-abort.patch | 26 --------------------------
8a74d28
 4 files changed, 4 insertions(+), 28 deletions(-)
8a74d28
 delete mode 100644 grub-core/lib/gnulib-patches/no-abort.patch
8a74d28
8a74d28
diff --git a/bootstrap.conf b/bootstrap.conf
e622855
index 645e3a459c..71ce943c7d 100644
8a74d28
--- a/bootstrap.conf
8a74d28
+++ b/bootstrap.conf
8a74d28
@@ -81,7 +81,7 @@ cp -a INSTALL INSTALL.grub
8a74d28
 bootstrap_post_import_hook () {
8a74d28
   set -e
8a74d28
   for patchname in fix-null-deref fix-null-state-deref fix-regcomp-uninit-token \
8a74d28
-      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width no-abort; do
8a74d28
+      fix-regexec-null-deref fix-uninit-structure fix-unused-value fix-width; do
8a74d28
     patch -d grub-core/lib/gnulib -p2 \
8a74d28
       < "grub-core/lib/gnulib-patches/$patchname.patch"
8a74d28
   done
8a74d28
diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist
e622855
index f4791dc6ca..5eef708338 100644
8a74d28
--- a/conf/Makefile.extra-dist
8a74d28
+++ b/conf/Makefile.extra-dist
bd73b85
@@ -38,7 +38,6 @@ EXTRA_DIST += grub-core/lib/gnulib-patches/fix-regexec-null-deref.patch
8a74d28
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-uninit-structure.patch
8a74d28
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-unused-value.patch
8a74d28
 EXTRA_DIST += grub-core/lib/gnulib-patches/fix-width.patch
8a74d28
-EXTRA_DIST += grub-core/lib/gnulib-patches/no-abort.patch
8a74d28
 
8a74d28
 EXTRA_DIST += grub-core/lib/libgcrypt
8a74d28
 EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
8a74d28
diff --git a/config.h.in b/config.h.in
e622855
index 9c7b4afaaa..c3134309c6 100644
8a74d28
--- a/config.h.in
8a74d28
+++ b/config.h.in
8a74d28
@@ -68,6 +68,9 @@
8a74d28
 
8a74d28
 #  ifndef _GL_INLINE_HEADER_BEGIN
8a74d28
 #    define _GL_ATTRIBUTE_CONST __attribute__ ((const))
8a74d28
+
8a74d28
+/* We don't have an abort() for gnulib to call in regexp. */
8a74d28
+#    define abort __builtin_unreachable
8a74d28
 #  endif /* !_GL_INLINE_HEADER_BEGIN */
8a74d28
 
8a74d28
 #endif
8a74d28
diff --git a/grub-core/lib/gnulib-patches/no-abort.patch b/grub-core/lib/gnulib-patches/no-abort.patch
8a74d28
deleted file mode 100644
e622855
index e469c4762e..0000000000
8a74d28
--- a/grub-core/lib/gnulib-patches/no-abort.patch
8a74d28
+++ /dev/null
8a74d28
@@ -1,26 +0,0 @@
8a74d28
-diff --git a/lib/regcomp.c b/lib/regcomp.c
8a74d28
-index cc85f35ac..de45ebb5c 100644
8a74d28
---- a/lib/regcomp.c
8a74d28
-+++ b/lib/regcomp.c
8a74d28
-@@ -528,9 +528,9 @@ regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
8a74d28
-        to this routine.  If we are given anything else, or if other regex
8a74d28
-        code generates an invalid error code, then the program has a bug.
8a74d28
-        Dump core so we can fix it.  */
8a74d28
--    abort ();
8a74d28
--
8a74d28
--  msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
8a74d28
-+    msg = gettext ("unknown regexp error");
8a74d28
-+  else
8a74d28
-+    msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]);
8a74d28
- 
8a74d28
-   msg_size = strlen (msg) + 1; /* Includes the null.  */
8a74d28
- 
8a74d28
-@@ -1136,7 +1136,7 @@ optimize_utf8 (re_dfa_t *dfa)
8a74d28
- 	}
8a74d28
- 	break;
8a74d28
-       default:
8a74d28
--	abort ();
8a74d28
-+	break;
8a74d28
-       }
8a74d28
- 
8a74d28
-   if (mb_chars || has_period)