bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] sigsegv: Avoid "candidate for attribute 'cold'" warning


From: Gleb Fotengauer-Malinovskiy
Subject: [PATCH] sigsegv: Avoid "candidate for attribute 'cold'" warning
Date: Wed, 16 Aug 2023 10:45:00 +0000

Following the glibc commit glibc-2.38~298 ("Mark various cold functions
as __COLD"), the compilation of projects employing the manywarnings
module (such as GNU grep) with with the -flto flag triggers a GCC
warning:

sigsegv.c: In function ‘stackoverflow_deinstall_handler.part.0’:
sigsegv.c:1441:1: error: function might be candidate for attribute ‘cold’ 
[-Werror=suggest-attribute=cold]

* lib/sigsegv.in.h: Check that _GL_CONFIG_H_INCLUDED is defined.
(stackoverflow_deinstall_handler): Mark with attribute 'cold'.
---
 ChangeLog        | 5 +++++
 lib/sigsegv.in.h | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 41fa1a19b0..6e54bd6415 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-08-16  Gleb Fotengauer-Malinovskiy  <glebfm@altlinux.org>  (tiny change)
+       sigsegv: Avoid "candidate for attribute 'cold'" warning.
+       * lib/sigsegv.in.h: Check that _GL_CONFIG_H_INCLUDED is defined.
+       (stackoverflow_deinstall_handler): Mark with attribute 'cold'.
+
 2023-07-10  Bruno Haible  <bruno@clisp.org>
 
        dfa: Overcome wchar_t limitations.
diff --git a/lib/sigsegv.in.h b/lib/sigsegv.in.h
index 7db6c0df39..0dd2152976 100644
--- a/lib/sigsegv.in.h
+++ b/lib/sigsegv.in.h
@@ -19,6 +19,11 @@
 #ifndef _SIGSEGV_H
 #define _SIGSEGV_H
 
+/* This file uses _GL_ATTRIBUTE_COLD.  */
+# if !_GL_CONFIG_H_INCLUDED
+#  error "Please include config.h first."
+# endif
+
 /* Get size_t.  */
 #include <stddef.h>
 
@@ -231,7 +236,7 @@ extern int stackoverflow_install_handler 
(stackoverflow_handler_t handler,
 /*
  * Deinstalls the stack overflow handler.
  */
-extern void stackoverflow_deinstall_handler (void);
+extern void stackoverflow_deinstall_handler (void) _GL_ATTRIBUTE_COLD;
 
 #endif /* HAVE_STACK_OVERFLOW_RECOVERY */
 
-- 
glebfm




reply via email to

[Prev in Thread] Current Thread [Next in Thread]