Skip to content

Commit 938f1d9

Browse files
committed
X86_64: silence some truncation warnings
There are a number of places where we truncate to a 32-bit value from a 64-bit value as we may running a 32-bit binary on 64-bits. This silences some of the warnings by explicitly truncating the integers rather than implicitly performing the operation.
1 parent 1e4aeb6 commit 938f1d9

File tree

1 file changed

+9
-9
lines changed
  • Headers/DebugServer2/Architecture/X86_64

1 file changed

+9
-9
lines changed

Headers/DebugServer2/Architecture/X86_64/CPUState.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ struct CPUState64 {
238238
gp.r14 = regs[14];
239239
gp.r15 = regs[15];
240240
gp.rip = regs[16];
241-
gp.eflags = regs[17];
242-
gp.cs = regs[18];
243-
gp.ss = regs[19];
244-
gp.ds = regs[20];
245-
gp.es = regs[21];
246-
gp.fs = regs[22];
247-
gp.gs = regs[23];
241+
gp.eflags = static_cast<uint32_t>(regs[17]);
242+
gp.cs = static_cast<uint32_t>(regs[18]);
243+
gp.ss = static_cast<uint32_t>(regs[19]);
244+
gp.ds = static_cast<uint32_t>(regs[20]);
245+
gp.es = static_cast<uint32_t>(regs[21]);
246+
gp.fs = static_cast<uint32_t>(regs[22]);
247+
gp.gs = static_cast<uint32_t>(regs[23]);
248248
}
249249

250250
public:
@@ -594,7 +594,7 @@ struct CPUState {
594594
}
595595
inline void setPC(uint64_t pc) {
596596
if (is32)
597-
state32.setPC(pc);
597+
state32.setPC(static_cast<uint32_t>(pc));
598598
else
599599
state64.setPC(pc);
600600
}
@@ -604,7 +604,7 @@ struct CPUState {
604604
}
605605
inline void setSP(uint64_t sp) {
606606
if (is32)
607-
state32.setSP(sp);
607+
state32.setSP(static_cast<uint32_t>(sp));
608608
else
609609
state64.setSP(sp);
610610
}

0 commit comments

Comments
 (0)