summary refs log tree commit diff
diff options
context:
space:
mode:
authorZ. Liu <zhixu.liu@gmail.com>2024-08-25 01:32:48 +0800
committerGerrit Pape <pape@smarden.org>2024-09-25 23:34:19 +0000
commit977abd9a06683c29d6888aecbf941386587c7c0e (patch)
tree34b3850a2edd4755bca1d2270685d7b0f43610df
parent4b32d478dedfdcf292f0aaddc29d91768fe1585f (diff)
downloadrunit-977abd9a06683c29d6888aecbf941386587c7c0e.tar.gz
runit-977abd9a06683c29d6888aecbf941386587c7c0e.tar.xz
runit-977abd9a06683c29d6888aecbf941386587c7c0e.zip
fix compilation warning(s): -Wincompatible-pointer-types-discards-qualifiers
found by using clang 18 with CFLAGS: -Wall

since gcc 14, certain warnings (including this one, gcc report as
-Wincompatible-pointer-types) are now errors, see
https://gcc.gnu.org/gcc-14/porting_to.html

link of debian's patches is: https://salsa.debian.org/debian/runit/-/tree/master/debian/patches
  0014-fix-implicit-declarations-incompatible-types-argv-ty.patch

pathexec_run.c: warning: passing 'const char *const *' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   19 |     execve(file,argv,envp);
      |                 ^~~~ ^~~~
   36 |     execve(tmp.s,argv,envp);
      |                  ^~~~ ^~~~
pathexec_env.c:67:21: warning: passing 'const char *const *' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   67 |   pathexec_run(file,argv,e);
      |                     ^~~~
pathexec_env.c:67:26: warning: passing 'const char **' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   67 |   pathexec_run(file,argv,e);
      |                          ^
runsvdir.c:74:25: warning: passing 'const char *[3]' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   74 |     pathexec_run(*prog, prog, (const char* const*)environ);
      |                         ^~~~
runsvdir.c:74:31: warning: passing 'const char *const *' to parameter of type 'char *const *' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers]
   74 |     pathexec_run(*prog, prog, (const char* const*)environ);
      |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r--src/chpst.c30
-rw-r--r--src/pathexec.h6
-rw-r--r--src/pathexec_env.c8
-rw-r--r--src/pathexec_run.c2
-rw-r--r--src/runsvdir.c4
-rw-r--r--src/sgetopt.c2
-rw-r--r--src/sgetopt.h2
-rw-r--r--src/subgetopt.c2
-rw-r--r--src/subgetopt.h2
-rw-r--r--src/sv.c2
-rw-r--r--src/svlogd.c4
-rw-r--r--src/utmpset.c2
12 files changed, 33 insertions, 33 deletions
diff --git a/src/chpst.c b/src/chpst.c
index 2055aeb..2e62285 100644
--- a/src/chpst.c
+++ b/src/chpst.c
@@ -41,7 +41,7 @@ void usage() { strerr_die4x(100, "usage: ", progname, USAGE_MAIN, "\n"); }
 
 char *set_user =0;
 char *env_user =0;
-const char *argv0 =0;
+char *argv0 =0;
 const char *env_dir =0;
 unsigned int verbose =0;
 unsigned int pgrp =0;
@@ -259,14 +259,14 @@ void slimit() {
 }
 
 /* argv[0] */
-void setuidgid(int, const char *const *);
-void envuidgid(int, const char *const *);
-void envdir(int, const char *const *);
-void pgrphack(int, const char *const *);
-void setlock(int, const char *const *);
-void softlimit(int, const char *const *);
-
-int main(int argc, const char **argv) {
+void setuidgid(int, char *const *);
+void envuidgid(int, char *const *);
+void envdir(int, char *const *);
+void pgrphack(int, char *const *);
+void setlock(int, char *const *);
+void softlimit(int, char *const *);
+
+int main(int argc, char **argv) {
   int opt;
   int i;
   unsigned long ul;
@@ -367,7 +367,7 @@ int main(int argc, const char **argv) {
 void setuidgid_usage() {
   strerr_die4x(100, "usage: ", progname, USAGE_SETUIDGID, "\n");
 }
-void setuidgid(int argc, const char *const *argv) {
+void setuidgid(int argc, char *const *argv) {
   const char *account;
 
   if (! (account =*++argv)) setuidgid_usage();
@@ -380,7 +380,7 @@ void setuidgid(int argc, const char *const *argv) {
 void envuidgid_usage() {
   strerr_die4x(100, "usage: ", progname, USAGE_ENVUIDGID, "\n");
 }
-void envuidgid(int argc, const char *const *argv) {
+void envuidgid(int argc, char *const *argv) {
   const char *account;
 
   if (! (account =*++argv)) envuidgid_usage();
@@ -393,7 +393,7 @@ void envuidgid(int argc, const char *const *argv) {
 void envdir_usage() {
   strerr_die4x(100, "usage: ", progname, USAGE_ENVDIR, "\n");
 }
-void envdir(int argc, const char *const *argv) {
+void envdir(int argc, char *const *argv) {
   const char *dir;
 
   if (! (dir =*++argv)) envdir_usage();
@@ -406,7 +406,7 @@ void envdir(int argc, const char *const *argv) {
 void pgrphack_usage() {
   strerr_die4x(100, "usage: ", progname, USAGE_PGRPHACK, "\n");
 }
-void pgrphack(int argc, const char *const *argv) {
+void pgrphack(int argc, char *const *argv) {
   if (! *++argv) pgrphack_usage();
   setsid();
   pathexec(argv);
@@ -416,7 +416,7 @@ void pgrphack(int argc, const char *const *argv) {
 void setlock_usage() {
   strerr_die4x(100, "usage: ", progname, USAGE_SETLOCK, "\n");
 }
-void setlock(int argc, const char *const *argv) {
+void setlock(int argc, char *const *argv) {
   int opt;
   unsigned int delay =0;
   unsigned int x =0;
@@ -450,7 +450,7 @@ void getlarg(long *l) {
   if (optarg[scan_ulong(optarg, &ul)]) usage();
   *l =ul;
 }
-void softlimit(int argc, const char *const *argv) {
+void softlimit(int argc, char *const *argv) {
   int opt;
   
   while ((opt =getopt(argc,argv,"a:c:d:f:l:m:o:p:r:s:t:")) != opteof)
diff --git a/src/pathexec.h b/src/pathexec.h
index d46ab17..46af3e0 100644
--- a/src/pathexec.h
+++ b/src/pathexec.h
@@ -3,9 +3,9 @@
 #ifndef PATHEXEC_H
 #define PATHEXEC_H
 
-extern void pathexec_run(const char *,const char * const *,const char * const *);
+extern void pathexec_run(const char *,char * const *,char * const *);
 extern int pathexec_env(const char *,const char *);
-extern void pathexec_env_run(const char *, const char * const *);
-extern void pathexec(const char * const *);
+extern void pathexec_env_run(const char *, char * const *);
+extern void pathexec(char * const *);
 
 #endif
diff --git a/src/pathexec_env.c b/src/pathexec_env.c
index 1305469..f873094 100644
--- a/src/pathexec_env.c
+++ b/src/pathexec_env.c
@@ -22,9 +22,9 @@ int pathexec_env(const char *s,const char *t)
   return stralloc_cat(&plus,&tmp);
 }
 
-void pathexec_env_run(const char *file, const char *const *argv)
+void pathexec_env_run(const char *file, char *const *argv)
 {
-  const char **e;
+  char **e;
   unsigned int elen;
   unsigned int i;
   unsigned int j;
@@ -40,7 +40,7 @@ void pathexec_env_run(const char *file, const char *const *argv)
     if (!plus.s[i])
       ++elen;
 
-  e = (const char **) alloc((elen + 1) * sizeof(char *));
+  e = (char **) alloc((elen + 1) * sizeof(char *));
   if (!e) return;
 
   elen = 0;
@@ -68,7 +68,7 @@ void pathexec_env_run(const char *file, const char *const *argv)
   alloc_free(e);
 }
 
-void pathexec(const char *const *argv)
+void pathexec(char *const *argv)
 {
   return pathexec_env_run(*argv, argv);
 }
diff --git a/src/pathexec_run.c b/src/pathexec_run.c
index 70ac7a8..8d159a8 100644
--- a/src/pathexec_run.c
+++ b/src/pathexec_run.c
@@ -9,7 +9,7 @@
 
 static stralloc tmp;
 
-void pathexec_run(const char *file,const char * const *argv,const char * const *envp)
+void pathexec_run(const char *file,char * const *argv,char * const *envp)
 {
   const char *path;
   unsigned int split;
diff --git a/src/runsvdir.c b/src/runsvdir.c
index ecebd0a..28cb044 100644
--- a/src/runsvdir.c
+++ b/src/runsvdir.c
@@ -63,7 +63,7 @@ void runsv(int no, char *name) {
   }
   if (pid == 0) {
     /* child */
-    const char *prog[3];
+    char *prog[3];
 
     prog[0] ="runsv";
     prog[1] =name;
@@ -71,7 +71,7 @@ void runsv(int no, char *name) {
     sig_uncatch(sig_hangup);
     sig_uncatch(sig_term);
     if (pgrp) setsid();
-    pathexec_run(*prog, prog, (const char* const*)environ);
+    pathexec_run(*prog, prog, (char* const*)environ);
     fatal("unable to start runsv ", name);
   }
   sv[no].pid =pid;
diff --git a/src/sgetopt.c b/src/sgetopt.c
index 8bb608f..778bca2 100644
--- a/src/sgetopt.c
+++ b/src/sgetopt.c
@@ -27,7 +27,7 @@ Documentation in sgetopt.3.
 int opterr = 1;
 const char *optprogname = 0;
 
-int getopt(int argc,const char *const *argv,const char *opts)
+int getopt(int argc,char *const *argv,const char *opts)
 {
   int c;
   const char *s;
diff --git a/src/sgetopt.h b/src/sgetopt.h
index bf8bce6..eb4cbf8 100644
--- a/src/sgetopt.h
+++ b/src/sgetopt.h
@@ -16,7 +16,7 @@
 
 #include "subgetopt.h"
 
-extern int sgetoptmine(int,const char *const *,const char *);
+extern int sgetoptmine(int,char *const *,const char *);
 extern int sgetopterr;
 extern const char *sgetoptprogname;
 
diff --git a/src/subgetopt.c b/src/subgetopt.c
index 85ace96..a23e0d7 100644
--- a/src/subgetopt.c
+++ b/src/subgetopt.c
@@ -16,7 +16,7 @@ const char *optarg = 0;
 int optproblem = 0;
 int optdone = SUBGETOPTDONE;
 
-int sgopt(int argc,const char *const *argv,const char *opts)
+int sgopt(int argc,char *const *argv,const char *opts)
 {
   int c;
   const char *s;
diff --git a/src/subgetopt.h b/src/subgetopt.h
index 41ad26a..5163148 100644
--- a/src/subgetopt.h
+++ b/src/subgetopt.h
@@ -15,7 +15,7 @@
 
 #define SUBGETOPTDONE -1
 
-extern int subgetopt(int,const char *const *,const char *);
+extern int subgetopt(int,char *const *,const char *);
 extern const char *subgetoptarg;
 extern int subgetoptind;
 extern int subgetoptpos;
diff --git a/src/sv.c b/src/sv.c
index 9003142..6ff9bc0 100644
--- a/src/sv.c
+++ b/src/sv.c
@@ -281,7 +281,7 @@ int main(int argc, char **argv) {
   lsb =(str_diff(progname, "sv"));
   if ((x =env_get("SVDIR"))) varservice =x;
   if ((x =env_get("SVWAIT"))) scan_ulong(x, &wait);
-  while ((i =getopt(argc, (const char* const*)argv, "w:vV")) != opteof) {
+  while ((i =getopt(argc, (char* const*)argv, "w:vV")) != opteof) {
     switch(i) {
     case 'w': scan_ulong(optarg, &wait);
     case 'v': verbose =1; break;
diff --git a/src/svlogd.c b/src/svlogd.c
index 5e55a90..033f5f6 100644
--- a/src/svlogd.c
+++ b/src/svlogd.c
@@ -52,7 +52,7 @@ unsigned long linelen;
 const char *replace ="";
 char repl =0;
 
-const char **fndir;
+char **fndir;
 int fdwdir;
 struct stat st;
 stralloc sa;
@@ -661,7 +661,7 @@ void logmatch(struct logdir *ld) {
     i +=byte_chr(&ld->inst.s[i], ld->inst.len -i, 0);
   }
 }
-int main(int argc, const char **argv) {
+int main(int argc, char **argv) {
   int i;
   int opt;
 
diff --git a/src/utmpset.c b/src/utmpset.c
index cb39909..05ccb10 100644
--- a/src/utmpset.c
+++ b/src/utmpset.c
@@ -81,7 +81,7 @@ int wtmp_logout(const char *line) {
   return(1);
 }
 
-int main (int argc, const char * const *argv, const char * const *envp) {
+int main (int argc, char * const *argv, const char * const *envp) {
   int opt;
   int wtmp =0;