# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574790428 21600
#      Tue Nov 26 11:47:08 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID bdaf3416fb1b1010546d8a52b75dc764ca8a80a5
# Parent  6001387b32501dd5c76c969467cf4f7a655e9dcf
Change getgroups arg 2 type in chkshsgr.c to gid_t

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile chkshsgr.c
  chkshsgr.c: In function ‘main’:
  chkshsgr.c:10:3: warning: passing argument 2 of ‘getgroups’ from incompatible pointer type [enabled by default]
     if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
     ^
  In file included from chkshsgr.c:3:0:
  /usr/include/unistd.h:711:12: note: expected ‘__gid_t *’ but argument is of type ‘short int *’
   extern int getgroups (int __size, __gid_t __list[]) __THROW __wur;
              ^

diff -r 6001387b3250 -r bdaf3416fb1b external/src/chkshsgr.c
--- a/external/src/chkshsgr.c	Tue Nov 26 10:48:03 2019 -0600
+++ b/external/src/chkshsgr.c	Tue Nov 26 11:47:08 2019 -0600
@@ -4,7 +4,7 @@
 
 int main()
 {
-  short x[4];
+  gid_t x[4];
 
   x[0] = x[1] = 0;
   if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574791174 21600
#      Tue Nov 26 11:59:34 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID a12ee55203125f8ef926dbe72e66a1bd45235619
# Parent  bdaf3416fb1b1010546d8a52b75dc764ca8a80a5
Include grp.h in chkshsgr.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile chkshsgr.c
  chkshsgr.c: In function ‘main’:
  chkshsgr.c:10:3: warning: implicit declaration of function ‘setgroups’ [-Wimplicit-function-declaration]
     if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
     ^

diff -r bdaf3416fb1b -r a12ee5520312 external/src/chkshsgr.c
--- a/external/src/chkshsgr.c	Tue Nov 26 11:47:08 2019 -0600
+++ b/external/src/chkshsgr.c	Tue Nov 26 11:59:34 2019 -0600
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <grp.h>
 #include <unistd.h>
 
 int main()
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574791401 21600
#      Tue Nov 26 12:03:21 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID b0034c0716a2f8496d17d5c4a1d8d77193b3594f
# Parent  a12ee55203125f8ef926dbe72e66a1bd45235619
Include grp.h in chpst.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile chpst.c
  chpst.c: In function ‘suidgid’:
  chpst.c:80:3: warning: implicit declaration of function ‘setgroups’ [-Wimplicit-function-declaration]
     if (setgroups(ugid.gids, ugid.gid) == -1) fatal("unable to setgroups");
     ^

diff -r a12ee5520312 -r b0034c0716a2 external/src/chpst.c
--- a/external/src/chpst.c	Tue Nov 26 11:59:34 2019 -0600
+++ b/external/src/chpst.c	Tue Nov 26 12:03:21 2019 -0600
@@ -2,6 +2,7 @@
 #include <time.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <grp.h>
 #include <unistd.h>
 #include "sgetopt.h"
 #include "error.h"
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574791671 21600
#      Tue Nov 26 12:07:51 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 396b02da6d0e56256ac5c1cf00ed0af690dbd8f1
# Parent  b0034c0716a2f8496d17d5c4a1d8d77193b3594f
Avoid op sequence order ambiguity in chpst.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile chpst.c
  chpst.c: In function ‘main’:
  chpst.c:312:33: warning: operation on ‘subgetoptarg’ may be undefined [-Wsequence-point]
             if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
                                   ^

diff -r b0034c0716a2 -r 396b02da6d0e external/src/chpst.c
--- a/external/src/chpst.c	Tue Nov 26 12:03:21 2019 -0600
+++ b/external/src/chpst.c	Tue Nov 26 12:07:51 2019 -0600
@@ -309,7 +309,8 @@
     case 'n':
       switch (*optarg) {
         case '-':
-          if (optarg[scan_ulong(++optarg, &ul)]) usage(); nicelvl =ul;
+          ++optarg;
+          if (optarg[scan_ulong(optarg, &ul)]) usage(); nicelvl =ul;
           nicelvl *=-1;
           break;
         case '+': ++optarg;
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574792032 21600
#      Tue Nov 26 12:13:52 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 81ee1629db40cb6c87fa327fadcb7fcf1aeb4c53
# Parent  396b02da6d0e56256ac5c1cf00ed0af690dbd8f1
Include unistd.h in compile pathexec_run.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile pathexec_run.c
  pathexec_run.c: In function ‘pathexec_run’:
  pathexec_run.c:18:5: warning: implicit declaration of function ‘execve’ [-Wimplicit-function-declaration]
       execve(file,argv,envp);
       ^

diff -r 396b02da6d0e -r 81ee1629db40 external/src/pathexec_run.c
--- a/external/src/pathexec_run.c	Tue Nov 26 12:07:51 2019 -0600
+++ b/external/src/pathexec_run.c	Tue Nov 26 12:13:52 2019 -0600
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <unistd.h>
 #include "error.h"
 #include "stralloc.h"
 #include "str.h"
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574805376 21600
#      Tue Nov 26 15:56:16 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID e19a22494c69e30e3cd384ae6780f4667a67e449
# Parent  81ee1629db40cb6c87fa327fadcb7fcf1aeb4c53
Cast execve argv arg in pathexec_run.c

This change eliminates the following GCC 4.8.5 warnings on RHEL 7.7:

  ./compile pathexec_run.c
  pathexec_run.c: In function ‘pathexec_run’:
  pathexec_run.c:19:5: warning: passing argument 2 of ‘execve’ from incompatible pointer type [enabled by default]
       execve(file,argv,envp);
       ^
  In file included from pathexec_run.c:3:0:
  /usr/include/unistd.h:551:12: note: expected ‘char * const*’ but argument is of type ‘const char * const*’
   extern int execve (const char *__path, char *const __argv[],
              ^
  pathexec_run.c:36:5: warning: passing argument 2 of ‘execve’ from incompatible pointer type [enabled by default]
       execve(tmp.s,argv,envp);
       ^
  In file included from pathexec_run.c:3:0:
  /usr/include/unistd.h:551:12: note: expected ‘char * const*’ but argument is of type ‘const char * const*’
   extern int execve (const char *__path, char *const __argv[],
              ^

diff -r 81ee1629db40 -r e19a22494c69 external/src/pathexec_run.c
--- a/external/src/pathexec_run.c	Tue Nov 26 12:13:52 2019 -0600
+++ b/external/src/pathexec_run.c	Tue Nov 26 15:56:16 2019 -0600
@@ -16,7 +16,7 @@
   int savederrno;
 
   if (file[str_chr(file,'/')]) {
-    execve(file,argv,envp);
+    execve(file,(char * const *)argv,envp);
     return;
   }
 
@@ -33,7 +33,7 @@
     if (!stralloc_cats(&tmp,file)) return;
     if (!stralloc_0(&tmp)) return;
 
-    execve(tmp.s,argv,envp);
+    execve(tmp.s,(char * const *)argv,envp);
     if (errno != error_noent) {
       savederrno = errno;
       if ((errno != error_acces) && (errno != error_perm) && (errno != error_isdir)) return;
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574807490 21600
#      Tue Nov 26 16:31:30 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID eea70f9d621273abdca6d0bd27f8729ec4f175ab
# Parent  e19a22494c69e30e3cd384ae6780f4667a67e449
Cast execve envp arg in pathexec_run.c

This change eliminates the following GCC 4.8.5 warnings on RHEL 7.7:

  ./compile pathexec_run.c
  pathexec_run.c: In function ‘pathexec_run’:
  pathexec_run.c:19:5: warning: passing argument 3 of ‘execve’ from incompatible pointer type [enabled by default]
       execve(file,(char * const *)argv,envp);
       ^
  In file included from pathexec_run.c:3:0:
  /usr/include/unistd.h:551:12: note: expected ‘char * const*’ but argument is of type ‘const char * const*’
   extern int execve (const char *__path, char *const __argv[],
              ^
  pathexec_run.c:36:5: warning: passing argument 3 of ‘execve’ from incompatible pointer type [enabled by default]
       execve(tmp.s,(char * const *)argv,envp);
       ^
  In file included from pathexec_run.c:3:0:
  /usr/include/unistd.h:551:12: note: expected ‘char * const*’ but argument is of type ‘const char * const*’
   extern int execve (const char *__path, char *const __argv[],
              ^

diff -r e19a22494c69 -r eea70f9d6212 external/src/pathexec_run.c
--- a/external/src/pathexec_run.c	Tue Nov 26 15:56:16 2019 -0600
+++ b/external/src/pathexec_run.c	Tue Nov 26 16:31:30 2019 -0600
@@ -16,7 +16,7 @@
   int savederrno;
 
   if (file[str_chr(file,'/')]) {
-    execve(file,(char * const *)argv,envp);
+    execve(file,(char * const *)argv,(char * const *)envp);
     return;
   }
 
@@ -33,7 +33,7 @@
     if (!stralloc_cats(&tmp,file)) return;
     if (!stralloc_0(&tmp)) return;
 
-    execve(tmp.s,(char * const *)argv,envp);
+    execve(tmp.s,(char * const *)argv,(char * const *)envp);
     if (errno != error_noent) {
       savederrno = errno;
       if ((errno != error_acces) && (errno != error_perm) && (errno != error_isdir)) return;
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574808043 21600
#      Tue Nov 26 16:40:43 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 6d61f595fb22a0ee4bdb09d727c300828fc76a3e
# Parent  eea70f9d621273abdca6d0bd27f8729ec4f175ab
Include grp.h in prot.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile prot.c
  prot.c: In function ‘prot_gid’:
  prot.c:13:3: warning: implicit declaration of function ‘setgroups’ [-Wimplicit-function-declaration]
     if (setgroups(1,&gid) == -1) return -1;
     ^

diff -r eea70f9d6212 -r 6d61f595fb22 external/src/prot.c
--- a/external/src/prot.c	Tue Nov 26 16:31:30 2019 -0600
+++ b/external/src/prot.c	Tue Nov 26 16:40:43 2019 -0600
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <grp.h>
 #include "hasshsgr.h"
 #include "prot.h"
 
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574874991 21600
#      Wed Nov 27 11:16:31 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 3714c914f8803b8235329a5438ce83c5241a0070
# Parent  6d61f595fb22a0ee4bdb09d727c300828fc76a3e
Change setgroups arg 2 type in prot.c to gid_t

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile prot.c
  prot.c: In function ‘prot_gid’:
  prot.c:14:3: warning: pointer targets in passing argument 2 of ‘setgroups’ differ in signedness [-Wpointer-sign]
     if (setgroups(1,&gid) == -1) return -1;
     ^
  In file included from prot.c:3:0:
  /usr/include/grp.h:181:12: note: expected ‘const __gid_t *’ but argument is of type ‘int *’
   extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
              ^

diff -r 6d61f595fb22 -r 3714c914f880 external/src/prot.c
--- a/external/src/prot.c	Tue Nov 26 16:40:43 2019 -0600
+++ b/external/src/prot.c	Wed Nov 27 11:16:31 2019 -0600
@@ -7,11 +7,13 @@
 int prot_gid(int gid)
 {
 #ifdef HASSHORTSETGROUPS
-  short x[2];
-  x[0] = gid; x[1] = 73; /* catch errors */
+  gid_t x[2];
+  x[0] = (gid_t)gid; x[1] = 73; /* catch errors */
   if (setgroups(1,x) == -1) return -1;
 #else
-  if (setgroups(1,&gid) == -1) return -1;
+  gid_t x;
+  x = (gid_t)gid;
+  if (setgroups(1,&x) == -1) return -1;
 #endif
   return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
 }
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574879582 21600
#      Wed Nov 27 12:33:02 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID abd85fc8cbb6632f78d8973a673df11bda56a82a
# Parent  3714c914f8803b8235329a5438ce83c5241a0070
Include unistd.h in proto.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile prot.c
  prot.c: In function ‘prot_gid’:
  prot.c:18:3: warning: implicit declaration of function ‘setgid’ [-Wimplicit-function-declaration]
     return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
     ^

diff -r 3714c914f880 -r abd85fc8cbb6 external/src/prot.c
--- a/external/src/prot.c	Wed Nov 27 11:16:31 2019 -0600
+++ b/external/src/prot.c	Wed Nov 27 12:33:02 2019 -0600
@@ -1,6 +1,7 @@
 /* Public domain. */
 
 #include <grp.h>
+#include <unistd.h>
 #include "hasshsgr.h"
 #include "prot.h"
 
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574880136 21600
#      Wed Nov 27 12:42:16 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 2f9db40fe5a069b5c9e7498a45e0ecff3f0ad518
# Parent  abd85fc8cbb6632f78d8973a673df11bda56a82a
Use gid_t/uid_t types in setgid/setuid in proto.c

GCC 4.8.5 on RHEL 7.7 did not emit warnings about these type
differences, but these changes are consistent with the type changes that
were necessary in proto.c to quash other warnings.

diff -r abd85fc8cbb6 -r 2f9db40fe5a0 external/src/prot.c
--- a/external/src/prot.c	Wed Nov 27 12:33:02 2019 -0600
+++ b/external/src/prot.c	Wed Nov 27 12:42:16 2019 -0600
@@ -16,10 +16,10 @@
   x = (gid_t)gid;
   if (setgroups(1,&x) == -1) return -1;
 #endif
-  return setgid(gid); /* _should_ be redundant, but on some systems it isn't */
+  return setgid((gid_t)gid); /* _should_ be redundant, but on some systems it isn't */
 }
 
 int prot_uid(int uid)
 {
-  return setuid(uid);
+  return setuid((uid_t)uid);
 }
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574880328 21600
#      Wed Nov 27 12:45:28 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 6fb94ec18d5277e100432f5780f6f9cd5902bb2c
# Parent  2f9db40fe5a069b5c9e7498a45e0ecff3f0ad518
Include unistd.h in seek_set.c

This change eliminates the following GCC 4.8.5 warning on RHEL 7.7:

  ./compile seek_set.c
  seek_set.c: In function ‘seek_set’:
  seek_set.c:9:1: warning: implicit declaration of function ‘lseek’ [-Wimplicit-function-declaration]
   { if (lseek(fd,(off_t) pos,SET) == -1) return -1; return 0; }
   ^

diff -r 2f9db40fe5a0 -r 6fb94ec18d52 external/src/seek_set.c
--- a/external/src/seek_set.c	Wed Nov 27 12:42:16 2019 -0600
+++ b/external/src/seek_set.c	Wed Nov 27 12:45:28 2019 -0600
@@ -1,6 +1,7 @@
 /* Public domain. */
 
 #include <sys/types.h>
+#include <unistd.h>
 #include "seek.h"
 
 #define SET 0 /* sigh */
# HG changeset patch
# User J. Lewis Muir <jlmuir@imca-cat.org>
# Date 1574881770 21600
#      Wed Nov 27 13:09:30 2019 -0600
# Branch 2.1.2_compiler-warning-fixes
# Node ID 942ba9fb2086c5157b70fb62e34b7e6c393dc127
# Parent  6fb94ec18d5277e100432f5780f6f9cd5902bb2c
Use time_t type in {u,w}tmp_logout in utmpset.c

This change eliminates the following GCC 4.8.5 warnings on RHEL 7.7:

  ./compile utmpset.c
  utmpset.c: In function ‘utmp_logout’:
  utmpset.c:38:5: warning: passing argument 1 of ‘time’ from incompatible pointer type [enabled by default]
       if (time(&ut.ut_time) == -1) break;
       ^
  In file included from utmpset.c:2:0:
  /usr/include/time.h:192:15: note: expected ‘time_t *’ but argument is of type ‘int32_t *’
   extern time_t time (time_t *__timer) __THROW;
                 ^
  utmpset.c: In function ‘wtmp_logout’:
  utmpset.c:68:3: warning: passing argument 1 of ‘time’ from incompatible pointer type [enabled by default]
     if (time(&ut.ut_time) == -1) {
     ^
  In file included from utmpset.c:2:0:
  /usr/include/time.h:192:15: note: expected ‘time_t *’ but argument is of type ‘int32_t *’
   extern time_t time (time_t *__timer) __THROW;
                 ^

diff -r 6fb94ec18d52 -r 942ba9fb2086 external/src/utmpset.c
--- a/external/src/utmpset.c	Wed Nov 27 12:45:28 2019 -0600
+++ b/external/src/utmpset.c	Wed Nov 27 13:09:30 2019 -0600
@@ -24,6 +24,7 @@
 int utmp_logout(const char *line) {
   int fd;
   uw_tmp ut;
+  time_t t;
   int ok =-1;
 
   if ((fd =open(UW_TMP_UFILE, O_RDWR, 0)) < 0)
@@ -35,7 +36,8 @@
     if (!ut.ut_name[0] || (str_diff(ut.ut_line, line) != 0)) continue;
     memset(ut.ut_name, 0, sizeof ut.ut_name);
     memset(ut.ut_host, 0, sizeof ut.ut_host);
-    if (time(&ut.ut_time) == -1) break;
+    if (time(&t) == (time_t)-1) break;
+    ut.ut_time = t;
 #ifdef DEAD_PROCESS
     ut.ut_type =DEAD_PROCESS;
 #endif
@@ -52,6 +54,7 @@
   int len;
   struct stat st;
   uw_tmp ut;
+  time_t t;
 
   if ((fd = open_append(UW_TMP_WFILE)) == -1)
     strerr_die4sys(111, FATAL, "unable to open ", UW_TMP_WFILE, ": ");
@@ -65,10 +68,11 @@
   memset(&ut, 0, sizeof(uw_tmp));
   if ((len =str_len(line)) > sizeof ut.ut_line) len =sizeof ut.ut_line -2;
   byte_copy(ut.ut_line, len, line);
-  if (time(&ut.ut_time) == -1) {
+  if (time(&t) == (time_t)-1) {
     close(fd);
     return(-1);
   }
+  ut.ut_time = t;
 #ifdef DEAD_PROCESS
   ut.ut_type =DEAD_PROCESS;
 #endif

