]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
cpu-supports: remove assert dependency
authorPádraig Brady <P@draigBrady.com>
Tue, 16 Sep 2025 16:38:57 +0000 (17:38 +0100)
committerPádraig Brady <P@draigBrady.com>
Tue, 16 Sep 2025 16:50:25 +0000 (17:50 +0100)
Avoid LGPL incompatibility issues by removing assert.

* lib/cpu-supports.c (hwcaps_allowed): Replace assert()s
with defensive returns allowing the passed hwcap.
* modules/cpu-supports: Remove the dependency.

ChangeLog
lib/cpu-supports.c
modules/cpu-supports

index d6a4df6cd0315b83621414c5fe9dac4e6ff5d192..58e2bde0254a632fb94c5d69958d55843a55ef9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-09-16  Pádraig Brady  <P@draigBrady.com>
+
+       cpu-supports: remove assert dependency
+       Avoid LGPL incompatibility issues by removing assert.
+       * lib/cpu-supports.c (hwcaps_allowed): Replace assert()s
+       with defensive returns allowing the passed hwcap.
+       * modules/cpu-supports: Remove the dependency.
+
 2025-09-16  Bruno Haible  <bruno@clisp.org>
 
        Document msvcrt (native Windows) bugs regarding console output.
index 94b7c4d7bf9aabbc068bf8722cfd33ad7d3b08a9..887c394ecbb03fda812e4af2fbcbed2553c394f7 100644 (file)
@@ -16,7 +16,6 @@
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -31,7 +30,8 @@ hwcap_allowed (char const *glibc_hwcap)
   if (! glibc_hwcap)
     return true;
 
-  assert (*glibc_hwcap == '-');  /* Pass HWCAP with a leading -  */
+  if (*glibc_hwcap != '-')  /* Need to pass HWCAP with a leading -  */
+    return true;
 
   /* Match how GLIBC parses tunables as indicated with:
        GLIBC_TUNABLES=glibc.cpu.hwcaps=... ld.so --list-tunables | grep hwcaps
@@ -58,7 +58,8 @@ hwcap_allowed (char const *glibc_hwcap)
         hwcaps = "";
     }
 
-  assert (hwcaps);
+  if (! hwcaps)  /* Shouldn't happen.  */
+    return true;
 
   if (! *hwcaps)
     return true;
index dcb07df8c373818a81378d7e8834110603031d3d..448eb2a9028306b20b4f44860954bf07258c28f6 100644 (file)
@@ -6,7 +6,6 @@ lib/cpu-supports.h
 lib/cpu-supports.c
 
 Depends-on:
-assert
 attribute
 bool
 c99