From 08ccd043d7767373f775ad6f5e57b86045985db8 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 14:41:44 -0700 Subject: [PATCH 1/8] Fix "assignment as a condition" warnings A lot of code assigns variables within an if condition, like: if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); This results in warnings with modern compilers: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] Fix the code by properly adding parenthesis around these assignments. --- converters/asc/asc.c | 2 +- converters/decsys/decsys.c | 2 +- converters/dtos8cvt/dtos8cvt.c | 2 +- converters/gt7cvt/gt7cvt.c | 2 +- converters/indent/indent.c | 2 +- converters/littcvt/littcvt.c | 2 +- converters/mt2tpc/mt2tpc.c | 2 +- converters/mtcvt23/mtcvtv23.c | 2 +- converters/mtcvtfix/mtcvtfix.c | 2 +- converters/mtcvtodd/mtcvtodd.c | 2 +- converters/noff/noff.c | 2 +- converters/sfmtcvt/sfmtcvt.c | 2 +- converters/strrem/strrem.c | 2 +- converters/strsub/strsub.c | 2 +- converters/tp512cvt/tp512cvt.c | 2 +- converters/tpc2mt/tpc2mt.c | 2 +- crossassemblers/hpasm/hpasm.c | 4 ++-- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/converters/asc/asc.c b/converters/asc/asc.c index 44630f0..5532f37 100644 --- a/converters/asc/asc.c +++ b/converters/asc/asc.c @@ -71,7 +71,7 @@ else mode = MD_WIN; for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/decsys/decsys.c b/converters/decsys/decsys.c index ac12d34..5eba4cc 100644 --- a/converters/decsys/decsys.c +++ b/converters/decsys/decsys.c @@ -42,7 +42,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".dtp"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".dtp"); else strcat (oname, ".dtp"); ifile = fopen (argv[i], "r"); if (ifile == NULL) { diff --git a/converters/dtos8cvt/dtos8cvt.c b/converters/dtos8cvt/dtos8cvt.c index 8a0b4c0..0d6b495 100644 --- a/converters/dtos8cvt/dtos8cvt.c +++ b/converters/dtos8cvt/dtos8cvt.c @@ -42,7 +42,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".dt8"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".dt8"); else strcat (oname, ".dt8"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/gt7cvt/gt7cvt.c b/converters/gt7cvt/gt7cvt.c index 690728d..1340bac 100644 --- a/converters/gt7cvt/gt7cvt.c +++ b/converters/gt7cvt/gt7cvt.c @@ -62,7 +62,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".tap"); else strcat (oname, ".tap"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/indent/indent.c b/converters/indent/indent.c index 03760f1..7dbe160 100644 --- a/converters/indent/indent.c +++ b/converters/indent/indent.c @@ -45,7 +45,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "ra"); if (ifile == NULL) { diff --git a/converters/littcvt/littcvt.c b/converters/littcvt/littcvt.c index 617d1ca..10c2580 100644 --- a/converters/littcvt/littcvt.c +++ b/converters/littcvt/littcvt.c @@ -44,7 +44,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/mt2tpc/mt2tpc.c b/converters/mt2tpc/mt2tpc.c index 8bf4acf..e6c5eca 100644 --- a/converters/mt2tpc/mt2tpc.c +++ b/converters/mt2tpc/mt2tpc.c @@ -46,7 +46,7 @@ if (argc < 2) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tpc"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".tpc"); else strcat (oname, ".tpc"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/mtcvt23/mtcvtv23.c b/converters/mtcvt23/mtcvtv23.c index 3b150c5..ebffe78 100644 --- a/converters/mtcvt23/mtcvtv23.c +++ b/converters/mtcvt23/mtcvtv23.c @@ -43,7 +43,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".tap"); else strcat (oname, ".tap"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/mtcvtfix/mtcvtfix.c b/converters/mtcvtfix/mtcvtfix.c index bc0f922..01cd8ce 100644 --- a/converters/mtcvtfix/mtcvtfix.c +++ b/converters/mtcvtfix/mtcvtfix.c @@ -45,7 +45,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/mtcvtodd/mtcvtodd.c b/converters/mtcvtodd/mtcvtodd.c index e00c357..0813679 100644 --- a/converters/mtcvtodd/mtcvtodd.c +++ b/converters/mtcvtodd/mtcvtodd.c @@ -43,7 +43,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/noff/noff.c b/converters/noff/noff.c index 1234050..02df837 100644 --- a/converters/noff/noff.c +++ b/converters/noff/noff.c @@ -42,7 +42,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "ra"); if (ifile == NULL) { diff --git a/converters/sfmtcvt/sfmtcvt.c b/converters/sfmtcvt/sfmtcvt.c index d558d44..3d1f2bc 100644 --- a/converters/sfmtcvt/sfmtcvt.c +++ b/converters/sfmtcvt/sfmtcvt.c @@ -97,7 +97,7 @@ for (i = 1, numf = 0; i < argc; i++) { maxaddr[0], k, maxaddr[k]); return 0; } } strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".bin"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".bin"); else strcat (oname, ".bin"); ofile = fopen (oname, "wb"); if (ofile == NULL) { diff --git a/converters/strrem/strrem.c b/converters/strrem/strrem.c index 22b0996..a51aab8 100644 --- a/converters/strrem/strrem.c +++ b/converters/strrem/strrem.c @@ -44,7 +44,7 @@ if ((argc < 2) || (argv[0] == NULL)) { slen = strlen (srem); for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "r"); if (ifile == NULL) { diff --git a/converters/strsub/strsub.c b/converters/strsub/strsub.c index ff4503c..ea57f28 100644 --- a/converters/strsub/strsub.c +++ b/converters/strsub/strsub.c @@ -44,7 +44,7 @@ rmvlen = strlen (rmv); ins = argv[2]; for (i = 3; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".new"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".new"); else strcat (oname, ".new"); ifile = fopen (argv[i], "r"); if (ifile == NULL) { diff --git a/converters/tp512cvt/tp512cvt.c b/converters/tp512cvt/tp512cvt.c index cd5af60..da19219 100644 --- a/converters/tp512cvt/tp512cvt.c +++ b/converters/tp512cvt/tp512cvt.c @@ -44,7 +44,7 @@ if ((argc < 2) || (argv[0] == NULL)) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".tap"); else strcat (oname, ".tap"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/converters/tpc2mt/tpc2mt.c b/converters/tpc2mt/tpc2mt.c index 3c5896d..25a1213 100644 --- a/converters/tpc2mt/tpc2mt.c +++ b/converters/tpc2mt/tpc2mt.c @@ -46,7 +46,7 @@ if (argc < 2) { for (i = 1; i < argc; i++) { strcpy (oname, argv[i]); - if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap"); + if ((ppos = strrchr (oname, '.'))) strcpy (ppos, ".tap"); else strcat (oname, ".tap"); ifile = fopen (argv[i], "rb"); if (ifile == NULL) { diff --git a/crossassemblers/hpasm/hpasm.c b/crossassemblers/hpasm/hpasm.c index 69828ca..e9fa120 100644 --- a/crossassemblers/hpasm/hpasm.c +++ b/crossassemblers/hpasm/hpasm.c @@ -44,7 +44,7 @@ char *nam; char *ppos; strncpy (listfilename, nam, 250); - if (ppos = strrchr (listfilename, '.')) strcpy (ppos, ".lst"); + if ((ppos = strrchr (listfilename, '.'))) strcpy (ppos, ".lst"); else strcat (listfilename, ".lst"); listfile = fopen (listfilename, "w"); } @@ -76,7 +76,7 @@ char *nam; char *ppos; strncpy (outfilename, nam, 250); - if (ppos = strrchr (outfilename, '.')) strcpy (ppos, ".bin"); + if ((ppos = strrchr (outfilename, '.'))) strcpy (ppos, ".bin"); else strcat (outfilename, ".bin"); outfile = fopen (outfilename, "wb"); outaddr = 0; From cbcc55d68485b3a895ecef143cbee1d483097514 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:07:22 -0700 Subject: [PATCH 2/8] Switch function declarations from K&R to ANSI C --- converters/tar2mt/tar2mt.c | 2 +- crossassemblers/hpasm/hpasm.c | 38 ++++++++++++-------------------- extracters/ckabstape/ckabstape.c | 2 +- extracters/rstsflx/diskio.c | 4 ++-- extracters/rstsflx/dohook.c | 2 +- extracters/rstsflx/doinit.c | 2 +- extracters/rstsflx/rtime.c | 4 ++-- extracters/rstsflx/unxabsio.c | 2 +- 8 files changed, 23 insertions(+), 33 deletions(-) diff --git a/converters/tar2mt/tar2mt.c b/converters/tar2mt/tar2mt.c index 64be3e9..5bb62ec 100644 --- a/converters/tar2mt/tar2mt.c +++ b/converters/tar2mt/tar2mt.c @@ -29,7 +29,7 @@ #include #include -main (int argc, char **argv) +int main (int argc, char **argv) { FILE *fIn = NULL, *fOut = NULL; size_t blocksize = 8192, bytes_read; diff --git a/crossassemblers/hpasm/hpasm.c b/crossassemblers/hpasm/hpasm.c index e9fa120..c997dd5 100644 --- a/crossassemblers/hpasm/hpasm.c +++ b/crossassemblers/hpasm/hpasm.c @@ -35,11 +35,10 @@ int rep_count=0; /* >0 if REP statement in process */ char listfilename[256]; FILE *listfile; /****************************************************/ -start_listing (nam) +void start_listing (char *nam) /* ** Initialize listing output file */ -char *nam; { char *ppos; @@ -49,7 +48,7 @@ char *nam; listfile = fopen (listfilename, "w"); } /****************************************************/ -finish_listing () { +void finish_listing (void) { /* ** Finish off listing output file */ @@ -67,11 +66,10 @@ long outcount; long outbufsize=27; long outbuf[27]; /****************************************************/ -start_output (nam) +void start_output (char *nam) /* ** Initialize binary output file */ -char *nam; { char *ppos; @@ -83,7 +81,7 @@ char *nam; outcount = 0; } /****************************************************/ -send_output () { +void send_output (void) { /* ** Write block to binary output file */ @@ -104,24 +102,22 @@ send_output () { outcount = 0; } /****************************************************/ -output_word (addr,word) +void output_word (long address, long word) /* ** Write word to binary output file */ -long addr; -long word; { - if (outcount && (outaddr + outcount) != addr) { + if (outcount && (outaddr + outcount) != address) { send_output(); } - if (!outcount) outaddr = addr; + if (!outcount) outaddr = address; outbuf[outcount++] = word; if (outcount == outbufsize) { send_output(); } } /****************************************************/ -finish_output () { +void finish_output (void) { /* ** Finish current output block, write trailing leader, ** and close output file @@ -133,8 +129,7 @@ finish_output () { printf ("Output is in %s\n", outfilename); } /****************************************************/ -emit (code) -long code; +void emit (long code) { fprintf (listfile, " %05lo %06lo ", addr, code); if (!print_flag) { @@ -147,8 +142,7 @@ long code; addr++; } /****************************************************/ -err (text) -char *text; +void err (char *text) { if (!print_flag) { fprintf (listfile, " %12s %s\n", " ", line); @@ -221,7 +215,7 @@ long *value; *value=0; } /****************************************************/ -show_labels () +void show_labels (void) { long i; for (i=0; itm_year - 70) * 1000 + tmb->tm_yday + 1); } -word curtime () /* current time in rsts form */ +word curtime (void) /* current time in rsts form */ { struct tm *tmb; time_t now; diff --git a/extracters/rstsflx/unxabsio.c b/extracters/rstsflx/unxabsio.c index 652895a..036e463 100644 --- a/extracters/rstsflx/unxabsio.c +++ b/extracters/rstsflx/unxabsio.c @@ -86,7 +86,7 @@ void absseek (long block) /* This routine is called to do any needed "close" actions for absolute I/O */ -void absclose () +void absclose (void) { rabort(INTERNAL); /* should never get here */ } From ab104adcce81aa645ff9c8a7e6d30d687af5fe6f Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:09:27 -0700 Subject: [PATCH 3/8] Fix warnings for unused function parameters --- config11/config11.c | 2 ++ converters/m8376/m8376.c | 2 ++ extracters/rstsflx/doalloc.c | 1 + extracters/rstsflx/docomp.c | 1 + extracters/rstsflx/doident.c | 1 + extracters/rstsflx/scancmd.c | 2 ++ extracters/rstsflx/unxabsio.c | 3 +++ 7 files changed, 12 insertions(+) diff --git a/config11/config11.c b/config11/config11.c index 3b6c0f1..cb65b48 100644 --- a/config11/config11.c +++ b/config11/config11.c @@ -57,6 +57,8 @@ char *namtab[RANK_LNT] = { int main (int argc, char *argv[]) { +(void)argc; (void)argv; + for ( ;; ) { for (i = 0; i < RANK_LNT; i++) numctl[i] = 0; printf ("Enter configuration data\n"); diff --git a/converters/m8376/m8376.c b/converters/m8376/m8376.c index 48ac147..35d003e 100644 --- a/converters/m8376/m8376.c +++ b/converters/m8376/m8376.c @@ -38,6 +38,8 @@ char fname[256]; int c, i, j; unsigned int wd[1024]; +(void)argc; (void)argv; + for (i = 0; i < 8; i++) { sprintf (fname, "C:\\temp\\m8376\\m8376e%03d.bin", fnum[i]); fi[i] = fopen (fname, "rb"); diff --git a/extracters/rstsflx/doalloc.c b/extracters/rstsflx/doalloc.c index eabbe78..2b076c3 100644 --- a/extracters/rstsflx/doalloc.c +++ b/extracters/rstsflx/doalloc.c @@ -10,6 +10,7 @@ void doalloc (int argc, char **argv) /* show allocated clusters */ { + (void)argc; (void)argv; /* unused parameters */ byte *s; int bit, szb; long first, used, unused, biggest, size; diff --git a/extracters/rstsflx/docomp.c b/extracters/rstsflx/docomp.c index 362c4f5..b69495c 100644 --- a/extracters/rstsflx/docomp.c +++ b/extracters/rstsflx/docomp.c @@ -11,6 +11,7 @@ void docomp (int argc, char **argv) /* zero unused clusters */ { + (void)argc; (void)argv; /* unused parameters */ byte *s; int bit, szb; long first, size, iosize; diff --git a/extracters/rstsflx/doident.c b/extracters/rstsflx/doident.c index 2038425..9982aa7 100644 --- a/extracters/rstsflx/doident.c +++ b/extracters/rstsflx/doident.c @@ -10,6 +10,7 @@ void doident (int argc, char **argv) /* show pack id data */ { + (void)argc; (void)argv; /* unused parameters */ packlabel *p; char rdate[DATELEN]; char rtime[RTIMELEN]; diff --git a/extracters/rstsflx/scancmd.c b/extracters/rstsflx/scancmd.c index f4f689c..958f355 100644 --- a/extracters/rstsflx/scancmd.c +++ b/extracters/rstsflx/scancmd.c @@ -219,6 +219,7 @@ void dodisk (int argc, char **argv) void doexit (int argc, char **argv) { + (void)argc; (void)argv; /* unused parameters */ int i; #ifndef __APPLE__ @@ -496,6 +497,7 @@ void initialize_readline (void) */ char ** flx_completion (char *text, int start, int end) { + (void)end; /* unused parameter */ char **matches; matches = NULL; diff --git a/extracters/rstsflx/unxabsio.c b/extracters/rstsflx/unxabsio.c index 036e463..473e71d 100644 --- a/extracters/rstsflx/unxabsio.c +++ b/extracters/rstsflx/unxabsio.c @@ -81,6 +81,7 @@ int absopen (const char *rname, const char *mode) void absseek (long block) { + (void)block; /* unused parameter */ rabort(INTERNAL); /* should never get here */ } @@ -99,6 +100,7 @@ void absclose (void) long absread (long sec, long count, void *buffer) { + (void)sec; (void)count; (void)buffer; /* unused parameters */ return (0); /* should never get here */ } @@ -106,5 +108,6 @@ long absread (long sec, long count, void *buffer) long abswrite (long sec, long count, void *buffer) { + (void)sec; (void)count; (void)buffer; /* unused parameters */ return (0); /* should never get here */ } From 1baa6cf5f8ff7daf4d6f5533481acb7ccdd3c71f Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:13:07 -0700 Subject: [PATCH 4/8] Remove unused variables --- converters/decsys/decsys.c | 4 ++-- converters/noff/noff.c | 2 +- extracters/mmdir/mmdir.c | 4 ++-- extracters/rstsflx/rstsflx.c | 1 - extracters/rstsflx/scancmd.c | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/converters/decsys/decsys.c b/converters/decsys/decsys.c index 5eba4cc..b5c7093 100644 --- a/converters/decsys/decsys.c +++ b/converters/decsys/decsys.c @@ -31,7 +31,7 @@ int main (int argc, char *argv[]) { -int i, j, k, word; +int i, k, word; char *ppos, oname[256]; int fill[256] = { 0 }; FILE *ifile, *ofile; @@ -55,7 +55,7 @@ for (i = 1; i < argc; i++) { printf ("Processing file %s\n", argv[i]); fwrite (fill, sizeof (int), 256, ofile); - for (j = 0;; j++) { + for (;;) { k = fscanf (ifile, "%d", &word); if (k == EOF) break; // printf ("%06o\n", word); diff --git a/converters/noff/noff.c b/converters/noff/noff.c index 02df837..d82211b 100644 --- a/converters/noff/noff.c +++ b/converters/noff/noff.c @@ -33,7 +33,7 @@ int main (int argc, char *argv[]) { int i, c, ffc; -char *ppos, oline[256], oname[256]; +char *ppos, oname[256]; FILE *ifile, *ofile; if ((argc < 2) || (argv[0] == NULL)) { diff --git a/extracters/mmdir/mmdir.c b/extracters/mmdir/mmdir.c index d5744ac..4769518 100644 --- a/extracters/mmdir/mmdir.c +++ b/extracters/mmdir/mmdir.c @@ -32,7 +32,7 @@ int main (int argc, char *argv[]) { -int obj, i, k, fc, rc, tpos, sa, ea, fr, fq; +int i, k, fc, rc, tpos, sa, ea, fr, fq; unsigned char b[53]; unsigned char bca[4]; unsigned int bc; @@ -67,7 +67,7 @@ for (i = 1; i < argc; i++) { printf ("End of logical tape\n"); break; } preveof = 1; - fc++; obj++; + fc++; rc = 1; tpos = tpos + 4; } else if (bc > MAXRLNT) { diff --git a/extracters/rstsflx/rstsflx.c b/extracters/rstsflx/rstsflx.c index 9b46234..cda36f9 100644 --- a/extracters/rstsflx/rstsflx.c +++ b/extracters/rstsflx/rstsflx.c @@ -83,7 +83,6 @@ void doabort(int status, const char *srcfile, int srcline) int main (int argc, char **argv) { - int cmdlen; char **cmdargv = NULL; /* for scanning command line */ int cmdargc; char *word; diff --git a/extracters/rstsflx/scancmd.c b/extracters/rstsflx/scancmd.c index 958f355..376c869 100644 --- a/extracters/rstsflx/scancmd.c +++ b/extracters/rstsflx/scancmd.c @@ -220,7 +220,6 @@ void dodisk (int argc, char **argv) void doexit (int argc, char **argv) { (void)argc; (void)argv; /* unused parameters */ - int i; #ifndef __APPLE__ i = append_history (newhistitems, histfile); From fea0f4d72164007f5738f7bfd1309c6fada0d08a Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:23:30 -0700 Subject: [PATCH 5/8] Type and format fixes --- config11/config11.c | 2 +- converters/gt7cvt/gt7cvt.c | 2 +- converters/hpconvert/hpconvert.c | 3 ++- crossassemblers/hpasm/hpasm.c | 4 ++-- extracters/mtdump/mtdump.c | 2 +- extracters/rawcopy/RawCopy.c | 4 ++-- extracters/tpdump/tpdump.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config11/config11.c b/config11/config11.c index cb65b48..bc22fff 100644 --- a/config11/config11.c +++ b/config11/config11.c @@ -103,7 +103,7 @@ for ( ;; ) { for (j = 1; j < numctl[i]; j++) { printf ("\t\t %d\t%06o\n", j + 1, csr); csr = (csr + modtab[i] + 1) & ~modtab[i]; } - printf (" %\t\tgap\t%06o\n", csr); + printf (" %%\t\tgap\t%06o\n", csr); } if ((i + 1) < RANK_LNT) csr = (csr + modtab[i+1] + 1) & ~modtab[i+1]; } diff --git a/converters/gt7cvt/gt7cvt.c b/converters/gt7cvt/gt7cvt.c index 1340bac..27f8d27 100644 --- a/converters/gt7cvt/gt7cvt.c +++ b/converters/gt7cvt/gt7cvt.c @@ -31,7 +31,7 @@ #define FLPSIZ 65536 unsigned char fzero[4] = { 0 }; -int dump_rec (FILE *of, int bc, char *buf) +int dump_rec (FILE *of, int bc, unsigned char *buf) { unsigned char buc[4]; diff --git a/converters/hpconvert/hpconvert.c b/converters/hpconvert/hpconvert.c index 93d8ff5..98b864b 100644 --- a/converters/hpconvert/hpconvert.c +++ b/converters/hpconvert/hpconvert.c @@ -173,7 +173,8 @@ int main (int argc, char sig_fwd [SIGNATURE_SIZE], sig_rev [SIGNATURE_SIZE]; char hold, cylinder [CYLINDER_SIZE]; bool identified = false, reversed = false, debug = false; - int i, cyl, from_cyl, to_cyl, remap; + size_t i; + int cyl, from_cyl, to_cyl, remap; int platter, cylinder_size, hole_size; diff --git a/crossassemblers/hpasm/hpasm.c b/crossassemblers/hpasm/hpasm.c index c997dd5..0b01dec 100644 --- a/crossassemblers/hpasm/hpasm.c +++ b/crossassemblers/hpasm/hpasm.c @@ -886,7 +886,7 @@ char *argv[]; fflush (stdout); asm_pass (f1); fclose (f1); - printf ("%d lines\n", line_count); + printf ("%ld lines\n", line_count); } } @@ -904,7 +904,7 @@ char *argv[]; printf ("%s ", argv[ii]); fflush (stdout); asm_pass (f1); - printf ("%d lines\n", line_count); + printf ("%ld lines\n", line_count); fclose (f1); } } diff --git a/extracters/mtdump/mtdump.c b/extracters/mtdump/mtdump.c index 7941747..eace445 100644 --- a/extracters/mtdump/mtdump.c +++ b/extracters/mtdump/mtdump.c @@ -53,7 +53,7 @@ if ((argc < 2) || (argv[0] == NULL)) { printf ("Usage is: mtdump {-secf} file [file...]\n"); exit (0); } -s = argv[1]; +s = (unsigned char *)argv[1]; if ((s != NULL) && (*s++ == '-')) { ++argv; --argc; switch (*s) { diff --git a/extracters/rawcopy/RawCopy.c b/extracters/rawcopy/RawCopy.c index 75636e2..1d056c9 100644 --- a/extracters/rawcopy/RawCopy.c +++ b/extracters/rawcopy/RawCopy.c @@ -40,10 +40,10 @@ while (0 != (bytesread = fread(buf, 1, readsize, fin))) else totalbytes += bytesread; if (0 == (totalbytes%(1024*1024))) - fprintf(stderr, "%6dMB Copied...\r", totalbytes/(1024*1024)); + fprintf(stderr, "%6zuMB Copied...\r", totalbytes/(1024*1024)); } fprintf(stderr, "\n"); -fprintf(stderr, "Total Data: %6.2f MBytes (%d bytes)\n", totalbytes/(1024.0*1024.0), totalbytes); +fprintf(stderr, "Total Data: %6.2f MBytes (%zu bytes)\n", totalbytes/(1024.0*1024.0), totalbytes); fclose(fin); fclose(fout); exit(0); diff --git a/extracters/tpdump/tpdump.c b/extracters/tpdump/tpdump.c index 97cf055..ffdcc69 100644 --- a/extracters/tpdump/tpdump.c +++ b/extracters/tpdump/tpdump.c @@ -173,7 +173,7 @@ int main ( int argc, char* argv[] ) if ( (recsiz & 1) && even ) fread ( pr, 1, 1, fi ); recsiz2 = read_len ( fi ); if ( recsiz2 != recsiz ) - { printf("Unequal starting and ending record sizes: %d != %d\n", + { printf("Unequal starting and ending record sizes: %zu != %zu\n", recsiz, recsiz2); return(4); } From e7841440e0dcb4bee47ad42efe2cf7424617a4ac Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:27:45 -0700 Subject: [PATCH 6/8] config11: Use fgets instead of gets From the gets() man page: The gets() function cannot be used securely. Because of its lack of bounds checking, and the inability for the calling program to reliably determine the length of the next incoming line, the use of this function enables malicious users to arbitrarily change a running program's functionality through a buffer overflow attack. It is strongly suggested that the fgets() function be used in all cases. --- config11/config11.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config11/config11.c b/config11/config11.c index bc22fff..540ebca 100644 --- a/config11/config11.c +++ b/config11/config11.c @@ -29,6 +29,7 @@ #include #include #include +#include #define RANK_LNT 34 @@ -64,7 +65,9 @@ for ( ;; ) { printf ("Enter configuration data\n"); for ( ;; ) { printf ("Name:\t"); - if (gets (inp) == NULL) return 0; + if (fgets (inp, sizeof(inp), stdin) == NULL) return 0; + /* Remove trailing newline if present */ + if (inp[strlen(inp)-1] == '\n') inp[strlen(inp)-1] = '\0'; if (*inp == 0) break; for (cp = inp; *cp != 0; cp++) *cp = toupper (*cp); for (rank = 0; rank < RANK_LNT; rank++) { @@ -77,7 +80,9 @@ for ( ;; ) { printf ("\n"); continue; } printf ("Number:\t"); - gets (inp); + if (fgets (inp, sizeof(inp), stdin) == NULL) continue; + /* Remove trailing newline if present */ + if (inp[strlen(inp)-1] == '\n') inp[strlen(inp)-1] = '\0'; errno = 0; num = strtoul (inp, &ocp, 10); if (errno || (inp == ocp)) { From f29ed40788850bde7e0e5cc7c50ada877acc03af Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:29:22 -0700 Subject: [PATCH 7/8] hpconvert: Use mkstemp() instead of tmpnam() From the tmpnam() man page: The tmpnam() and tempnam() functions are susceptible to a race condition occurring between the selection of the file name and the creation of the file, which allows malicious users to potentially overwrite arbitrary files in the system, depending on the level of privilege of the running program. --- converters/hpconvert/hpconvert.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/converters/hpconvert/hpconvert.c b/converters/hpconvert/hpconvert.c index 98b864b..0201b8f 100644 --- a/converters/hpconvert/hpconvert.c +++ b/converters/hpconvert/hpconvert.c @@ -248,7 +248,15 @@ int main (int argc, /* Generate a temporary filename for the converted image. */ - name_out = tmpnam (NULL); + char temp_template[] = "/tmp/hpconvert_XXXXXX"; + int temp_fd = mkstemp(temp_template); + if (temp_fd == -1) { + puts ("Error: cannot generate a temporary filename."); + fclose (fin); + return 1; + } + close(temp_fd); + name_out = temp_template; if (name_out == NULL) { puts ("Error: cannot generate a temporary filename."); From ff05fea5311d976e228ffd9e055deed11026a997 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Fri, 17 Oct 2025 16:30:21 -0700 Subject: [PATCH 8/8] ods2: Use proper braces in direct.c --- extracters/ods2/direct.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/extracters/ods2/direct.c b/extracters/ods2/direct.c index 888af89..3650633 100644 --- a/extracters/ods2/direct.c +++ b/extracters/ods2/direct.c @@ -128,12 +128,15 @@ int namematch(char *spec,int speclen,char *entry,int entrylen) if (entrylen < count) count = entrylen; do { register char sch = *spc,ech = *ent; - if (sch != ech) if (toupper(sch) != toupper(ech)) - if (sch == '%') { - percent = 1; - } else { - break; + if (sch != ech) { + if (toupper(sch) != toupper(ech)) { + if (sch == '%') { + percent = 1; + } else { + break; + } } + } spc++; ent++; } while (--count > 0);