From 85f96a7d6f65cf84aec22762818a96261323b1ce Mon Sep 17 00:00:00 2001 From: uz Date: Mon, 28 Sep 2009 15:59:18 +0000 Subject: [PATCH] Fixed warnings generated by clang (run by Per Olofsson). git-svn-id: svn://svn.cc65.org/cc65/trunk@4255 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/listing.c | 12 ++++++------ src/ca65/nexttok.c | 10 +++++----- src/ca65/pseudo.c | 4 ++-- src/cc65/codeent.c | 26 +++++++++++++++----------- src/cc65/codegen.c | 6 +++--- src/cc65/codeseg.c | 4 ++-- src/cc65/compile.c | 2 +- src/cc65/error.c | 16 ++++++++-------- src/cc65/preproc.c | 4 ++-- src/cc65/scanner.c | 2 +- src/cc65/stmt.c | 2 +- src/da65/handler.c | 10 +++++----- src/ld65/scanner.c | 4 ++-- src/od65/dump.c | 22 +++++++++++----------- 14 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/ca65/listing.c b/src/ca65/listing.c index 911c27db2..37dbcd2c9 100644 --- a/src/ca65/listing.c +++ b/src/ca65/listing.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2008 Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2000-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -218,7 +218,7 @@ static void PrintPageHeader (FILE* F, const ListLine* L) /* Print the header for a new page. It is assumed that the given line is the * last line of the previous page. */ -{ +{ /* Gte a pointer to the current input file */ const StrBuf* CurFile = GetFileName (L->File); @@ -231,7 +231,7 @@ static void PrintPageHeader (FILE* F, const ListLine* L) VER_MAJOR, VER_MINOR, VER_PATCH, Copyright, InFile, - SB_GetLen (CurFile), SB_GetConstBuf (CurFile)); + (int) SB_GetLen (CurFile), SB_GetConstBuf (CurFile)); /* Count pages, reset lines */ ++PageNumber; diff --git a/src/ca65/nexttok.c b/src/ca65/nexttok.c index b5ae2ecb1..cb76bdb18 100644 --- a/src/ca65/nexttok.c +++ b/src/ca65/nexttok.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2008 Ullrich von Bassewitz */ -/* Roemerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2000-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -707,7 +707,7 @@ void Consume (Token Expected, const char* ErrMsg) if (Tok == Expected) { NextTok (); } else { - Error (ErrMsg); + Error ("%s", ErrMsg); } } diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 55383b935..00c9bdc72 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2008, Ullrich von Bassewitz */ +/* (C) 1998-2009, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -1356,7 +1356,7 @@ static void DoOut (void) /* Output the string and be sure to flush the output to keep it in * sync with any error messages if the output is redirected to a file. */ - printf ("%*s\n", SB_GetLen (&SVal), SB_GetConstBuf (&SVal)); + printf ("%.*s\n", (int) SB_GetLen (&SVal), SB_GetConstBuf (&SVal)); fflush (stdout); NextTok (); } diff --git a/src/cc65/codeent.c b/src/cc65/codeent.c index 546786b7a..8c73081b6 100644 --- a/src/cc65/codeent.c +++ b/src/cc65/codeent.c @@ -1373,6 +1373,7 @@ void CE_Output (const CodeEntry* E) { const OPCDesc* D; unsigned Chars; + int Space; const char* Target; /* If we have a label, print that */ @@ -1387,6 +1388,9 @@ void CE_Output (const CodeEntry* E) /* Print the mnemonic */ Chars = WriteOutput ("\t%s", D->Mnemo); + + /* Space to leave before the operand */ + Space = 9 - Chars; /* Print the operand */ switch (E->AM) { @@ -1397,50 +1401,50 @@ void CE_Output (const CodeEntry* E) case AM65_ACC: /* accumulator */ - Chars += WriteOutput ("%*sa", 9-Chars, ""); + Chars += WriteOutput ("%*sa", Space, ""); break; case AM65_IMM: /* immidiate */ - Chars += WriteOutput ("%*s#%s", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s#%s", Space, "", E->Arg); break; case AM65_ZP: case AM65_ABS: /* zeropage and absolute */ - Chars += WriteOutput ("%*s%s", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s%s", Space, "", E->Arg); break; case AM65_ZPX: case AM65_ABSX: /* zeropage,X and absolute,X */ - Chars += WriteOutput ("%*s%s,x", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s%s,x", Space, "", E->Arg); break; case AM65_ABSY: /* absolute,Y */ - Chars += WriteOutput ("%*s%s,y", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s%s,y", Space, "", E->Arg); break; case AM65_ZPX_IND: /* (zeropage,x) */ - Chars += WriteOutput ("%*s(%s,x)", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s(%s,x)", Space, "", E->Arg); break; case AM65_ZP_INDY: /* (zeropage),y */ - Chars += WriteOutput ("%*s(%s),y", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s(%s),y", Space, "", E->Arg); break; case AM65_ZP_IND: /* (zeropage) */ - Chars += WriteOutput ("%*s(%s)", 9-Chars, "", E->Arg); + Chars += WriteOutput ("%*s(%s)", Space, "", E->Arg); break; case AM65_BRA: /* branch */ Target = E->JumpTo? E->JumpTo->Name : E->Arg; - Chars += WriteOutput ("%*s%s", 9-Chars, "", Target); + Chars += WriteOutput ("%*s%s", Space, "", Target); break; default: @@ -1449,11 +1453,11 @@ void CE_Output (const CodeEntry* E) } /* Print usage info if requested by the debugging flag */ - if (Debug) { + if (Debug) { char Use [128]; char Chg [128]; WriteOutput ("%*s; USE: %-12s CHG: %-12s SIZE: %u", - 30-Chars, "", + (int)(30-Chars), "", RegInfoDesc (E->Use, Use), RegInfoDesc (E->Chg, Chg), E->Size); diff --git a/src/cc65/codegen.c b/src/cc65/codegen.c index 76077ab30..abb8a6ec4 100644 --- a/src/cc65/codegen.c +++ b/src/cc65/codegen.c @@ -929,7 +929,7 @@ void g_getind (unsigned Flags, unsigned Offs) void g_leasp (int Offs) /* Fetch the address of the specified symbol into the primary register */ { - unsigned char Lo, Hi; + unsigned char Lo, Hi; /* Calculate the offset relative to sp */ Offs -= StackPtr; @@ -4230,7 +4230,7 @@ void g_defbytes (const void* Bytes, unsigned Count) } while (Chunk); /* Output the line */ - AddDataLine (Buf); + AddDataLine ("%s", Buf); } } @@ -4407,7 +4407,7 @@ void g_switch (Collection* Nodes, unsigned DefaultLabel, unsigned Depth) void g_asmcode (struct StrBuf* B) /* Output one line of assembler code. */ { - AddCodeLine ("%.*s", SB_GetLen (B), SB_GetConstBuf (B)); + AddCodeLine ("%.*s", (int) SB_GetLen (B), SB_GetConstBuf (B)); } diff --git a/src/cc65/codeseg.c b/src/cc65/codeseg.c index 36fdc05b6..492a322b9 100644 --- a/src/cc65/codeseg.c +++ b/src/cc65/codeseg.c @@ -1079,7 +1079,7 @@ void CS_DelCodeRange (CodeSeg* S, unsigned First, unsigned Last) if (CE_HasLabel (FirstEntry)) { /* Get the entry following last */ CodeEntry* FollowingEntry = CS_GetNextEntry (S, Last); - if (FollowingEntry) { + if (FollowingEntry) { /* There is an entry after Last - move the labels */ CS_MoveLabels (S, FirstEntry, FollowingEntry); } else { @@ -1395,7 +1395,7 @@ void CS_Output (CodeSeg* S) const char* N = strchr (L, '\n'); if (N) { /* We have a newline, just write the first part */ - WriteOutput ("%.*s\n; ", N - L, L); + WriteOutput ("%.*s\n; ", (int) (N - L), L); L = N+1; } else { /* No Newline, write as is */ diff --git a/src/cc65/compile.c b/src/cc65/compile.c index befb1e9c6..9e2f23fce 100644 --- a/src/cc65/compile.c +++ b/src/cc65/compile.c @@ -356,7 +356,7 @@ void Compile (const char* FileName) /* Preprocess each line and write it to the output file */ while (NextLine ()) { Preprocess (); - WriteOutput ("%.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + WriteOutput ("%.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } /* Close the output file */ diff --git a/src/cc65/error.c b/src/cc65/error.c index 9a41afe98..694ccdd01 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2004 Ullrich von Bassewitz */ -/* Römerstraße 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -77,7 +77,7 @@ static void IntWarning (const char* Filename, unsigned LineNo, const char* Msg, fprintf (stderr, "\n"); if (Line) { - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } ++WarningCount; } @@ -126,7 +126,7 @@ static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va fprintf (stderr, "\n"); if (Line) { - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } ++ErrorCount; if (ErrorCount > 10) { @@ -192,7 +192,7 @@ void Fatal (const char* Format, ...) fprintf (stderr, "\n"); if (Line) { - Print (stderr, 1, "Input: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } exit (EXIT_FAILURE); } @@ -223,7 +223,7 @@ void Internal (const char* Format, ...) fprintf (stderr, "\n"); if (Line) { - fprintf (stderr, "\nInput: %.*s\n", SB_GetLen (Line), SB_GetConstBuf (Line)); + fprintf (stderr, "\nInput: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } /* Use abort to create a core dump */ diff --git a/src/cc65/preproc.c b/src/cc65/preproc.c index 77720a710..1b13018bc 100644 --- a/src/cc65/preproc.c +++ b/src/cc65/preproc.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2008, Ullrich von Bassewitz */ +/* (C) 1998-2009, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -1387,7 +1387,7 @@ void Preprocess (void) Done: if (Verbosity > 1 && SB_NotEmpty (Line)) { printf ("%s(%u): %.*s\n", GetCurrentFile (), GetCurrentLine (), - SB_GetLen (Line), SB_GetConstBuf (Line)); + (int) SB_GetLen (Line), SB_GetConstBuf (Line)); } } diff --git a/src/cc65/scanner.c b/src/cc65/scanner.c index 49fd291d5..74ceb6742 100644 --- a/src/cc65/scanner.c +++ b/src/cc65/scanner.c @@ -1037,7 +1037,7 @@ int Consume (token_t Token, const char* ErrorMsg) NextToken (); return 1; } else { - Error (ErrorMsg); + Error ("%s", ErrorMsg); return 0; } } diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 977971b01..1f5a61ea4 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -91,7 +91,7 @@ static void CheckTok (token_t Tok, const char* Msg, int* PendingToken) */ { if (CurTok.Tok != Tok) { - Error (Msg); + Error ("%s", Msg); } else if (PendingToken) { *PendingToken = 1; } else { diff --git a/src/da65/handler.c b/src/da65/handler.c index f7412ff77..3b73a01cc 100644 --- a/src/da65/handler.c +++ b/src/da65/handler.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000-2004 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2000-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -80,7 +80,7 @@ static void OneLine (const OpcDesc* D, const char* Arg, ...) xvsprintf (Buf, sizeof (Buf), Arg, ap); va_end (ap); Indent (ACol); - Output (Buf); + Output ("%s", Buf); /* Add the code stuff as comment */ LineComment (PC, D->Size); diff --git a/src/ld65/scanner.c b/src/ld65/scanner.c index f2649e405..35a7addf9 100644 --- a/src/ld65/scanner.c +++ b/src/ld65/scanner.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2008, Ullrich von Bassewitz */ +/* (C) 1998-2009, Ullrich von Bassewitz */ /* Roemerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ @@ -360,7 +360,7 @@ void CfgConsume (cfgtok_t T, const char* Msg) /* Skip a token, print an error message if not found */ { if (CfgTok != T) { - CfgError (Msg); + CfgError ("%s", Msg); } CfgNextTok (); } diff --git a/src/od65/dump.c b/src/od65/dump.c index 208c4bfbc..2db9b964d 100644 --- a/src/od65/dump.c +++ b/src/od65/dump.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2002-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2002-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -317,7 +317,7 @@ void DumpObjOptions (FILE* F, unsigned long Offset) case OPT_ARGSTR: ArgStr = GetString (&StrPool, Val); ArgLen = strlen (ArgStr); - printf (" Data:%*s\"%s\"\n", 24-ArgLen, "", ArgStr); + printf (" Data:%*s\"%s\"\n", (int)(24-ArgLen), "", ArgStr); break; case OPT_ARGNUM: @@ -383,7 +383,7 @@ void DumpObjFiles (FILE* F, unsigned long Offset) printf (" Index:%27u\n", I); /* Print the data */ - printf (" Name:%*s\"%s\"\n", 24-Len, "", Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); printf (" Size:%26lu\n", Size); printf (" Modification time:%13lu (%s)\n", MTime, TimeToStr (MTime)); } @@ -437,7 +437,7 @@ void DumpObjSegments (FILE* F, unsigned long Offset) printf (" Index:%27u\n", I); /* Print the data */ - printf (" Name:%*s\"%s\"\n", 24-Len, "", Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); printf (" Size:%26lu\n", Size); printf (" Alignment:%21u\n", Align); printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize, @@ -496,7 +496,7 @@ void DumpObjImports (FILE* F, unsigned long Offset) /* Print the data */ printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize, AddrSizeToStr (AddrSize)); - printf (" Name:%*s\"%s\"\n", 24-Len, "", Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); } /* Destroy the string pool */ @@ -564,7 +564,7 @@ void DumpObjExports (FILE* F, unsigned long Offset) printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, ConDes)); printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize, AddrSizeToStr (AddrSize)); - printf (" Name:%*s\"%s\"\n", 24-Len, "", Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); if (HaveValue) { printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value); } @@ -637,7 +637,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset) printf (" Type:%22s0x%02X (%s)\n", "", Type, GetExportFlags (Type, 0)); printf (" Address size:%14s0x%02X (%s)\n", "", AddrSize, AddrSizeToStr (AddrSize)); - printf (" Name:%*s\"%s\"\n", 24-Len, "", Name); + printf (" Name:%*s\"%s\"\n", (int)(24-Len), "", Name); if (HaveValue) { printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value); } @@ -745,7 +745,7 @@ void DumpObjSegSize (FILE* F, unsigned long Offset) (void) ReadVar (F); /* Print the size for this segment */ - printf (" %s:%*s%6lu\n", Name, 24-Len, "", Size); + printf (" %s:%*s%6lu\n", Name, (int)(24-Len), "", Size); /* Seek to the end of the segment data (start of next) */ FileSetPos (F, NextSeg); -- 2.39.5