Code cleanup

Thu, 11 Apr 2013 09:18:31 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 11 Apr 2013 09:18:31 +0100
changeset 136
f7d78dfb45d0
parent 134
b826697f411a
child 137
994d03cdcba2

Code cleanup

* Fix some compiler warnings --
* string format
* shift greater than type size,
* unused variable.

src/keyboard.c file | annotate | diff | revisions
src/memory.c file | annotate | diff | revisions
src/wd2010.c file | annotate | diff | revisions
     1.1 diff -r b826697f411a -r f7d78dfb45d0 src/keyboard.c
     1.2 --- a/src/keyboard.c	Wed Mar 13 00:43:25 2013 +0000
     1.3 +++ b/src/keyboard.c	Thu Apr 11 09:18:31 2013 +0100
     1.4 @@ -218,7 +218,6 @@
     1.5  
     1.6  	// if buffer empty, do a keyboard scan
     1.7  	if (ks->buflen == 0) {
     1.8 -		size_t last_writep;
     1.9  		// Keyboard Data Begins Here (BEGKBD)
    1.10  		//ks->buffer[ks->writep] = KEY_BEGIN_KEYBOARD;
    1.11  		//ks->writep = (ks->writep + 1) % KEYBOARD_BUFFER_SIZE;
    1.12 @@ -228,7 +227,6 @@
    1.13  			if (ks->keystate[i]) {
    1.14  				LOG_IF(kbc_debug, "KBC KEY DOWN: %d\n", i);
    1.15  				ks->buffer[ks->writep] = i;
    1.16 -				last_writep = ks->writep;
    1.17  				ks->writep = (ks->writep + 1) % KEYBOARD_BUFFER_SIZE;
    1.18  				if (ks->buflen < KEYBOARD_BUFFER_SIZE) ks->buflen++;
    1.19  				nkeys++;
     2.1 diff -r b826697f411a -r f7d78dfb45d0 src/memory.c
     2.2 --- a/src/memory.c	Wed Mar 13 00:43:25 2013 +0000
     2.3 +++ b/src/memory.c	Thu Apr 11 09:18:31 2013 +0100
     2.4 @@ -215,10 +215,10 @@
     2.5  			state.bsr1 = address & 0xffff;							\
     2.6  			LOG("Bus Error while reading, addr %08X, statcode %d", address, st);		\
     2.7  			if (state.ee) m68k_pulse_bus_error();					\
     2.8 -			if (bits == 32)											\
     2.9 +			if (bits >= 32)											\
    2.10  				return EMPTY & 0xFFFFFFFF;									\
    2.11  			else													\
    2.12 -				return EMPTY & ((1UL << bits)-1);								\
    2.13 +				return EMPTY & ((1ULL << bits)-1);								\
    2.14  		}															\
    2.15  	} while (0)
    2.16  /*}}}*/
     3.1 diff -r b826697f411a -r f7d78dfb45d0 src/wd2010.c
     3.2 --- a/src/wd2010.c	Wed Mar 13 00:43:25 2013 +0000
     3.3 +++ b/src/wd2010.c	Thu Apr 11 09:18:31 2013 +0100
     3.4 @@ -239,7 +239,7 @@
     3.5  			if (ctx->cmd_has_drq) {
     3.6  				temp = ctx->status & ~(SR_BUSY & SR_DRQ);
     3.7  				temp |= (ctx->data_pos < ctx->data_len) ? SR_DRQ : 0;
     3.8 -				LOG("\tWDFDC rd sr, has drq, pos=%lu len=%lu, sr=0x%02X", ctx->data_pos, ctx->data_len, temp);
     3.9 +				LOG("\tWDFDC rd sr, has drq, pos=%zu len=%zu, sr=0x%02X", ctx->data_pos, ctx->data_len, temp);
    3.10  			} else {
    3.11  				temp = ctx->status & ~0x80;
    3.12  			}
    3.13 @@ -379,13 +379,13 @@
    3.14  								lba = (((ctx->track * ctx->geom_heads * ctx->geom_spt) + (ctx->head * ctx->geom_spt) + ctx->sector) + i);
    3.15  								// convert LBA to byte address
    3.16  								lba *= ctx->geom_secsz;
    3.17 -								LOG("\tREAD lba = %lu", lba);
    3.18 +								LOG("\tREAD lba = %zu", lba);
    3.19  
    3.20  								// Read the sector from the file
    3.21  								fseek(ctx->disc_image, lba, SEEK_SET);
    3.22  								// TODO: check fread return value! if < secsz, BAIL! (call it a crc error or secnotfound maybe? also log to stderr)
    3.23  								ctx->data_len += fread(&ctx->data[ctx->data_len], 1, ctx->geom_secsz, ctx->disc_image);
    3.24 -								LOG("\tREAD len=%lu, pos=%lu, ssz=%d", ctx->data_len, ctx->data_pos, ctx->geom_secsz);
    3.25 +								LOG("\tREAD len=%zu, pos=%zu, ssz=%d", ctx->data_len, ctx->data_pos, ctx->geom_secsz);
    3.26  							}
    3.27  
    3.28  							ctx->status = 0;