Fix a whole bunch of warnings.

This commit is contained in:
David Given 2022-08-01 22:08:23 +02:00
parent 551f666028
commit 511c3e99ee
35 changed files with 103 additions and 93 deletions

View file

@ -37,6 +37,7 @@ extern struct tm* localtime(const time_t *_timer);
extern size_t strftime(char *_s, size_t _maxsize, extern size_t strftime(char *_s, size_t _maxsize,
const char *_format, const char *_format,
const struct tm *_timeptr); const struct tm *_timeptr);
extern void tzset(void);
/* Extensions not in the standard */ /* Extensions not in the standard */

View file

@ -23,5 +23,6 @@ extern struct tm *gmtime();
extern struct tm *localtime(); extern struct tm *localtime();
extern char *asctime(); extern char *asctime();
extern char *ctime(); extern char *ctime();
extern void tzset(void);
#endif /* _TIME_H */ #endif /* _TIME_H */

View file

@ -93,8 +93,7 @@ long di_off;
int firstreg; int firstreg;
int int
regscore(off, size, typ, score, totyp) regscore(long off, int size, int typ, int score, int totyp)
long off;
{ {
if (size != 4) return -1; if (size != 4) return -1;
score -= 1; score -= 1;
@ -137,9 +136,7 @@ f_regsave()
} }
void void
regsave(regstr, off, size) regsave(const char* regstr, long off, int size)
const char *regstr;
long off;
{ {
if (strcmp(regstr, "esi") == 0) { if (strcmp(regstr, "esi") == 0) {
if (! firstreg) firstreg = -1; if (! firstreg) firstreg = -1;

View file

@ -83,8 +83,7 @@ long di_off;
int firstreg; int firstreg;
int int
regscore(off, size, typ, score, totyp) regscore(long off, int size, int typ, int score, int totyp)
long off;
{ {
if (size != 2) return -1; if (size != 2) return -1;
score -= 1; score -= 1;
@ -133,9 +132,7 @@ f_regsave()
} }
void void
regsave(regstr, off, size) regsave(const char* regstr, long off, int size)
const char *regstr;
long off;
{ {
if (strcmp(regstr, "si") == 0) { if (strcmp(regstr, "si") == 0) {
if (! firstreg) firstreg = -1; if (! firstreg) firstreg = -1;

View file

@ -1,7 +1,6 @@
#include <em_abs.h> #include <em_abs.h>
char * char* _trpstr(int d)
_trpstr(d)
{ {
switch(d) switch(d)
{ {

View file

@ -60,8 +60,7 @@ con_mult(word sz) {
#include <con_float> #include <con_float>
int int
regscore(off,size,typ,score,totyp) regscore(long off, int size, int typ, int score, int totyp)
long off;
{ {
if (score == 0) return -1; if (score == 0) return -1;
switch(typ) { switch(typ) {
@ -183,9 +182,7 @@ f_regsave()
} }
void void
regsave(s,off,size) regsave(const char* s, long off, int size)
const char *s;
long off;
{ {
assert (regnr < 9); assert (regnr < 9);
regsav[regnr].rs_reg = s; regsav[regnr].rs_reg = s;

View file

@ -11,6 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -53,10 +54,10 @@ int outputfile_created;
FILE *output; FILE *output;
int rom_in_text; int rom_in_text;
static cv_int2(); static void cv_int2(int n);
static fatal(); static void fatal(const char* s, ...);
static emits(); static void emits(struct outsect*);
static emit_symtab(); static void emit_symtab(void);
char *program ; char *program ;
@ -71,9 +72,7 @@ char flag ;
#define LSECT BSSSG+1 #define LSECT BSSSG+1
#define NSECT LSECT+1 #define NSECT LSECT+1
main(argc, argv) int main(int argc, char* argv[])
int argc;
char *argv[];
{ {
register struct exec *e = &exec; register struct exec *e = &exec;
@ -189,7 +188,7 @@ main(argc, argv)
return 0; return 0;
} }
cv_int2(n) void cv_int2(int n)
{ {
putc(n, output); putc(n, output);
putc((n>>8), output); putc((n>>8), output);
@ -209,7 +208,7 @@ cv_long(l)
/* /*
* Transfer the emitted byted from one file to another. * Transfer the emitted byted from one file to another.
*/ */
emits(section) struct outsect *section ; { void emits(struct outsect* section) {
register long n ; register long n ;
register int blk; register int blk;
char buffer[BUFSIZ]; char buffer[BUFSIZ];
@ -234,7 +233,7 @@ emits(section) struct outsect *section ; {
} }
} }
emit_symtab() void emit_symtab(void)
{ {
struct outname ACK_name; /* symbol table entry in ACK format */ struct outname ACK_name; /* symbol table entry in ACK format */
struct nlist PDP_name; /* symbol table entry in PDP V7 format */ struct nlist PDP_name; /* symbol table entry in PDP V7 format */
@ -303,17 +302,21 @@ emit_symtab()
} }
/* VARARGS1 */ /* VARARGS1 */
fatal(s, a1, a2) void fatal(const char* s, ...)
char *s;
{ {
va_list ap;
fprintf(stderr,"%s: ",program) ; fprintf(stderr,"%s: ",program) ;
fprintf(stderr, s, a1, a2); va_start(ap, s);
vfprintf(stderr, s, ap);
va_end(ap);
if (outputfile_created) if (outputfile_created)
unlink(output_file); unlink(output_file);
exit(1); exit(1);
} }
rd_fatal() void rd_fatal(void)
{ {
fatal("read error\n"); fatal("read error\n");
} }

View file

@ -88,8 +88,11 @@ char *salloc(int size)
return(p); return(p);
} }
int compar(char **p1, char **p2) int compar(const void* pp1, const void* pp2)
{ {
const char **p1 = (const char**) pp1;
const char **p2 = (const char**) pp2;
assert(*p1 != *p2); assert(*p1 != *p2);
if (*p1 < *p2) if (*p1 < *p2)
return(-1); return(-1);

View file

@ -10,11 +10,11 @@
#include "types.h" #include "types.h"
string myalloc(int size); extern string myalloc(int size);
void myfree(void* p); extern void myfree(void* p);
void popstr(int nnstab); extern void popstr(int nnstab);
char *salloc(int size); extern char *salloc(int size);
int compar(char **p1, char **p2); extern int compar(const void* pp1, const void* pp2);
void garbage_collect(void); extern void garbage_collect(void);
#endif /* SALLOC_H_ */ #endif /* SALLOC_H_ */

View file

@ -6,7 +6,7 @@
static label_p label_list = (label_p)0; static label_p label_list = (label_p)0;
void add_label(num, height, flth) void add_label(int num, int height, int flth)
{ {
label_p lbl = (label_p)0; label_p lbl = (label_p)0;

View file

@ -12,7 +12,7 @@ static void extend(struct array* array)
struct array* newarray = realloc(array->item, newmax * sizeof(*newarray)); struct array* newarray = realloc(array->item, newmax * sizeof(*newarray));
array->max = newmax; array->max = newmax;
array->item = newarray; array->item = (void**) newarray;
} }
} }

View file

@ -5,7 +5,7 @@
#define INCR_SIZE 8 #define INCR_SIZE 8
static void append(void* mapp, char* key, void* value) static void append(void* mapp, const char* key, void* value)
{ {
struct smap* map = mapp; struct smap* map = mapp;
struct smap_node* node; struct smap_node* node;
@ -26,7 +26,7 @@ static void append(void* mapp, char* key, void* value)
} }
void smap_put(struct smap *mapp, char* key, void* value) void smap_put(struct smap *mapp, const char* key, void* value)
{ {
struct smap* map = mapp; struct smap* map = mapp;
int i; int i;
@ -71,7 +71,7 @@ void smap_free(struct smap *mapp, int free_key, int free_value)
free(mapp->item); free(mapp->item);
} }
void smap_add(struct smap *mapp, char* key, void* value) void smap_add(struct smap *mapp, const char* key, void* value)
{ {
struct smap* map = mapp; struct smap* map = mapp;
int i; int i;

View file

@ -36,11 +36,11 @@ extern void smap_init(struct smap *mapp);
* it does not already exist, otherwise replaces the * it does not already exist, otherwise replaces the
* value `value` associated with the existing `key`. * value `value` associated with the existing `key`.
*/ */
extern void smap_put(struct smap *mapp, char* key, void* value); extern void smap_put(struct smap *mapp, const char* key, void* value);
/** Adds a new item in a string map only if `key` does /** Adds a new item in a string map only if `key` does
* not already exist in the string map. * not already exist in the string map.
*/ */
extern void smap_add(struct smap *mapp, char* key, void* value); extern void smap_add(struct smap *mapp, const char* key, void* value);
/** Returns the value associated with the specified `key`, returns /** Returns the value associated with the specified `key`, returns
* NULL if `key` is not present in the string map. * NULL if `key` is not present in the string map.
* *

View file

@ -69,7 +69,7 @@ char* stringlist_get(struct stringlist *list, int index)
i++; i++;
} }
return i; return NULL;
} }

View file

@ -3,7 +3,7 @@
struct stringfragment struct stringfragment
{ {
const char* data; char* data;
struct stringfragment* next; struct stringfragment* next;
}; };

View file

@ -37,7 +37,7 @@ uint8_t cpm_parse_filename(FCB* fcb, const char* filename)
c = *filename++; c = *filename++;
if (isdigit(c)) if (isdigit(c))
{ {
user = strtol(filename-1, &filename, 10); user = strtol(filename-1, (char**) &filename, 10);
c = *filename++; c = *filename++;
} }
c = toupper(c); c = toupper(c);

View file

@ -116,4 +116,8 @@ struct tchars {
#define EXTA 14 #define EXTA 14
#define EXTB 15 #define EXTB 15
extern int ioctl(int fd, unsigned int request, ...);
extern int gtty(int fildes, struct sgttyb* argp);
extern int stty(int fildes, struct sgttyb* argp);
#endif /* _SGTTY_H */ #endif /* _SGTTY_H */

View file

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
#include <sgtty.h> #include <sgtty.h>
int
gtty(fildes,argp) int fildes ; struct sgttyb *argp ; { int gtty(int fildes, struct sgttyb* argp) {
return ioctl(fildes,TIOCGETP,argp) ; return ioctl(fildes,TIOCGETP,argp) ;
} }

View file

@ -1,5 +1,6 @@
/* $Id$ */ #include <sgtty.h>
isatty(f)
int isatty(int fd)
{ {
char buf[128]; char buf[128];
/* not a sgttyb struct; it might not be large enough; /* not a sgttyb struct; it might not be large enough;
@ -7,6 +8,6 @@ isatty(f)
where gtty is an ioctl(..., TCGETA, ...) where gtty is an ioctl(..., TCGETA, ...)
*/ */
if (gtty(f, buf) < 0) return 0; if (gtty(fd, (void*) buf) < 0) return 0;
return 1; return 1;
} }

View file

@ -1,14 +1,14 @@
/* $Id$ */ /* $Id$ */
#include <signal.h> #include <signal.h>
typedef void (*callvec)() ; extern void _setsig(int (*)(int));
static callvec vector[16] = { static sighandler_t vector[16] = {
SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL,
SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL, SIG_DFL
} ; } ;
static char mapvec[] = { static const char mapvec[] = {
0, /* EARRAY */ 0, /* EARRAY */
0, /* ERANGE */ 0, /* ERANGE */
0, /* ESET */ 0, /* ESET */
@ -42,16 +42,17 @@ static char mapvec[] = {
#define VECBASE 128 #define VECBASE 128
static firsttime = 1 ; static firsttime = 1 ;
static int catchtrp() ; extern int sigtrp(int mapval, int sig) ;
static int procesig() ; static int catchtrp(int trapno) ;
static int procesig(int signo) ;
callvec signal(sig,func) int sig ; callvec func ; { sighandler_t signal(int sig, sighandler_t func) {
register index, i ; register index, i ;
callvec prev ; sighandler_t prev ;
index= sig-1 ; index= sig-1 ;
if ( index<0 || index>=(sizeof vector/sizeof vector[0]) ) { if ( index<0 || index>=(sizeof vector/sizeof vector[0]) ) {
return (callvec) -1 ; return (sighandler_t) -1 ;
} }
if ( firsttime ) { if ( firsttime ) {
firsttime= 0 ; firsttime= 0 ;
@ -68,13 +69,13 @@ callvec signal(sig,func) int sig ; callvec func ; {
} else { } else {
mapval=VECBASE+sig; mapval=VECBASE+sig;
} }
if ( sigtrp(mapval,sig)== -1 ) return (callvec) -1; if ( sigtrp(mapval,sig)== -1 ) return (sighandler_t) -1;
} }
return prev ; return prev ;
} }
static int catchtrp(trapno) int trapno ; { static int catchtrp(int trapno) {
if ( trapno>VECBASE && if ( trapno>VECBASE &&
trapno<=VECBASE + (sizeof vector/sizeof vector[0]) ) { trapno<=VECBASE + (sizeof vector/sizeof vector[0]) ) {
return procesig(trapno-VECBASE) ; return procesig(trapno-VECBASE) ;
@ -86,9 +87,9 @@ static int catchtrp(trapno) int trapno ; {
return 0 ; /* Failed to handle the trap */ return 0 ; /* Failed to handle the trap */
} }
static int procesig(sig) int sig ; { static int procesig(int sig) {
register index ; register index ;
callvec trf ; sighandler_t trf ;
index= sig-1 ; index= sig-1 ;
trf= vector[index] ; trf= vector[index] ;

View file

@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
#include <sgtty.h> #include <sgtty.h>
int
stty(fildes,argp) int fildes ; struct sgttyb *argp ; { int stty(int fildes, struct sgttyb* argp) {
return ioctl(fildes,TIOCSETP,argp) ; return ioctl(fildes,TIOCSETP,argp) ;
} }

View file

@ -3,9 +3,9 @@
* return offset in file. * return offset in file.
*/ */
long lseek(); long lseek(int fd, int offset, int whence);
long tell(f) long tell(int fd)
{ {
return(lseek(f, 0L, 1)); return(lseek(fd, 0L, 1));
} }

View file

@ -1,8 +1,10 @@
/* $Id$ */ /* $Id$ */
#include <sys/types.h> #include <sys/types.h>
#include <sys/timeb.h> #include <sys/timeb.h>
time_t
time(timpt) time_t *timpt ; { extern void ftime(struct timeb* buf);
time_t time(time_t* timpt) {
struct timeb buf ; struct timeb buf ;
ftime(&buf) ; ftime(&buf) ;

View file

@ -1,3 +1,3 @@
_cleanup() void _cleanup(void)
{ {
} }

View file

@ -1,4 +1,7 @@
exit(n) extern void _cleanup(void);
extern void _exit(int n);
void exit(int n)
{ {
_cleanup(); _cleanup();
_exit(n); _exit(n);

View file

@ -1,7 +1,7 @@
int extern int ioctl(int fd, unsigned int request, ...);
gtty(fildes,argp) extern int _ioctl(int fd, int ioc, void* ptr);
int fildes ;
char *argp ; int gtty(int fildes, char* argp)
{ {
return ioctl(fildes,/*TIOCGETP*/(('t'<<8)|8),argp) ; return ioctl(fildes,/*TIOCGETP*/(('t'<<8)|8),argp) ;
} }

View file

@ -1,3 +1,5 @@
extern int ioctl(int fd, unsigned int request, ...);
int isatty(int fd) int isatty(int fd)
{ {
unsigned u; unsigned u;

View file

@ -1,7 +1,6 @@
int extern int _ioctl(int fd, int ioc, void* ptr);
stty(fildes,argp)
int fildes ; int stty(int fildes, char* argp)
char *argp;
{ {
return _ioctl(fildes,/*TIOCSETP*/(('t'<<8)|9),argp) ; return _ioctl(fildes,/*TIOCSETP*/(('t'<<8)|9),argp) ;
} }

View file

@ -4,6 +4,7 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include "em_spec.h" #include "em_spec.h"
#include "as_spec.h" #include "as_spec.h"

View file

@ -28,7 +28,7 @@ cons_t nicepr(int typ, addr_u *ap)
case CONST: case CONST:
return (ap->ad_i); return (ap->ad_i);
case LOCSYM: case LOCSYM:
return (int_cast ap->ad_lp); return (int_cast (intptr_t)ap->ad_lp);
case GLOOFF: case GLOOFF:
return (ap->ad_df.df_gp - mglobs); return (ap->ad_df.df_gp - mglobs);
case GLOSYM: case GLOSYM:
@ -135,7 +135,7 @@ void dump(int n)
if (lbp->l_defined != EMPTY) if (lbp->l_defined != EMPTY)
printf(" %8d%8d%8d%8d %-s\n", printf(" %8d%8d%8d%8d %-s\n",
lbp->l_hinum * LOCLABSIZE + i, lbp->l_hinum * LOCLABSIZE + i,
int_cast lbp, lbp->l_min, lbp->l_max, int_cast (intptr_t)lbp, lbp->l_min, lbp->l_max,
labstr[(unsigned char)lbp->l_defined]); labstr[(unsigned char)lbp->l_defined]);
} }
} }

View file

@ -83,7 +83,7 @@ lab_id instr_lab(short number)
/* symlookup */ /* symlookup */
STATIC unsigned hash(const char *string) { STATIC unsigned hash(const char *string) {
register char *p; register const char *p;
register unsigned i,sum; register unsigned i,sum;
for (sum=i=0,p=string;*p;i += 3) for (sum=i=0,p=string;*p;i += 3)

View file

@ -12,6 +12,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <em_spec.h> #include <em_spec.h>
#include "types.h" #include "types.h"
#include "def.h" #include "def.h"
@ -69,7 +70,7 @@ void OUTVERBOSE(const char *s, int n1, int n2)
void VA(short *a) { void VA(short *a) {
if (a == (short *) 0) error("VA: 0 argument"); if (a == (short *) 0) error("VA: 0 argument");
if ( ((unsigned) a & 01) == 01) { if ( ((intptr_t) a & 01) == 01) {
/* MACHINE DEPENDENT TEST */ /* MACHINE DEPENDENT TEST */
error("VA: odd argument"); error("VA: odd argument");
} }

View file

@ -100,7 +100,7 @@ int do_sigtrp(
} }
else if (tn >= 0 && tn <= 252) else if (tn >= 0 && tn <= 252)
{/* legal tn */ {/* legal tn */
if ((int) signal(sn, HndlEmSig) == -1) if (signal(sn, HndlEmSig) == SIG_ERR)
{ {
sig_map[sn] = old_tn; sig_map[sn] = old_tn;
return (-1); return (-1);

View file

@ -128,7 +128,7 @@ PRIVATE size buf_cnt[5]; /* Current sizes of the buffers */
PRIVATE char *buf[5]; /* Pointers to the buffers */ PRIVATE char *buf[5]; /* Pointers to the buffers */
PRIVATE check_buf(); PRIVATE check_buf();
PRIVATE int savestr(); PRIVATE int savestr(int n, ptr addr);
PRIVATE int vec(); PRIVATE int vec();
void moncall(void) void moncall(void)
@ -702,7 +702,7 @@ void moncall(void)
#ifdef SYS_V /* from system.h */ #ifdef SYS_V /* from system.h */
utimbuf.x = actime; utimbuf.x = actime;
utimbuf.y = modtime; utimbuf.y = modtime;
if (!savestr(0, dsp1) || utime(buf[0], &utimbuf) == -1) { if (!savestr(0, dsp1) || utime(buf[0], (struct utimbuf*) &utimbuf) == -1) {
#else /* SYS_V */ #else /* SYS_V */
utimbuf[0] = actime; utimbuf[0] = actime;
utimbuf[1] = modtime; utimbuf[1] = modtime;
@ -1037,9 +1037,7 @@ PRIVATE check_buf(n, sz)
} }
} }
PRIVATE int savestr(n, addr) PRIVATE int savestr(int n, ptr addr)
int n;
ptr addr;
{ {
register size len; register size len;
register char *cp, ch; register char *cp, ch;

View file

@ -123,7 +123,7 @@ void printpatterns(void) {
i++; i++;
} }
fputs("};\n", genc); fputs("};\n", genc);
fputs("int\ncheck_constraint(patno){\n\tint r;\n\tswitch(patno){\n",genc); fputs("int\ncheck_constraint(int patno){\n\tint r;\n\tswitch(patno){\n",genc);
p = pattable; p = pattable;
while (p < current) { while (p < current) {
if (p->p_constraint) { if (p->p_constraint) {