* agent/command.c (cmd_havekey): Constify where possible.
(cmd_genkey): Ditto.
(cmd_get_passphrase): Ditto.
(cmd_passwd): Ditto.
(cmd_export_key): Ditto.
* common/server-help.c (option_value): Constify where possible.
* common/server-help.h (option_value): Ditto.
* common/stringhelp.c (make_dirname): Ditto.
(split_fields): Ditto.
(split_fields_colon): Ditto.
* dirmngr/dirmngr.c (handle_connections): Constify where possible.
* g10/misc.c (optlen): Constify where possible.
* g10/tofu.c (ask_about_binding): Ditto.
* sm/gpgsm.c (run_protect_tool): Constify where possible.
* tests/asschk.c (main): Constify where possible.
* tests/openpgp/fake-pinentry.c (option_value): Constify where possible.
(parse_pinentry_user_data): Ditto.
* tools/gpgconf.c (query_swdb): Constify where possible.

--

glibc-2.43 with -std=gnu23/-std=c23 (default in >= GCC 15) implements
C23's const-preserving macros for stdlib functions (i.e. you pass in
a const pointer, you get one back). Fix some resulting warnings.

Signed-off-by: Sam James <[email protected]>
---
 agent/command.c               | 12 ++++++------
 common/server-help.c          |  4 ++--
 common/server-help.h          |  2 +-
 common/stringhelp.c           |  8 ++++----
 dirmngr/dirmngr.c             |  2 +-
 g10/misc.c                    |  2 +-
 g10/tofu.c                    |  2 +-
 sm/gpgsm.c                    |  4 ++--
 tests/asschk.c                |  2 +-
 tests/openpgp/fake-pinentry.c |  8 ++++----
 tools/gpgconf.c               |  2 +-
 11 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/agent/command.c b/agent/command.c
index 21c95203c..cc3f21ddc 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -663,7 +663,7 @@ cmd_havekey (assuan_context_t ctx, char *line)
   ctrl_t ctrl = assuan_get_pointer (ctx);
   gpg_error_t err;
   unsigned char grip[20];
-  char *p;
+  const char *p;
   int list_mode = 0;  /* Less than 0 for no limit.  */
   int info_mode = 0;
   int counter;
@@ -1186,7 +1186,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
   if (has_option (line, "--preset"))
     flags |= GENKEY_FLAG_PRESET;
   opt_inq_passwd = has_option (line, "--inq-passwd");
-  passwd_nonce = option_value (line, "--passwd-nonce");
+  passwd_nonce = (char *) option_value (line, "--passwd-nonce");
   if (passwd_nonce)
     {
       for (pend = passwd_nonce; *pend && !spacep (pend); pend++)
@@ -2041,7 +2041,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
   opt_no_ask = has_option (line, "--no-ask");
   if (has_option_name (line, "--repeat"))
     {
-      p = option_value (line, "--repeat");
+      p = (char *) option_value (line, "--repeat");
       if (p)
        opt_repeat = atoi (p);
       else
@@ -2437,7 +2437,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
     return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
 
   opt_preset = has_option (line, "--preset");
-  cache_nonce = option_value (line, "--cache-nonce");
+  cache_nonce = (char *) option_value (line, "--cache-nonce");
   opt_verify = has_option (line, "--verify");
   if (cache_nonce)
     {
@@ -2454,7 +2454,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
         }
     }
 
-  passwd_nonce = option_value (line, "--passwd-nonce");
+  passwd_nonce = (char *) option_value (line, "--passwd-nonce");
   if (passwd_nonce)
     {
       for (pend = passwd_nonce; *pend && !spacep (pend); pend++)
@@ -3138,7 +3138,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
   if (mode1003)
     openpgp = 0;
 
-  cache_nonce = option_value (line, "--cache-nonce");
+  cache_nonce = (char *) option_value (line, "--cache-nonce");
   if (cache_nonce)
     {
       for (pend = cache_nonce; *pend && !spacep (pend); pend++)
diff --git a/common/server-help.c b/common/server-help.c
index e5a69e02d..812dcb932 100644
--- a/common/server-help.c
+++ b/common/server-help.c
@@ -164,10 +164,10 @@ get_option_value (char *line, const char *name, char 
**r_value)
 
 /* Return a pointer to the argument of the option with NAME.  If such
    an option is not given, NULL is returned. */
-char *
+const char *
 option_value (const char *line, const char *name)
 {
-  char *s;
+  const char *s;
   int n = strlen (name);
 
   s = strstr (line, name);
diff --git a/common/server-help.h b/common/server-help.h
index 9d2f4cfba..102b9cc9b 100644
--- a/common/server-help.h
+++ b/common/server-help.h
@@ -65,6 +65,6 @@ gpg_error_t get_option_value (char *line, const char *name, 
char **r_value);
 
 /* Return a pointer to the argument of the option with NAME.  If such
    an option is not given, NULL is returned. */
-char *option_value (const char *line, const char *name);
+const char *option_value (const char *line, const char *name);
 
 #endif /* GNUPG_COMMON_SERVER_HELP_H */
diff --git a/common/stringhelp.c b/common/stringhelp.c
index 8bbc68ab1..7095b5477 100644
--- a/common/stringhelp.c
+++ b/common/stringhelp.c
@@ -375,7 +375,7 @@ make_basename(const char *filepath, const char *inputpath)
 #ifdef __riscos__
     return riscos_make_basename(filepath, inputpath);
 #else
-    char *p;
+    const char *p;
 
     (void)inputpath; /* Only required for riscos.  */
 
@@ -406,7 +406,7 @@ make_dirname(const char *filepath)
 {
     char *dirname;
     int  dirname_length;
-    char *p;
+    const char *p;
 
     if ( !(p=strrchr(filepath, '/')) )
 #ifdef HAVE_DOSISH_SYSTEM
@@ -1422,7 +1422,7 @@ int
 split_fields (char *string, const char **array, int arraysize)
 {
   int n = 0;
-  const char *p;
+  char *p;
   char *pend;
 
   for (p = string; *p == ' '; p++)
@@ -1461,7 +1461,7 @@ int
 split_fields_colon (char *string, const char **array, int arraysize)
 {
   int n = 0;
-  const char *p;
+  char *p;
   char *pend;
 
   p = string;
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index c3cdd56a7..a92611365 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -2400,7 +2400,7 @@ handle_connections (assuan_fd_t listen_fd)
     {
       /* We need to watch the directory for the file because there
        * won't be an IN_DELETE_SELF for a socket file.  */
-      char *slash = strrchr (socket_name, '/');
+      char *slash = (char *) strrchr (socket_name, '/');
       log_assert (slash && slash[1]);
       *slash = 0;
       if (inotify_add_watch (my_inotify_fd, socket_name, IN_DELETE) == -1)
diff --git a/g10/misc.c b/g10/misc.c
index 58932ed7b..addce3e63 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1565,7 +1565,7 @@ argsplit(char *string)
 static size_t
 optlen(const char *s)
 {
-  char *end=strpbrk(s," =");
+  const char *end=strpbrk(s," =");
 
   if(end)
     return end-s;
diff --git a/g10/tofu.c b/g10/tofu.c
index 740ee6475..e00a1569c 100644
--- a/g10/tofu.c
+++ b/g10/tofu.c
@@ -1981,7 +1981,7 @@ ask_about_binding (ctrl_t ctrl,
         }
       else if (!response[1])
         {
-          char *choice = strchr (choices, *response);
+          const char *choice = strchr (choices, *response);
 
           if (choice)
             {
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index d1f9a59d3..0516af964 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -2514,7 +2514,7 @@ run_protect_tool (int argc, char **argv)
   (void)argv;
 #else
   const char *pgm;
-  char **av;
+  const char **av;
   int i;
 
   if (!opt.protect_tool_program || !*opt.protect_tool_program)
@@ -2529,7 +2529,7 @@ run_protect_tool (int argc, char **argv)
   for (i=1; argc; i++, argc--, argv++)
     av[i] = *argv;
   av[i] = NULL;
-  execv (pgm, av);
+  execv (pgm, (char * const *) av);
   log_error ("error executing '%s': %s\n", pgm, strerror (errno));
 #endif /*!HAVE_W32_SYSTEM*/
   gpgsm_exit (2);
diff --git a/tests/asschk.c b/tests/asschk.c
index b32f9361c..b1d1920ea 100644
--- a/tests/asschk.c
+++ b/tests/asschk.c
@@ -1037,7 +1037,7 @@ main (int argc, char **argv)
     {
       invocation_name = *argv++;
       argc--;
-      p = strrchr (invocation_name, '/');
+      p = (char *) strrchr (invocation_name, '/');
       if (p)
         invocation_name = p+1;
     }
diff --git a/tests/openpgp/fake-pinentry.c b/tests/openpgp/fake-pinentry.c
index b460a1da3..4462d1b9d 100644
--- a/tests/openpgp/fake-pinentry.c
+++ b/tests/openpgp/fake-pinentry.c
@@ -176,10 +176,10 @@ skip_options (const char *line)
 
 /* Return a pointer to the argument of the option with NAME.  If such
    an option is not given, NULL is returned. */
-char *
+const char *
 option_value (const char *line, const char *name)
 {
-  char *s;
+  const char *s;
   int n = strlen (name);
 
   s = strstr (line, name);
@@ -210,7 +210,7 @@ parse_pinentry_user_data (const char *args,
     fclose (log_stream);
   log_stream = NULL;
 
-  logfile = option_value (args, "--logfile");
+  logfile = (char *) option_value (args, "--logfile");
   if (logfile)
     {
       char *p = logfile, more;
@@ -228,7 +228,7 @@ parse_pinentry_user_data (const char *args,
         }
     }
 
-  passphrasefile = option_value (args, "--passphrasefile");
+  passphrasefile = (char *) option_value (args, "--passphrasefile");
   if (passphrasefile)
     {
       char *p = passphrasefile, more;
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index 9fcd5dfd5..40cfaf655 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -551,7 +551,7 @@ query_swdb (estream_t out, const char *name, const char 
*current_version)
         }
 
       /* Tokenize the name.  */
-      p = strrchr (fields[0], '_');
+      p = (char *) strrchr (fields[0], '_');
       if (!p)
         continue; /* Name w/o an underscore.  */
       *p++ = 0;
-- 
2.52.0


_______________________________________________
Gnupg-devel mailing list
[email protected]
https://lists.gnupg.org/mailman/listinfo/gnupg-devel

Reply via email to