Fix splint warnings

This commit is contained in:
Hugo Villeneuve 2014-02-13 00:52:19 -05:00
parent e417485aaf
commit c91e69d435
7 changed files with 29 additions and 27 deletions

View File

@ -33,7 +33,7 @@ main(int argc, char **argv)
if (options.filename != NULL) {
rc = hexfile_load(options.filename);
if (!rc)
exit(1);
exit(EXIT_FAILURE);
}
console_reset();
@ -44,8 +44,8 @@ main(int argc, char **argv)
} else {
menu_display_usage();
console_show_registers();
yyparse();
(void) yyparse();
}
return 0;
exit(EXIT_SUCCESS);
}

View File

@ -58,6 +58,7 @@ menu_get_input(char *buf, ssize_t size)
if ((int) strlen(line) > max_len) {
printf("input line too long");
free(line);
return YY_NULL;
}
@ -189,7 +190,7 @@ console_exec(int num)
log_info("Program executing...");
cpu8051_run(num, kbhit);
(void) cpu8051_run(num, kbhit);
if (kbhit()) {
(void) getch(); /* Flush key */
@ -205,7 +206,7 @@ console_exec(int num)
void
console_trace(void)
{
cpu8051_exec();
(void) cpu8051_exec();
console_show_registers();
disassemble_num(cpu8051.pc, 1);
}

View File

@ -49,7 +49,7 @@ log_debug(const char *format, ...)
log_prefix_package_name(stream, "debug");
va_start(ap, format);
vfprintf(stream, format, ap);
(void) vfprintf(stream, format, ap);
va_end(ap);
log_suffix_newline(stream);
@ -67,7 +67,7 @@ log_info(const char *format, ...)
log_prefix_package_name(stream, "info");
va_start(ap, format);
vfprintf(stream, format, ap);
(void) vfprintf(stream, format, ap);
va_end(ap);
log_suffix_newline(stream);
@ -85,7 +85,7 @@ log_warn(const char *format, ...)
log_prefix_package_name(stream, "warn");
va_start(ap, format);
vfprintf(stream, format, ap);
(void) vfprintf(stream, format, ap);
va_end(ap);
log_suffix_newline(stream);
@ -101,7 +101,7 @@ log_err(const char *format, ...)
log_prefix_package_name(stream, "error");
va_start(ap, format);
vfprintf(stream, format, ap);
(void) vfprintf(stream, format, ap);
va_end(ap);
log_suffix_newline(stream);
@ -117,7 +117,7 @@ log_fail(const char *format, ...)
log_prefix_package_name(stream, "error");
va_start(ap, format);
vfprintf(stream, format, ap);
(void) vfprintf(stream, format, ap);
va_end(ap);
log_suffix_newline(stream);

View File

@ -50,14 +50,12 @@ mem_init(void)
m = &mem_infos[k];
if (m->size > m->max_size) {
log_err("Memory size invalid (max = %d)", m->max_size);
exit(1);
log_fail("Memory size invalid (max = %d)", m->max_size);
}
m->buf = malloc(m->size);
if (m->buf == NULL) {
log_err("%s", strerror(errno));
exit(1);
log_fail("%s", strerror(errno));
}
memset(m->buf, 0x00, m->size);
@ -319,13 +317,13 @@ mem_dump(unsigned int address, int size, enum mem_id_t id)
return;
for (offset = 0; offset < size; offset += 16) {
unsigned char data[16];
uint8_t data[16];
printf("%.4X ", address + offset);
for (col = 0; col < 16; col++) {
data[col] = mem_read8(id, address + offset + col);
printf(" %.2X", (int) data[col]);
printf(" %.2X", data[col]);
}
printf(" ");
@ -333,7 +331,7 @@ mem_dump(unsigned int address, int size, enum mem_id_t id)
for (col = 0; col < 16; col++) {
if ((int) data[col] >= 32 &&
(int) data[col] <= 126)
printf("%c", data[col]);
printf("%c", (char) data[col]);
else
printf(".");
}

View File

@ -10,7 +10,6 @@
# include "config.h"
#endif
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <argp.h>
@ -59,7 +58,7 @@ decode_debug_option(char *arg, struct argp_state *state)
char *endptr;
int log_level;
log_level = strtol(arg, &endptr, 0);
log_level = (int) strtol(arg, &endptr, 0);
if (*endptr != '\0') {
log_err("Invalid log level");
@ -87,13 +86,13 @@ decode_memory_size(char *arg, struct argp_state *state, int memid)
else if (memid == EXT_MEM_ID)
dest = &options.xram_size;
else
exit(1); /* Programming error. */
exit(EXIT_FAILURE); /* Programming error. */
/*
* Sizes versus max memory sizes will be checked when calling
* memory_init().
*/
*dest = strtol(arg, &endptr, 0);
*dest = (int) strtol(arg, &endptr, 0);
if (*endptr != '\0') {
log_err("Invalid memory size");
@ -106,7 +105,7 @@ decode_address(char *arg, struct argp_state *state, uint16_t *dest)
{
char *endptr;
*dest = strtol(arg, &endptr, 0);
*dest = (uint16_t) strtol(arg, &endptr, 0);
if (*endptr != '\0') {
log_err("Invalid address");
@ -163,6 +162,8 @@ static struct argp argp = {argp_options, parse_opt, args_doc, str_doc,
void
parse_command_line_options(int argc, char *argv[])
{
error_t rc;
/* Setting default values. */
options.filename = NULL;
options.pram_size = PGM_MEM_DEFAULT_SIZE;
@ -172,5 +173,7 @@ parse_command_line_options(int argc, char *argv[])
options.stop_address = 0; /* 0 means stop address is disabled. */
/* Parse our arguments. */
argp_parse(&argp, argc, argv, 0, 0, NULL);
rc = argp_parse(&argp, argc, argv, 0, 0, NULL);
if (rc != 0)
log_fail("Failure to parse command line arguments");
}

View File

@ -12,13 +12,13 @@
/* Returns 0 or 1 */
int
psw_read_bit(int bit)
psw_read_bit(unsigned int bit)
{
return (mem_read8(INT_MEM_ID, _PSW_) >> bit) & 0x01;
}
void
psw_write_bit(int bit, int val)
psw_write_bit(unsigned int bit, int val)
{
uint8_t psw = mem_read8(INT_MEM_ID, _PSW_);

View File

@ -10,10 +10,10 @@
#define PSW_H 1
int
psw_read_bit(int bit);
psw_read_bit(unsigned int bit);
void
psw_write_bit(int bit, int val);
psw_write_bit(unsigned int bit, int val);
int
psw_read_cy(void);