groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/23: [grops]: Fix code style nit.


From: G. Branden Robinson
Subject: [groff] 05/23: [grops]: Fix code style nit.
Date: Fri, 16 Sep 2022 13:07:40 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 1b676f414a33964a7e3708a692a70a13d70f9a91
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Sep 13 04:34:52 2022 -0500

    [grops]: Fix code style nit.
    
    * src/devices/grops/ps.cpp (ps_printer::special)
      (resource_manager::process_file): Fix code style nit.  Mark static
      structs initialized within functions and never modified thereafter as
      `const`.  This attempts to work around an apparent false positive from
      AddressSanitizer.  If it doesn't pacify ASAN, please explain to me how
      constant structure members initialized to string literals and function
      pointers within the translation unit can ever be null.  If that is
      infeasible, please report a bug to your compiler vendor.
---
 ChangeLog                  | 15 +++++++++++++++
 src/devices/grops/ps.cpp   |  2 +-
 src/devices/grops/psrm.cpp |  2 +-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bde1e10db..a22309576 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2022-09-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/devices/grops/ps.cpp (ps_printer::special)
+       (resource_manager::process_file): Fix code style nit.  Mark
+       static structs initialized within functions and never modified
+       thereafter as `const`.  This attempts to work around an apparent
+       false positive from AddressSanitizer.  If it doesn't pacify
+       ASAN, please explain to me how constant structure members
+       initialized to string literals and function pointers within the
+       translation unit can ever be null.  If that is infeasible,
+       please report a bug to your compiler vendor.
+
+       Fixes (addresses, at any rate) https://savannah.gnu.org/bugs/\
+       ?61643>.  Thanks to Bjarni Ingi Gislason for the report.
+
 2022-09-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [mdoc]: Refactor: relocate most rendering option handling to
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index b891169e5..732d2bb39 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -1525,7 +1525,7 @@ void ps_printer::special(char *arg, const environment 
*env, char type)
   if (type != 'p')
     return;
   typedef void (ps_printer::*SPECIAL_PROCP)(char *, const environment *);
-  static struct {
+  static const struct {
     const char *name;
     SPECIAL_PROCP proc;
   } proc_table[] = {
diff --git a/src/devices/grops/psrm.cpp b/src/devices/grops/psrm.cpp
index 76d9d13b0..3c9a8b7b9 100644
--- a/src/devices/grops/psrm.cpp
+++ b/src/devices/grops/psrm.cpp
@@ -968,7 +968,7 @@ void resource_manager::process_file(int rank, FILE *fp,
     int (resource_manager::*proc)(const char *, int, FILE *, FILE *);
   };
 
-  static comment_info comment_table[] = {
+  static const comment_info comment_table[] = {
     { "BeginResource:", &resource_manager::do_begin_resource },
     { "IncludeResource:", &resource_manager::do_include_resource },
     { "BeginDocument:", &resource_manager::do_begin_document },



reply via email to

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