[wd2010] use size_t for init filesize, make disc init more verbose

Wed, 16 Jan 2013 00:34:11 +0000

author
Philip Pemberton <philpem@philpem.me.uk>
date
Wed, 16 Jan 2013 00:34:11 +0000
changeset 122
b214cf455ff2
parent 121
15ae2788e848
child 123
82755a8d276e

[wd2010] use size_t for init filesize, make disc init more verbose

src/wd2010.c file | annotate | diff | revisions
     1.1 --- a/src/wd2010.c	Tue Jan 15 17:02:56 2013 +0000
     1.2 +++ b/src/wd2010.c	Wed Jan 16 00:34:11 2013 +0000
     1.3 @@ -51,20 +51,24 @@
     1.4  
     1.5  int wd2010_init(WD2010_CTX *ctx, FILE *fp, int secsz, int spt, int heads)
     1.6  {
     1.7 -	long filesize;
     1.8 +	size_t filesize;
     1.9 +
    1.10  	wd2010_reset(ctx);
    1.11 +
    1.12  	// Start by finding out how big the image file is
    1.13  	fseek(fp, 0, SEEK_END);
    1.14  	filesize = ftell(fp);
    1.15  	fseek(fp, 0, SEEK_SET);
    1.16  
    1.17  	// Now figure out how many tracks it contains
    1.18 -	int tracks = filesize / secsz / spt / heads;
    1.19 +	unsigned int tracks = filesize / secsz / spt / heads;
    1.20  	// Confirm...
    1.21  	if (tracks < 1) {
    1.22  		return WD2010_ERR_BAD_GEOM;
    1.23  	}
    1.24  
    1.25 +	LOG("WD2010 initialised, %d cylinders, %d heads, %d sectors per track", tracks, heads, spt);
    1.26 +
    1.27  	// Allocate enough memory to store one disc track
    1.28  	if (ctx->data) {
    1.29  		free(ctx->data);
    1.30 @@ -79,8 +83,8 @@
    1.31  	ctx->geom_secsz = secsz;
    1.32  	ctx->geom_heads = heads;
    1.33  	ctx->geom_spt = spt;
    1.34 +
    1.35  	return WD2010_ERR_OK;
    1.36 -
    1.37  }
    1.38  
    1.39  void wd2010_reset(WD2010_CTX *ctx)