From f8cbe044479c99861f60134270f70153dca3266c Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 22 Mar 2019 13:18:07 -0400 Subject: [PATCH 1/5] Include for lseek() This unbreaks my build in OpenBSD. The old `long lseek()` conflicts with `off_t lseek()` in OpenBSD headers, because long and off_t are different types. Commit b4df26e caused "system.h" to include some headers where OpenBSD declares lseek(). Manuals for lseek() say to #include . Do so to be portable to systems where other headers don't declare lseek(). --- modules/src/system/open.c | 2 +- modules/src/system/seek.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/src/system/open.c b/modules/src/system/open.c index cf24f3206..1433cea9f 100644 --- a/modules/src/system/open.c +++ b/modules/src/system/open.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include "system.h" extern File *_get_entry(); @@ -16,7 +17,6 @@ sys_open(path, flag, filep) { register int fd; register File *fp; - long lseek(); if ((fp = _get_entry()) == (File *)0) return 0; diff --git a/modules/src/system/seek.c b/modules/src/system/seek.c index e4d1f8580..97749ae12 100644 --- a/modules/src/system/seek.c +++ b/modules/src/system/seek.c @@ -4,10 +4,9 @@ */ /* $Id$ */ +#include #include "system.h" -long lseek(); - int sys_seek(fp, off, whence, poff) File *fp; From dd328215d8f557a25806409e399742c5fa78a34e Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 22 Mar 2019 14:09:50 -0400 Subject: [PATCH 2/5] Use %zu to print size_t count This silences a compiler warning. --- util/cmisc/objectify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cmisc/objectify.c b/util/cmisc/objectify.c index 090956131..b8683f1dc 100644 --- a/util/cmisc/objectify.c +++ b/util/cmisc/objectify.c @@ -26,7 +26,7 @@ int main(int argc, const char* argv[]) count++; } printf("\n};\n"); - printf("const size_t %s_len = %d;\n", argv[1], count); + printf("const size_t %s_len = %zu;\n", argv[1], count); return 0; } From cdbff0dd1c5fb3ee139fe2a7195464b34f4c1a97 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 22 Mar 2019 14:19:02 -0400 Subject: [PATCH 3/5] Include or This silences some clang warnings of implicit declarations of functions. The `register int` silences a warning of implicit int. --- modules/src/system/access.c | 1 + modules/src/system/close.c | 1 + modules/src/system/create.c | 3 ++- modules/src/system/open.c | 1 + modules/src/system/read.c | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/src/system/access.c b/modules/src/system/access.c index 20773c7d0..bde73af26 100644 --- a/modules/src/system/access.c +++ b/modules/src/system/access.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include "system.h" int diff --git a/modules/src/system/close.c b/modules/src/system/close.c index 03aa767df..32896d806 100644 --- a/modules/src/system/close.c +++ b/modules/src/system/close.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include "system.h" void diff --git a/modules/src/system/create.c b/modules/src/system/create.c index 21203c41b..27ca9daec 100644 --- a/modules/src/system/create.c +++ b/modules/src/system/create.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include "system.h" extern File *_get_entry(); @@ -14,7 +15,7 @@ sys_create(filep, path, mode) char *path; int mode; { - register fd; + register int fd; register File *fp; if ((fp = _get_entry()) == (File *)0) diff --git a/modules/src/system/open.c b/modules/src/system/open.c index 1433cea9f..eed31dc13 100644 --- a/modules/src/system/open.c +++ b/modules/src/system/open.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include #include "system.h" diff --git a/modules/src/system/read.c b/modules/src/system/read.c index 850d68f35..f84c91de9 100644 --- a/modules/src/system/read.c +++ b/modules/src/system/read.c @@ -4,6 +4,7 @@ */ /* $Id$ */ +#include #include "system.h" int From 84f65f7ce32eeece9c3a8ecd4df03be1120f0c6b Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 22 Mar 2019 14:35:07 -0400 Subject: [PATCH 4/5] Raise _XOPEN_SOURCE from 500 to 700 In OpenBSD, _XOPEN_SOURCE 500 forces _POSIX_C_SOURCE down to 199506, which hides the declarations of openat() and fdopendir() and causes compiler warnings. Don't set _POSIX_C_SOURCE, because _XOPEN_SOURCE may set _POSIX_C_SOURCE to a different value. --- plat/cpm/emu/fileio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plat/cpm/emu/fileio.c b/plat/cpm/emu/fileio.c index a193805eb..d3df45785 100644 --- a/plat/cpm/emu/fileio.c +++ b/plat/cpm/emu/fileio.c @@ -1,5 +1,4 @@ -#define _XOPEN_SOURCE 500 -#define _POSIX_C_SOURCE 200809 +#define _XOPEN_SOURCE 700 #include #include #include @@ -440,4 +439,4 @@ int file_rename(cpm_filename_t* src, cpm_filename_t* dest) int drivefd = get_drive_fd(src); return renameat(drivefd, srcunixfilename, drivefd, destunixfilename); -} \ No newline at end of file +} From bec236c108d007e2c7df1cd63cad637518846d1d Mon Sep 17 00:00:00 2001 From: George Koehler Date: Fri, 22 Mar 2019 15:15:40 -0400 Subject: [PATCH 5/5] Include more headers to declare functions. This causes clang to give fewer warnings of implicit declarations of functions. In mach/pdp/cv/cv.c, rename wr_int2() to cv_int2() because it conflicts with wr_int2() in . In util/ack, rename F_OK to F_TRANSFORM because it conflicts with F_OK for access() in . --- mach/pdp/cv/cv.c | 28 +++++++++++++++------------- modules/src/object/object.h | 1 + plat/osx/cvmach/cvmach.c | 1 + util/ack/files.c | 1 + util/ack/main.c | 6 ++++-- util/ack/run.c | 2 ++ util/ack/scan.c | 4 ++-- util/ack/trans.h | 2 +- util/amisc/aelflod.c | 1 + util/amisc/anm.c | 3 +++ util/amisc/ashow.c | 1 + util/amisc/asize.c | 1 + util/amisc/astrip.c | 3 +++ util/arch/archiver.c | 4 +++- util/int/io.c | 2 ++ util/led/archive.c | 1 + util/led/error.c | 1 + util/led/finish.c | 1 + util/led/output.c | 1 + util/led/write.c | 1 + util/ncgg/output.c | 1 + util/opt/cleanup.c | 1 + util/topgen/main.c | 1 + 23 files changed, 49 insertions(+), 19 deletions(-) diff --git a/mach/pdp/cv/cv.c b/mach/pdp/cv/cv.c index 1cf76e930..6dbea9b0d 100644 --- a/mach/pdp/cv/cv.c +++ b/mach/pdp/cv/cv.c @@ -10,6 +10,8 @@ */ #include +#include +#include struct exec { short a_magic; @@ -28,6 +30,7 @@ struct nlist short n_value; }; +#include #include #ifndef NORCSID @@ -164,14 +167,14 @@ main(argc, argv) } /* Action at last */ - wr_int2(e->a_magic); - wr_int2(e->a_text); - wr_int2(e->a_data); - wr_int2(e->a_bss); - wr_int2(e->a_syms); - wr_int2(e->a_entry); - wr_int2(e->a_unused); - wr_int2(e->a_flag); + cv_int2(e->a_magic); + cv_int2(e->a_text); + cv_int2(e->a_data); + cv_int2(e->a_bss); + cv_int2(e->a_syms); + cv_int2(e->a_entry); + cv_int2(e->a_unused); + cv_int2(e->a_flag); emits(&outsect[TEXTSG]) ; emits(&outsect[ROMSG]) ; emits(&outsect[DATASG]) ; @@ -180,14 +183,14 @@ main(argc, argv) return 0; } -wr_int2(n) +cv_int2(n) { putc(n, output); putc((n>>8), output); } /* -wr_long(l) +cv_long(l) long l; { putc((int)(l >> 16), output); @@ -231,7 +234,6 @@ emit_symtab() struct nlist PDP_name; /* symbol table entry in PDP V7 format */ register unsigned short i; - extern char *malloc(); char *chars; long l; long off = OFF_CHAR(outhead); @@ -289,8 +291,8 @@ emit_symtab() PDP_name.n_name[j] = 0; } fwrite((char *) &PDP_name, sizeof(char), 8, output); - wr_int2(PDP_name.n_type); - wr_int2(PDP_name.n_value); + cv_int2(PDP_name.n_type); + cv_int2(PDP_name.n_value); } } diff --git a/modules/src/object/object.h b/modules/src/object/object.h index cf6ac476a..dcbffb88e 100644 --- a/modules/src/object/object.h +++ b/modules/src/object/object.h @@ -9,6 +9,7 @@ struct ar_hdr; struct outhead; +struct outname; struct outrelo; struct outsect; struct ranlib; diff --git a/plat/osx/cvmach/cvmach.c b/plat/osx/cvmach/cvmach.c index 5f8315ddd..32ee18677 100644 --- a/plat/osx/cvmach/cvmach.c +++ b/plat/osx/cvmach/cvmach.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/util/ack/files.c b/util/ack/files.c index 413395438..2c52ad83f 100644 --- a/util/ack/files.c +++ b/util/ack/files.c @@ -6,6 +6,7 @@ #include #include +#include #include "ack.h" #include "list.h" #include "trans.h" diff --git a/util/ack/main.c b/util/ack/main.c index a57454d60..47fb44f0e 100644 --- a/util/ack/main.c +++ b/util/ack/main.c @@ -4,9 +4,11 @@ * */ +#include #include #include #include +#include #include "ack.h" #include "list.h" #include "trans.h" @@ -386,7 +388,7 @@ static int process(char* arg) if (linker) add_input(&orig, linker); return 1; - case F_OK: + case F_TRANSFORM: break; } if (!phase) @@ -555,7 +557,7 @@ static void setneeds(const char* suffix, int tail) p_suffix = suffix; switch (getpath(&phase)) { - case F_OK: + case F_TRANSFORM: for (; phase; phase = phase->t_next) { if (phase->t_needed) diff --git a/util/ack/run.c b/util/ack/run.c index 32cb59fe5..8c59aa76a 100644 --- a/util/ack/run.c +++ b/util/ack/run.c @@ -4,9 +4,11 @@ * */ +#include #include #include #include +#include #include "ack.h" #include "list.h" #include "trans.h" diff --git a/util/ack/scan.c b/util/ack/scan.c index 3aaab8492..e846578de 100644 --- a/util/ack/scan.c +++ b/util/ack/scan.c @@ -237,7 +237,7 @@ static enum f_path scan_end(trf **first) { /* Finalization */ *first= curr ; } if ( curr->t_next ) { - return F_OK ; + return F_TRANSFORM ; } prev=curr ; } @@ -249,7 +249,7 @@ static enum f_path scan_end(trf **first) { /* Finalization */ if ( prev ) { prev->t_keep=YES ; } - return F_OK ; + return F_TRANSFORM ; } static void find_cpp(void) { diff --git a/util/ack/trans.h b/util/ack/trans.h index 54086a563..f16f64d7c 100644 --- a/util/ack/trans.h +++ b/util/ack/trans.h @@ -57,7 +57,7 @@ void add_input(path *, trf *); int runphase(trf *); /* scan.c */ -enum f_path { F_OK, F_NOMATCH, F_NOPATH } ; +enum f_path { F_TRANSFORM, F_NOMATCH, F_NOPATH } ; enum f_path getpath(trf **); /* trans.c */ diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index de4bcedd8..4ad77adbc 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "out.h" #define ASSERT(x) switch (2) { case 0: case (x): ; } diff --git a/util/amisc/anm.c b/util/amisc/anm.c index f2469f772..076c1424a 100644 --- a/util/amisc/anm.c +++ b/util/amisc/anm.c @@ -10,11 +10,14 @@ ** anm [-gopruns] [name ...] */ +#include #include #include #include #include +#include +#include "object.h" #include "out.h" #include "arch.h" #include "ranlib.h" diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 107e5f8ed..a1dbacf2f 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -7,6 +7,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include #define OK 0 /* Return value of gethead if Orl Korekt. */ diff --git a/util/amisc/asize.c b/util/amisc/asize.c index 998be441d..9b7bd7868 100644 --- a/util/amisc/asize.c +++ b/util/amisc/asize.c @@ -6,6 +6,7 @@ #include #include +#include "object.h" #include "out.h" /* diff --git a/util/amisc/astrip.c b/util/amisc/astrip.c index e82cb27f1..51342be4e 100644 --- a/util/amisc/astrip.c +++ b/util/amisc/astrip.c @@ -4,9 +4,12 @@ */ /* $Id$ */ +#include #include #include #include +#include +#include "object.h" #include "out.h" /* diff --git a/util/arch/archiver.c b/util/arch/archiver.c index 2be5fd3ad..4db6cdc73 100644 --- a/util/arch/archiver.c +++ b/util/arch/archiver.c @@ -25,6 +25,7 @@ static char RcsId[] = "$Id$"; #endif */ +#include #include #include #include @@ -32,6 +33,7 @@ static char RcsId[] = "$Id$"; #include #include #include +#include #include #include #ifdef AAL @@ -460,7 +462,7 @@ char *mess; return; } else if (u_fl && status.st_mtime <= member.ar_date) { - wr_arhdr(fd, member); + wr_arhdr(fd, &member); copy_member(member, ar_fd, fd, 0); return; } diff --git a/util/int/io.c b/util/int/io.c index 926c58b89..a903307aa 100644 --- a/util/int/io.c +++ b/util/int/io.c @@ -4,8 +4,10 @@ /* $Id$ */ +#include #include #include +#include #include "logging.h" #include "global.h" diff --git a/util/led/archive.c b/util/led/archive.c index 1b48dc087..770cd9348 100644 --- a/util/led/archive.c +++ b/util/led/archive.c @@ -11,6 +11,7 @@ static char rcsid[] = "$Id$"; #include #include #include "arch.h" +#include "object.h" #include "out.h" #include "ranlib.h" #include "const.h" diff --git a/util/led/error.c b/util/led/error.c index 61dc7983e..aeb8a31b3 100644 --- a/util/led/error.c +++ b/util/led/error.c @@ -11,6 +11,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include #include "const.h" diff --git a/util/led/finish.c b/util/led/finish.c index 9735ae440..e4d4dcbbe 100644 --- a/util/led/finish.c +++ b/util/led/finish.c @@ -10,6 +10,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include #include "const.h" #include "defs.h" diff --git a/util/led/output.c b/util/led/output.c index b303b24b2..44233840b 100644 --- a/util/led/output.c +++ b/util/led/output.c @@ -10,6 +10,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include #include "const.h" #include "memory.h" diff --git a/util/led/write.c b/util/led/write.c index cf161b61f..a0554b8e2 100644 --- a/util/led/write.c +++ b/util/led/write.c @@ -12,6 +12,7 @@ static char rcsid[] = "$Id$"; #include #include #include +#include #include "out.h" #include "const.h" #include "memory.h" diff --git a/util/ncgg/output.c b/util/ncgg/output.c index 7d85b9179..40733bab0 100644 --- a/util/ncgg/output.c +++ b/util/ncgg/output.c @@ -23,6 +23,7 @@ static char rcsid[]= "$Id$"; #include #include #include +#include #include "varinfo.h" #include "param.h" #include "reg.h" diff --git a/util/opt/cleanup.c b/util/opt/cleanup.c index 95564da0c..504e712f4 100644 --- a/util/opt/cleanup.c +++ b/util/opt/cleanup.c @@ -4,6 +4,7 @@ static char rcsid[] = "$Id$"; #include #include +#include #include "param.h" #include "types.h" #include diff --git a/util/topgen/main.c b/util/topgen/main.c index 35e0585d7..1a8dfed56 100644 --- a/util/topgen/main.c +++ b/util/topgen/main.c @@ -11,6 +11,7 @@ #include #include +#include #include "Lpars.h" extern int lineno, newline;