From cda0445afd5e204beda8039b1e081a6765689f2f Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Sun, 29 Jul 2012 16:18:40 +0400 Subject: [PATCH] devel/dev86: fix build with clang QA page: http://codelabs.ru/fbsd/ports/qa/devel/dev86/0.16.18 Signed-off-by: Eygene Ryabinkin --- devel/dev86/files/patch-fix-clang-build | 235 +++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 devel/dev86/files/patch-fix-clang-build diff --git a/devel/dev86/files/patch-fix-clang-build b/devel/dev86/files/patch-fix-clang-build new file mode 100644 index 0000000..af9126f --- /dev/null +++ b/devel/dev86/files/patch-fix-clang-build @@ -0,0 +1,235 @@ +Fix build with clang (warnings and errors) + +- tok_io.c: do_control() returns nothing, is it static + and it is called from tok_io.c without return value + being used. Change return type to 'void'. + +- copt.c: use fputs/fputc instead of fprintf. This disables + interpreting format specifiers inside headstr and slightly + optimizes the code. + +- bcc.c: use proper format specifier for ptrdiff_t argument. + +- label.c: don't use 'array[-1]' even when only address of this + element is needed -- this is better written as 'array - 1'. + +- state.c: remove useless self-assignment for jtablelab. Looks + like is was a hack from times where jtablelab wasn't really + used for I8088 and compiler whined about unused variable. + +- debug.c: embed ID string via __asm. This shuts down the warnings + about uninitialized variables and keeps the ID string even on + high optimization levels. + +- dbprintf.c: add missing header files; enable explicit comparison + in while() loop; __numout() should really return a string ('char *'). + +- ar.c: merge 2 printf() calls to disallow interpretation of format + strings inside 'string' variable. + +- dumps.c: include string.h to get protos for memcmp() and strlen(). + +- ar.h, ld.c: declare and use prototype for ld86r(). + +- mkar.c: include header with prototype for fatalerror(). + +- objdump86.c: remove comparison 'nameoff < 0', because 'nameoff' + is unsigned, so this expression is always true. +--- unproto/tok_io.c.orig 2012-07-28 13:08:02.320365351 +0400 ++++ unproto/tok_io.c 2012-07-28 13:08:09.351369522 +0400 +@@ -189,7 +189,7 @@ + + /* do_control - parse control line */ + +-static int do_control() ++static void do_control() + { + struct token *t; + int line; +--- copt/copt.c.orig 2012-07-28 13:10:55.221365659 +0400 ++++ copt/copt.c 2012-07-28 13:11:21.584365888 +0400 +@@ -803,8 +803,8 @@ + exit(1); + } + if (headstr != NULL) { +- fprintf(fp, headstr); +- fprintf(fp, "\n"); ++ fputs(headstr, fp); ++ fputc('\n', fp); + } + for (lp = infile; lp != NULL; lp = lp->next) + fprintf(fp, "%s\n", lp->text); +--- bcc/bcc.c.orig 2012-07-28 13:19:31.076371448 +0400 ++++ bcc/bcc.c 2012-07-28 13:21:23.985423274 +0400 +@@ -648,7 +648,7 @@ + strcat(buf, command.cmd); + + if (!*command.cmd) +- fprintf(stderr, "PATH%d=%s\n", prefix-exec_prefixs, buf); ++ fprintf(stderr, "PATH%td=%s\n", prefix-exec_prefixs, buf); + else if (access(buf, X_OK) == 0) + { + command.fullpath = copystr(buf); +--- bcc/label.c.orig 2012-07-28 13:27:11.193376632 +0400 ++++ bcc/label.c 2012-07-28 13:27:45.649374746 +0400 +@@ -228,7 +228,7 @@ + labptrsave = labptr; + while (++labptr != labmid) + if (labptr == labmax) +- labptr = &vislab[-1]; ++ labptr = vislab - 1; + else + labptr->lablc -= nlonger; + labptr = labptrsave; +--- bcc/state.c.orig 2012-07-28 13:35:58.774371176 +0400 ++++ bcc/state.c 2012-07-28 13:36:31.876395094 +0400 +@@ -627,9 +627,6 @@ + slconst((value_t) (ptypesize / 2), DREG); + /* really log ptypesize */ + deflabel(jtablelab = casejump()); +-#ifdef I8088 +- jtablelab = jtablelab; /* not used, allocated for regress */ +-#endif + for (caseval = caseptr->casevalue; caseval <= case1ptr->casevalue; + ++caseval) + { +--- bcc/debug.c.orig 2012-07-28 14:18:30.721412113 +0400 ++++ bcc/debug.c 2012-07-28 14:18:34.147438457 +0400 +@@ -89,12 +89,17 @@ + + #define USE_DBPRINTF + ++#if defined(__GNUC__) || defined(__INTEL_COMPILER) ++#define IDENT(string) __asm__(".ident\t\"" string "\"") ++#else ++#define IDENT(string) static char ident[] = string ++#endif ++ ++ + #ifndef DEBUG +-static char ident[] = +- "$Id: debug.c: (c) 1995-2004 Robert de Bath. Debugging disabled. $"; ++IDENT("$Id: debug.c: (c) 1995-2004 Robert de Bath. Debugging disabled. $"); + #else +-static char ident[] = +- "$Id: debug.c: (c) 1995-2004 Robert de Bath. Debugging enabled. $"; ++IDENT("$Id: debug.c: (c) 1995-2004 Robert de Bath. Debugging enabled. $"); + + static char * db_file = 0; + static int db_lineno = 0; +--- bcc/dbprintf.c.orig 2004-06-20 21:14:58.000000000 +0400 ++++ bcc/dbprintf.c 2012-07-28 14:33:47.838364722 +0400 +@@ -1,6 +1,8 @@ + + #include + #include ++#include ++#include + + #if defined(__STDC__) && !defined(__FIRST_ARG_IN_AX__) + #include +@@ -10,6 +12,9 @@ + #define va_strt(p,i) va_start(p) + #endif + ++int ++vdbprintf(register __const char *fmt, register va_list ap); ++ + #if defined(__STDC__) && !defined(__FIRST_ARG_IN_AX__) + int dbprintf(const char * fmt, ...) + #else +@@ -26,7 +31,7 @@ + return rv; + } + +-static unsigned char * __numout (long i, int base); ++static char * __numout (long i, int base); + static void putch(int ch) { static char buf[2]; *buf = ch; write(2,buf,1); } + + int +@@ -42,7 +47,7 @@ + char padch=' '; + int minsize, maxsize; + +- while(c=*fmt++) ++ while((c=*fmt++) != '\0') + { + count++; + if(c!='%') +@@ -151,10 +156,10 @@ + #ifndef __AS386_16__ + #define NUMLTH 11 + +-static unsigned char * ++static char * + __numout(long i, int base) + { +- static unsigned char out[NUMLTH+1]; ++ static char out[NUMLTH+1]; + int n; + int flg = 0; + unsigned long val; +--- ar/ar.c.orig 2012-07-28 14:34:28.541364340 +0400 ++++ ar/ar.c 2012-07-28 14:35:16.894365562 +0400 +@@ -2035,8 +2035,7 @@ + char *string; + struct mapelt *mapelt; + { +- fprintf (stderr, "%s: ", program_name); +- fprintf (stderr, string); ++ fprintf (stderr, "%s: %s", program_name, string); + if (mapelt->info.offset != 0) + fprintf (stderr, "%s(%s)", archive, mapelt->info.name); + else +--- ld/dumps.c.orig 2012-07-28 14:36:40.601368230 +0400 ++++ ld/dumps.c 2012-07-28 14:37:03.679419950 +0400 +@@ -2,6 +2,8 @@ + + /* Copyright (C) 1994 Bruce Evans */ + ++#include ++ + #include "const.h" + #include "obj.h" + #include "type.h" +--- libc/include/ar.h.orig 2012-07-28 14:44:40.334367406 +0400 ++++ libc/include/ar.h 2012-07-28 14:44:50.814379131 +0400 +@@ -15,4 +15,7 @@ + ar_fmag[2]; + }; + ++void ++ld86r(int argc, char ** argv); ++ + #endif /* __AR_H */ +--- ld/ld.c.orig 2012-07-28 14:45:16.329400386 +0400 ++++ ld/ld.c 2012-07-28 14:45:21.116430821 +0400 +@@ -2,6 +2,7 @@ + + /* Copyright (C) 1994 Bruce Evans */ + ++#include "ar.h" + #include "syshead.h" + #include "const.h" + #include "byteord.h" +--- ld/mkar.c.orig 2012-07-28 16:08:30.572367892 +0400 ++++ ld/mkar.c 2012-07-28 16:08:10.395364205 +0400 +@@ -11,6 +11,7 @@ + #endif + + #include "ar.h" ++#include "type.h" + + static struct ar_hdr arbuf; + +--- ld/objdump86.c.orig 2012-07-28 16:16:35.938401199 +0400 ++++ ld/objdump86.c 2012-07-28 16:17:35.736427015 +0400 +@@ -425,7 +425,7 @@ + offset = symtab[i].offset; + + symtype &= 0x3FFF; +- if (nameoff > str_len || nameoff < 0) ++ if (nameoff > str_len) + symnames[i] = strtab + str_len; + else + symnames[i] = strtab+nameoff; -- 1.7.10.3