Fix warnings in 1541 code

This commit is contained in:
simon.kagstrom 2010-02-08 18:40:04 +00:00
parent 5ec3b0ecd0
commit 108de6db83
2 changed files with 15 additions and 7 deletions

View File

@ -33,6 +33,7 @@
#include "Prefs.h" #include "Prefs.h"
#include "C64.h" #include "C64.h"
#include "main.h" #include "main.h"
#include "utils.hh"
#define DEBUG 0 #define DEBUG 0
#include "debug.h" #include "debug.h"
@ -217,10 +218,12 @@ uint8 ImageDrive::Open(int channel, const uint8 *name, int name_len)
} }
if (name[0] == '$') if (name[0] == '$')
{
if (channel) if (channel)
return open_file_ts(channel, DIR_TRACK, 0); return open_file_ts(channel, DIR_TRACK, 0);
else else
return open_directory(name + 1, name_len - 1); return open_directory(name + 1, name_len - 1);
}
if (name[0] == '#') if (name[0] == '#')
return open_direct(channel, name); return open_direct(channel, name);
@ -1998,7 +2001,8 @@ static bool parse_d64_file(FILE *f, image_file_desc &desc, bool has_header_id)
} else { } else {
// Read header ID from BAM (use error_info as buffer) // Read header ID from BAM (use error_info as buffer)
fseek(f, accum_num_sectors[18] * 256, SEEK_SET); fseek(f, accum_num_sectors[18] * 256, SEEK_SET);
fread(desc.error_info, 1, 256, f); if (fread(desc.error_info, 1, 256, f) != 256)
warning("Can't read all bytes\n");
desc.id1 = desc.error_info[BAM_DISK_ID]; desc.id1 = desc.error_info[BAM_DISK_ID];
desc.id2 = desc.error_info[BAM_DISK_ID + 1]; desc.id2 = desc.error_info[BAM_DISK_ID + 1];
} }
@ -2007,11 +2011,13 @@ static bool parse_d64_file(FILE *f, image_file_desc &desc, bool has_header_id)
memset(desc.error_info, 1, sizeof(desc.error_info)); memset(desc.error_info, 1, sizeof(desc.error_info));
if (size == NUM_SECTORS_35 * 257) { if (size == NUM_SECTORS_35 * 257) {
fseek(f, NUM_SECTORS_35 * 256, SEEK_SET); fseek(f, NUM_SECTORS_35 * 256, SEEK_SET);
fread(desc.error_info, NUM_SECTORS_35, 1, f); if (fread(desc.error_info, NUM_SECTORS_35, 1, f) != NUM_SECTORS_35)
warning("Can't read all sectors\n");
desc.has_error_info = true; desc.has_error_info = true;
} else if (size == NUM_SECTORS_40 * 257) { } else if (size == NUM_SECTORS_40 * 257) {
fseek(f, NUM_SECTORS_40 * 256, SEEK_SET); fseek(f, NUM_SECTORS_40 * 256, SEEK_SET);
fread(desc.error_info, NUM_SECTORS_40, 1, f); if (fread(desc.error_info, NUM_SECTORS_40, 1, f) != NUM_SECTORS_40)
warning("Can't read all sectors\n");
desc.has_error_info = true; desc.has_error_info = true;
} else } else
desc.has_error_info = false; desc.has_error_info = false;
@ -2032,7 +2038,8 @@ static bool parse_x64_file(FILE *f, image_file_desc &desc)
// Read header ID from BAM (use error_info as buffer) // Read header ID from BAM (use error_info as buffer)
fseek(f, desc.header_size + accum_num_sectors[18] * 256, SEEK_SET); fseek(f, desc.header_size + accum_num_sectors[18] * 256, SEEK_SET);
fread(desc.error_info, 1, 256, f); if (fread(desc.error_info, 1, 256, f) != 256)
warning("Can't read all bytes\n");
desc.id1 = desc.error_info[BAM_DISK_ID]; desc.id1 = desc.error_info[BAM_DISK_ID];
desc.id2 = desc.error_info[BAM_DISK_ID + 1]; desc.id2 = desc.error_info[BAM_DISK_ID + 1];
@ -2046,7 +2053,8 @@ static bool parse_image_file(FILE *f, image_file_desc &desc)
{ {
// Read header // Read header
uint8 header[64]; uint8 header[64];
fread(header, 1, sizeof(header), f); if (fread(header, 1, sizeof(header), f) != sizeof(header))
warning("Can't read all of the header\n");
// Determine file size // Determine file size
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);

View File

@ -29,8 +29,8 @@
*/ */
// Constants // Constants
const int NUM_SECTORS_35 = 683; // Number of sectors in a 35-track image const unsigned int NUM_SECTORS_35 = 683; // Number of sectors in a 35-track image
const int NUM_SECTORS_40 = 768; // Number of sectors in a 40-track image const unsigned int NUM_SECTORS_40 = 768; // Number of sectors in a 40-track image
// Disk image types // Disk image types
enum { enum {