public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: frv: fix cmpb uninitialized variable usage
@ 2023-12-24 10:24 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2023-12-24 10:24 UTC (permalink / raw)
  To: gdb-patches

This code sets up the cc variable based on the comparison of other
registers, but it does so incrementally with bit operations, and it
never initializes the cc variable.  Initialize it to 0 which the
cmpba insn is already doing.
---
 cpu/frv.cpu   | 1 +
 sim/frv/sem.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/cpu/frv.cpu b/cpu/frv.cpu
index cdb169eddc1c..d2fe7c602cc3 100644
--- a/cpu/frv.cpu
+++ b/cpu/frv.cpu
@@ -4266,6 +4266,7 @@
      "cmpb$pack $GRi,$GRj,$ICCi_1"
      (+ pack (GRk-null) OP_00 GRi ICCi_1 OPE2_0C GRj)
      (sequence ((QI cc))
+	       (set cc 0)
 	       (set-n cc (eq (and GRi #xff000000) (and GRj #xff000000)))
 	       (set-z cc (eq (and GRi #x00ff0000) (and GRj #x00ff0000)))
 	       (set-v cc (eq (and GRi #x0000ff00) (and GRj #x0000ff00)))
diff --git a/sim/frv/sem.c b/sim/frv/sem.c
index 20ac47be7642..cf47aff7c39b 100644
--- a/sim/frv/sem.c
+++ b/sim/frv/sem.c
@@ -3055,6 +3055,7 @@ SEM_FN_NAME (frvbf,cmpb) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
 
 {
   QI tmp_cc;
+  tmp_cc = 0;
 if (EQBI (EQSI (ANDSI (GET_H_GR (FLD (f_GRi)), 0xff000000), ANDSI (GET_H_GR (FLD (f_GRj)), 0xff000000)), 0)) {
   tmp_cc = ANDQI (tmp_cc, 7);
 } else {
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-24 10:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-24 10:24 [PATCH] sim: frv: fix cmpb uninitialized variable usage Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).