fixed problems found by cppcheck tool (patch by Maxim Derbasov)
This commit is contained in:
parent
c7c92bb62b
commit
1f4d3e7194
@ -316,6 +316,7 @@ int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
dbg_printf("%s:%d: missing symbol name\n", file.name, line_num);
|
||||
else
|
||||
dbg_printf("%s:%d: syntax error near '%s'\n", file.name, line_num, sym_name);
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
++sym_name;
|
||||
@ -333,6 +334,7 @@ int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset)
|
||||
}
|
||||
++line_num;
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1096,8 +1096,8 @@ bx_bool vvfat_image_t::read_sector_from_file(const char *path, Bit8u *buffer, Bi
|
||||
return 0;
|
||||
int offset = sector * 0x200;
|
||||
if (::lseek(fd, offset, SEEK_SET) != offset) {
|
||||
return 0;
|
||||
::close(fd);
|
||||
return 0;
|
||||
}
|
||||
int result = ::read(fd, buffer, 0x200);
|
||||
::close(fd);
|
||||
@ -1448,7 +1448,7 @@ bx_bool vvfat_image_t::write_file(const char *path, direntry_t *entry, bx_bool c
|
||||
int fd;
|
||||
Bit32u csize, fsize, fstart, cur, next, rsvd_clusters, bad_cluster;
|
||||
Bit64u offset;
|
||||
Bit8u *buffer;
|
||||
Bit8u *buffer = NULL;
|
||||
#ifndef WIN32
|
||||
struct tm tv;
|
||||
struct utimbuf ut;
|
||||
@ -1553,7 +1553,8 @@ bx_bool vvfat_image_t::write_file(const char *path, direntry_t *entry, bx_bool c
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(buffer)
|
||||
free(buffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -798,6 +798,7 @@ int tftp_send_data(Bit8u *buffer, unsigned block_nr, tftp_session_t *s)
|
||||
}
|
||||
|
||||
if (fseek(fp, (block_nr - 1) * s->blksize_val, SEEK_SET) < 0) {
|
||||
fclose(fp);
|
||||
return tftp_send_error(buffer, 3, "Block not seekable", s);
|
||||
}
|
||||
|
||||
@ -991,6 +992,7 @@ int process_tftp(bx_devmodel_c *netdev, const Bit8u *data, unsigned data_len, Bi
|
||||
return tftp_send_error(reply, 2, "Access violation", s);
|
||||
}
|
||||
if (fseek(fp, (block_nr - 1) * TFTP_BUFFER_SIZE, SEEK_SET) < 0) {
|
||||
fclose(fp);
|
||||
return tftp_send_error(reply, 3, "Block not seekable", s);
|
||||
}
|
||||
fwrite(reply, 1, tftp_len, fp);
|
||||
|
@ -3721,9 +3721,13 @@ bx_bool bx_sb16_buffer::puts(const char *data, ...)
|
||||
while (string[index] != 0)
|
||||
{
|
||||
if (put((Bit8u) string[index]) == 0)
|
||||
return 0; // buffer full
|
||||
{
|
||||
free(string);
|
||||
return 0; // buffer full
|
||||
}
|
||||
index++;
|
||||
}
|
||||
free(string);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ void bx_load32bitOSimagehack(void)
|
||||
}
|
||||
if (feof(fp)) break;
|
||||
}
|
||||
fclose(fp);
|
||||
} //if iolog file to load
|
||||
|
||||
// Invoke proper hack depending on which OS image we're loading
|
||||
|
@ -84,7 +84,7 @@ void iofunctions::remove_logfn(logfunc_t *fn)
|
||||
{
|
||||
assert(n_logfn > 0);
|
||||
int i = 0;
|
||||
while ((fn != logfn_list[i]) && (i < n_logfn)) {
|
||||
while ((i < n_logfn) && (fn != logfn_list[i])) {
|
||||
i++;
|
||||
};
|
||||
if (i < n_logfn) {
|
||||
@ -434,6 +434,7 @@ void logfunctions::panic(const char *fmt, ...)
|
||||
if (onoff[LOGLEV_PANIC] == ACT_FATAL) {
|
||||
va_start(ap, fmt);
|
||||
fatal(prefix, fmt, ap, 1);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ memmove (dest, src, size)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
else if (dest > src)
|
||||
for (i = size -1; i >= 0; --i)
|
||||
for (i = size -1; i < size; --i)
|
||||
{
|
||||
dest[i] = src[i];
|
||||
}
|
||||
|
@ -514,8 +514,7 @@ void create_sparse_image(const char *filename, Bit64u size)
|
||||
|
||||
Bit8u *padding = new Bit8u[padtopagesize];
|
||||
memset(padding, 0, padtopagesize);
|
||||
if (padding == NULL)
|
||||
fatal("ERROR: The disk image is not complete - could not create padding!");
|
||||
|
||||
if (bx_write_image(fd, sizesofar, padding, padtopagesize) != padtopagesize) {
|
||||
close(fd);
|
||||
fatal("ERROR: The disk image is not complete - could not write padding!");
|
||||
|
@ -50,8 +50,8 @@
|
||||
|
||||
int infd, outfd;
|
||||
|
||||
unsigned int delay = 60; // default delay, in seconds
|
||||
unsigned int count_down = 0;
|
||||
int delay = 60; // default delay, in seconds
|
||||
int count_down = 0;
|
||||
|
||||
char buffer[BUF_SIZE];
|
||||
ssize_t readcnt, writecnt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user