aboutsummaryrefslogtreecommitdiff
path: root/sim/rl78
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-05-04 22:56:31 -0400
committerMike Frysinger <vapier@gentoo.org>2021-05-04 23:05:02 -0400
commit5318ba65f8641ddc05e330c8545f9922cd3c48d6 (patch)
treef513fded4625cf7782aebc2b3e7aa14261b987b1 /sim/rl78
parentfa94b3a7c817a5e6615b24eeb3ac569b70af7e81 (diff)
downloadfsf-binutils-gdb-5318ba65f8641ddc05e330c8545f9922cd3c48d6.zip
fsf-binutils-gdb-5318ba65f8641ddc05e330c8545f9922cd3c48d6.tar.gz
fsf-binutils-gdb-5318ba65f8641ddc05e330c8545f9922cd3c48d6.tar.bz2
sim: rl78: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port. Fix local prototypes for a bunch of functions (e.g. adding static). Add missing includes for missing prototypes. Move local variable decls from the middle of functions to the top of the scope. Fix a logic error when processing commands where p was reassigned to cmd and then has its leading whitespace scanned a 2nd time. Handle short reads with fread().
Diffstat (limited to 'sim/rl78')
-rw-r--r--sim/rl78/ChangeLog14
-rwxr-xr-xsim/rl78/configure5
-rw-r--r--sim/rl78/configure.ac1
-rw-r--r--sim/rl78/cpu.c2
-rw-r--r--sim/rl78/gdb-if.c9
-rw-r--r--sim/rl78/mem.c6
-rw-r--r--sim/rl78/mem.h2
-rw-r--r--sim/rl78/rl78.c3
-rw-r--r--sim/rl78/trace.c9
9 files changed, 34 insertions, 17 deletions
diff --git a/sim/rl78/ChangeLog b/sim/rl78/ChangeLog
index f0e1631..baaf6d8 100644
--- a/sim/rl78/ChangeLog
+++ b/sim/rl78/ChangeLog
@@ -1,5 +1,19 @@
2021-05-04 Mike Frysinger <vapier@gentoo.org>
+ * cpu.c (trace_register_init): Add missing (void).
+ * gdb-if.c (rl78_signal_to_target, handle_step): Mark static.
+ (sim_do_command): Delete redundant for loop.
+ * mem.c (mirror_rom_base, mirror_ram_base, mirror_length): Mark static.
+ * mem.h (mem_set_mirror): New prototype.
+ * rl78.c (op_flags): Move psw decl to top of scope.
+ * trace.c: Include trace.h.
+ (load_file_and_line): Move file decl to top of scope. Declare ret.
+ assign fread to ret and use to index f->data.
+ * configure.ac: Delete SIM_AC_OPTION_WARNINGS call.
+ * configure: Regenerate.
+
+2021-05-04 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-05-04 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/rl78/configure b/sim/rl78/configure
index 59cb1ec..6e20768 100755
--- a/sim/rl78/configure
+++ b/sim/rl78/configure
@@ -11844,6 +11844,7 @@ _ACEOF
+
# Check whether --enable-werror was given.
if test "${enable_werror+set}" = set; then :
enableval=$enable_werror; case "${enableval}" in
@@ -11860,6 +11861,9 @@ if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
fi
WERROR_CFLAGS=""
+ if test "${ERROR_ON_WARNING}" = yes ; then
+ WERROR_CFLAGS="-Werror"
+ fi
build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
-Wpointer-sign \
@@ -11941,7 +11945,6 @@ $as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
fi
-
hardware="cfi core pal glue "
sim_hw_cflags="-DWITH_HW=1"
sim_hw="$hardware"
diff --git a/sim/rl78/configure.ac b/sim/rl78/configure.ac
index 0e5f69c..4f2c0ac 100644
--- a/sim/rl78/configure.ac
+++ b/sim/rl78/configure.ac
@@ -22,6 +22,5 @@ AC_INIT(Makefile.in)
AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
SIM_AC_COMMON
-SIM_AC_OPTION_WARNINGS(no)
SIM_AC_OUTPUT
diff --git a/sim/rl78/cpu.c b/sim/rl78/cpu.c
index a38d6f6..fde8afe 100644
--- a/sim/rl78/cpu.c
+++ b/sim/rl78/cpu.c
@@ -51,7 +51,7 @@ typedef struct {
unsigned char h;
} RegBank;
-static void trace_register_init ();
+static void trace_register_init (void);
/* This maps PSW to a pointer into memory[] */
static RegBank *regbase_table[256];
diff --git a/sim/rl78/gdb-if.c b/sim/rl78/gdb-if.c
index 5671791..7119214 100644
--- a/sim/rl78/gdb-if.c
+++ b/sim/rl78/gdb-if.c
@@ -403,7 +403,7 @@ int siggnal;
/* Given a signal number used by the rl78 bsp (that is, newlib),
return the corresponding signal numbers. */
-int
+static int
rl78_signal_to_target (int sig)
{
switch (sig)
@@ -442,7 +442,7 @@ rl78_signal_to_target (int sig)
/* Take a step return code RC and set up the variables consulted by
sim_stop_reason appropriately. */
-void
+static void
handle_step (int rc)
{
if (RL78_STEPPED (rc) || RL78_HIT_BREAK (rc))
@@ -549,11 +549,6 @@ sim_do_command (SIM_DESC sd, const char *cmd)
while (isspace (*p))
p++;
- /* Find the extent of the command word. */
- for (p = cmd; *p; p++)
- if (isspace (*p))
- break;
-
/* Null-terminate the command word, and record the start of any
further arguments. */
if (*p)
diff --git a/sim/rl78/mem.c b/sim/rl78/mem.c
index 8527e02..77e4987 100644
--- a/sim/rl78/mem.c
+++ b/sim/rl78/mem.c
@@ -63,9 +63,9 @@ mem_rom_size (int rom_bytes)
rom_limit = rom_bytes;
}
-int mirror_rom_base = 0x01000;
-int mirror_ram_base = 0xf1000;
-int mirror_length = 0x7000;
+static int mirror_rom_base = 0x01000;
+static int mirror_ram_base = 0xf1000;
+static int mirror_length = 0x7000;
void
mem_set_mirror (int rom_base, int ram_base, int length)
diff --git a/sim/rl78/mem.h b/sim/rl78/mem.h
index f04b36a..77d2f18 100644
--- a/sim/rl78/mem.h
+++ b/sim/rl78/mem.h
@@ -29,6 +29,8 @@ extern unsigned char memory[];
void init_mem (void);
+void mem_set_mirror (int rom_base, int ram_base, int length);
+
/* Pass the amount of bytes, like 2560 for 2.5k */
void mem_ram_size (int ram_bytes);
void mem_rom_size (int rom_bytes);
diff --git a/sim/rl78/rl78.c b/sim/rl78/rl78.c
index a969845..006691c 100644
--- a/sim/rl78/rl78.c
+++ b/sim/rl78/rl78.c
@@ -249,6 +249,7 @@ static void
op_flags (int before, int after, int mask, RL78_Size size)
{
int vmask, cmask, amask, avmask;
+ int psw;
if (size == RL78_Word)
{
@@ -265,7 +266,7 @@ op_flags (int before, int after, int mask, RL78_Size size)
avmask = 0x0f;
}
- int psw = get_reg (RL78_Reg_PSW);
+ psw = get_reg (RL78_Reg_PSW);
psw &= ~mask;
if (mask & RL78_PSW_CY)
diff --git a/sim/rl78/trace.c b/sim/rl78/trace.c
index b30ec2a..6f897eb 100644
--- a/sim/rl78/trace.c
+++ b/sim/rl78/trace.c
@@ -36,6 +36,7 @@
#include "cpu.h"
#include "mem.h"
#include "load.h"
+#include "trace.h"
static disassembler_ftype rl78_disasm_fn = NULL;
@@ -138,6 +139,8 @@ load_file_and_line (const char *filename, int lineno)
int i;
struct stat s;
const char *found_filename, *slash;
+ FILE *file;
+ size_t ret;
found_filename = filename;
while (1)
@@ -155,9 +158,9 @@ load_file_and_line (const char *filename, int lineno)
files = f;
f->filename = xstrdup (filename);
f->data = (char *) xmalloc (s.st_size + 2);
- FILE *file = fopen (found_filename, "rb");
- fread (f->data, 1, s.st_size, file);
- f->data[s.st_size] = 0;
+ file = fopen (found_filename, "rb");
+ ret = fread (f->data, 1, s.st_size, file);
+ f->data[ret] = 0;
fclose (file);
f->nlines = 1;