Description: Fixed compiler errors and warnings from GCC 14.
 Get source building with GCC 14 and spread 'const' around to
 get rid of any compiler warnings.
Author: Petter Reinholdtsen <pere@debian.org>
Bug-Debian: https://bugs.debian.org/1074879
Forwarded: no
Last-Update: 2024-11-06
---
Index: checkpw-salsa/auto-int8.c
===================================================================
--- checkpw-salsa.orig/auto-int8.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/auto-int8.c	2024-11-06 23:56:16.686951373 +0000
@@ -7,10 +7,12 @@
 char buf1[256];
 substdio ss1 = SUBSTDIO_FDBUF(write,1,buf1,sizeof(buf1));
 
-void puts(s)
-char *s;
+int puts(s)
+const char *s;
 {
-  if (substdio_puts(&ss1,s) == -1) _exit(111);
+  int ret;
+  if ((ret=substdio_puts(&ss1,s)) == -1) _exit(111);
+  return ret;
 }
 
 void main(argc,argv)
Index: checkpw-salsa/auto-str.c
===================================================================
--- checkpw-salsa.orig/auto-str.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/auto-str.c	2024-11-06 23:56:16.686951373 +0000
@@ -3,14 +3,17 @@
 #include "exit.h"
 
 char bspace[256];
+
 buffer b = BUFFER_INIT(write,1,bspace,sizeof bspace);
 
-void puts(char *s)
+int puts(char *s)
 {
-  if (buffer_puts(&b,s) == -1) _exit(111);
+  int ret;
+  if ((ret=buffer_puts(&b,s)) == -1) _exit(111);
+  return ret;
 }
 
-main(int argc,char **argv)
+int main(int argc,char **argv)
 {
   char *name;
   char *value;
Index: checkpw-salsa/buffer.c
===================================================================
--- checkpw-salsa.orig/buffer.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/buffer.c	2024-11-06 23:56:16.686951373 +0000
@@ -1,6 +1,6 @@
 #include "buffer.h"
 
-void buffer_init(buffer *s,int (*op)(),int fd,char *buf,unsigned int len)
+void buffer_init(buffer *s,ssize_t (*op)(),int fd,char *buf,unsigned int len)
 {
   s->x = buf;
   s->fd = fd;
Index: checkpw-salsa/buffer.h
===================================================================
--- checkpw-salsa.orig/buffer.h	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/buffer.h	2024-11-07 00:01:37.449932377 +0000
@@ -1,25 +1,27 @@
 #ifndef BUFFER_H
 #define BUFFER_H
 
+#include <sys/types.h>
+
 typedef struct buffer {
   char *x;
   unsigned int p;
   unsigned int n;
   int fd;
-  int (*op)();
+  ssize_t (*op)();
 } buffer;
 
 #define BUFFER_INIT(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
 #define BUFFER_INSIZE 8192
 #define BUFFER_OUTSIZE 8192
 
-extern void buffer_init(buffer *,int (*)(),int,char *,unsigned int);
+extern void buffer_init(buffer *,ssize_t (*)(),int,char *,unsigned int);
 
 extern int buffer_flush(buffer *);
-extern int buffer_put(buffer *,char *,unsigned int);
+extern int buffer_put(buffer *,const char *,unsigned int);
 extern int buffer_putalign(buffer *,char *,unsigned int);
 extern int buffer_putflush(buffer *,char *,unsigned int);
-extern int buffer_puts(buffer *,char *);
+extern int buffer_puts(buffer *,const char *);
 extern int buffer_putsalign(buffer *,char *);
 extern int buffer_putsflush(buffer *,char *);
 
Index: checkpw-salsa/buffer_get.c
===================================================================
--- checkpw-salsa.orig/buffer_get.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/buffer_get.c	2024-11-06 23:56:16.686951373 +0000
@@ -2,7 +2,7 @@
 #include "byte.h"
 #include "error.h"
 
-static int oneread(int (*op)(),int fd,char *buf,unsigned int len)
+static int oneread(ssize_t (*op)(),int fd,char *buf,unsigned int len)
 {
   int r;
 
Index: checkpw-salsa/buffer_put.c
===================================================================
--- checkpw-salsa.orig/buffer_put.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/buffer_put.c	2024-11-07 00:02:34.030461718 +0000
@@ -3,7 +3,7 @@
 #include "byte.h"
 #include "error.h"
 
-static int allwrite(int (*op)(),int fd,char *buf,unsigned int len)
+static int allwrite(ssize_t (*op)(),int fd,const char *buf,unsigned int len)
 {
   int w;
 
@@ -44,7 +44,7 @@
   return 0;
 }
 
-int buffer_put(buffer *s,char *buf,unsigned int len)
+int buffer_put(buffer *s,const char *buf,unsigned int len)
 {
   unsigned int n;
  
@@ -77,7 +77,7 @@
   return buffer_putalign(s,buf,str_len(buf));
 }
 
-int buffer_puts(buffer *s,char *buf)
+int buffer_puts(buffer *s,const char *buf)
 {
   return buffer_put(s,buf,str_len(buf));
 }
Index: checkpw-salsa/checkapoppw.c
===================================================================
--- checkpw-salsa.orig/checkapoppw.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/checkapoppw.c	2024-11-06 23:56:16.690951410 +0000
@@ -39,7 +39,7 @@
   _exit(x);
 }
 
-main(int argc,char **argv)
+int main(int argc,char **argv)
 {
   char *login;
   char *dash;
Index: checkpw-salsa/checkpw.c
===================================================================
--- checkpw-salsa.orig/checkpw.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/checkpw.c	2024-11-06 23:56:16.690951410 +0000
@@ -34,7 +34,7 @@
   _exit(x);
 }
 
-main(int argc,char **argv)
+int main(int argc,char **argv)
 {
   char *login;
   char *dash;
Index: checkpw-salsa/install.c
===================================================================
--- checkpw-salsa.orig/install.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/install.c	2024-11-06 23:57:57.371883359 +0000
@@ -51,7 +51,7 @@
 buffer ssout;
 
 void c(home,subdir,file,uid,gid,mode)
-char *home;
+const char *home;
 char *subdir;
 char *file;
 int uid;
@@ -138,7 +138,7 @@
     strerr_die6sys(111,FATAL,"unable to chmod .../",subdir,"/",file,": ");
 }
 
-main()
+int main()
 {
   fdsourcedir = open_read(".");
   if (fdsourcedir == -1)
Index: checkpw-salsa/instcheck.c
===================================================================
--- checkpw-salsa.orig/instcheck.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/instcheck.c	2024-11-06 23:58:04.815952403 +0000
@@ -74,7 +74,7 @@
 }
 
 void c(home,subdir,file,uid,gid,mode)
-char *home;
+const char *home;
 char *subdir;
 char *file;
 int uid;
@@ -101,7 +101,7 @@
   perm("",home,"/",file,S_IFREG,uid,gid,mode);
 }
 
-main()
+int main()
 {
   hier();
   _exit(0);
Index: checkpw-salsa/open.h
===================================================================
--- checkpw-salsa.orig/open.h	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/open.h	2024-11-06 23:56:16.690951410 +0000
@@ -1,10 +1,10 @@
 #ifndef OPEN_H
 #define OPEN_H
 
-extern int open_read(char *);
-extern int open_excl(char *);
-extern int open_append(char *);
-extern int open_trunc(char *);
-extern int open_write(char *);
+extern int open_read(const char *);
+extern int open_excl(const char *);
+extern int open_append(const char *);
+extern int open_trunc(const char *);
+extern int open_write(const char *);
 
 #endif
Index: checkpw-salsa/open_read.c
===================================================================
--- checkpw-salsa.orig/open_read.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/open_read.c	2024-11-06 23:56:16.690951410 +0000
@@ -2,5 +2,5 @@
 #include <fcntl.h>
 #include "open.h"
 
-int open_read(char *fn)
+int open_read(const char *fn)
 { return open(fn,O_RDONLY | O_NDELAY); }
Index: checkpw-salsa/open_trunc.c
===================================================================
--- checkpw-salsa.orig/open_trunc.c	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/open_trunc.c	2024-11-06 23:56:16.690951410 +0000
@@ -2,5 +2,5 @@
 #include <fcntl.h>
 #include "open.h"
 
-int open_trunc(char *fn)
+int open_trunc(const char *fn)
 { return open(fn,O_WRONLY | O_NDELAY | O_TRUNC | O_CREAT,0644); }
Index: checkpw-salsa/substdio.h
===================================================================
--- checkpw-salsa.orig/substdio.h	2024-11-06 23:56:16.694951447 +0000
+++ checkpw-salsa/substdio.h	2024-11-06 23:56:16.690951410 +0000
@@ -1,12 +1,14 @@
 #ifndef SUBSTDIO_H
 #define SUBSTDIO_H
 
+#include <sys/types.h>
+
 typedef struct substdio {
   char *x;
   int p;
   int n;
   int fd;
-  int (*op)();
+  ssize_t (*op)();
 } substdio;
 
 #define SUBSTDIO_FDBUF(op,fd,buf,len) { (buf), 0, (len), (fd), (op) }
--- checkpw-1.02.orig/hier.c
+++ checkpw-1.02/hier.c
@@ -1,6 +1,6 @@
 #include "auto_home.h"
 
-extern void c(char *home, char *subdir, char *file, int uid, int gid, int mode);
+extern void c(const char *home, char *subdir, char *file, int uid, int gid, int mode);
 
 void hier()
 {
--- checkpw-1.02.orig/str.h
+++ checkpw-1.02/str.h
@@ -5,7 +5,7 @@
 extern unsigned int str_copy(char *,char *);
 extern int str_diff(char *,char *);
 extern int str_diffn(char *,char *,unsigned int);
-extern unsigned int str_len(char *);
+extern unsigned int str_len(const char *);
 extern unsigned int str_chr(char *,int);
 extern unsigned int str_rchr(char *,int);
 extern int str_start(char *,char *);
--- checkpw-1.02.orig/str_len.c
+++ checkpw-1.02/str_len.c
@@ -1,8 +1,8 @@
 #include "str.h"
 
-unsigned int str_len(char *s)
+unsigned int str_len(const char *s)
 {
-  register char *t;
+  register const char *t;
 
   t = s;
   for (;;) {
--- checkpw-1.02.orig/strerr.h
+++ checkpw-1.02/strerr.h
@@ -12,8 +12,8 @@ extern struct strerr strerr_sys;
 extern void strerr_sysinit(void);
 
 extern char *strerr(struct strerr *);
-extern void strerr_warn(char *,char *,char *,char *,char *,char *,struct strerr *);
-extern void strerr_die(int,char *,char *,char *,char *,char *,char *,struct strerr *);
+extern void strerr_warn(char *,char *,const char *,char *,char *,char *,struct strerr *);
+extern void strerr_die(int,char *,char *,const char *,char *,char *,char *,struct strerr *);
 
 #define STRERR(r,se,a) \
 { se.who = 0; se.x = a; se.y = 0; se.z = 0; return r; }
--- checkpw-1.02.orig/strerr_die.c
+++ checkpw-1.02/strerr_die.c
@@ -2,7 +2,7 @@
 #include "exit.h"
 #include "strerr.h"
 
-void strerr_warn(char *x1,char *x2,char *x3,char *x4,char *x5,char *x6,struct strerr *se)
+void strerr_warn(char *x1,char *x2,const char *x3,char *x4,char *x5,char *x6,struct strerr *se)
 {
   strerr_sysinit();
  
@@ -24,7 +24,7 @@ void strerr_warn(char *x1,char *x2,char
   buffer_flush(buffer_2);
 }
 
-void strerr_die(int e,char *x1,char *x2,char *x3,char *x4,char *x5,char *x6,struct strerr *se)
+void strerr_die(int e,char *x1,char *x2,const char *x3,char *x4,char *x5,char *x6,struct strerr *se)
 {
   strerr_warn(x1,x2,x3,x4,x5,x6,se);
   _exit(e);
