Skip to content

Commit

Permalink
Fix all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sarnau committed Sep 13, 2024
1 parent 2390351 commit 073f8b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
37 changes: 21 additions & 16 deletions z80_assembler.cp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sys/syslimits.h>

#include "kk_ihex_write.h"
#include "z80_assembler.h"
Expand Down Expand Up @@ -68,7 +69,8 @@ static void listOneLine( uint32_t firstPC, uint32_t lastPC, const char *oneLine
***/
int main( int argc, char **argv )
{
char *filename = nullptr;
char *inputfilename = nullptr;
char outputfilename[PATH_MAX];

char *oneLine;
int i, j;
Expand Down Expand Up @@ -138,25 +140,25 @@ int main( int argc, char **argv )
}
j = 0; // start from the beginning in next arg group
} else {
if ( !filename )
filename = argv[ i ];
if ( !inputfilename )
inputfilename = argv[ i ];
else {
usage( argv[ 0 ] );
return 1;
} // check next arg string
}
}
if ( !filename ) {
if ( !inputfilename ) {
usage( argv[ 0 ] );
return 1;
}

infile = fopen( filename, "r" );
infile = fopen( inputfilename, "r" );
if ( !infile ) {
fprintf( stderr, "Error: cannot open infile %s\n", filename );
fprintf( stderr, "Error: cannot open infile %s\n", inputfilename );
return 1;
}
MSG( 1, "Processing infile \"%s\"\n", filename );
MSG( 1, "Processing infile \"%s\"\n", inputfilename );

LineNo = 1;
InitSymTab(); // init symbol table
Expand Down Expand Up @@ -200,21 +202,24 @@ int main( int argc, char **argv )
}
}

if ( !no_outfile && strlen( filename ) > 4 && !strcmp( filename + strlen( filename ) - 4, ".asm" ) ) {
if ( !no_outfile && strlen( inputfilename ) > 4 && !strcmp( inputfilename + strlen( inputfilename ) - 4, ".asm" ) ) {
strncpy(outputfilename, inputfilename, sizeof(outputfilename));

// create out file name(s) from in file name
sprintf( filename + strlen( filename ) - 3, com ? "com" : "bin" );
MSG( 1, "Creating output file %s\n", filename );
outbin = fopen( filename, "wb" );
size_t fnamelen = strlen( outputfilename );
strncpy( outputfilename + fnamelen - 3, com ? "com" : "bin", sizeof(outputfilename) -fnamelen - 3 );
MSG( 1, "Creating output file %s\n", outputfilename );
outbin = fopen( outputfilename, "wb" );
if ( !outbin ) {
fprintf( stderr, "Error: Can't open output file \"%s\".\n", filename );
fprintf( stderr, "Error: Can't open output file \"%s\".\n", outputfilename );
return 1;
}

sprintf( filename + strlen( filename ) - 3, "hex" );
MSG( 1, "Creating output file %s\n", filename );
outhex = fopen( filename, "wb" );
strncpy( outputfilename + fnamelen - 3, "hex", sizeof(outputfilename) -fnamelen - 3 );
MSG( 1, "Creating output file %s\n", outputfilename );
outhex = fopen( outputfilename, "wb" );
if ( !outhex ) {
fprintf( stderr, "Error: Can't open output file \"%s\".\n", filename );
fprintf( stderr, "Error: Can't open output file \"%s\".\n", outputfilename );
return 1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion z80_compile.cp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ uint8_t *iRAM = RAM + PC;
uint32_t op0;
uint8_t Op0_24,Op0_16;
int16_t op1,op2;
int32_t value1,value2;
int32_t value1 = 0,value2 = 0;
RecalcListP op1Recalc,op2Recalc;

checkPC( PC ); // detect min, max and overflow (wrap around)
Expand Down

2 comments on commit 073f8b1

@Ho-Ro
Copy link
Contributor

@Ho-Ro Ho-Ro commented on 073f8b1 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missing include in the Ubuntu CI build can be fixed by changing sys/syslimits.h to limits.h. What development system do you use? I'm working on Debian stable.

Run make
gcc -c -o z80_assembler.o z80_assembler.cp -I. -Wall
z80_assembler.cp:10:10: fatal error: sys/syslimits.h: No such file or directory
   10 | #include <sys/syslimits.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:[6](https://github.com/sarnau/Z80DisAssembler/actions/runs/10854638418/job/30125514930#step:3:7): z80_assembler.o] Error 1
Error: Process completed with exit code 2.```

@sarnau
Copy link
Owner Author

@sarnau sarnau commented on 073f8b1 Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS, thanks for the fix. Already checked in

Please sign in to comment.