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