[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 11/37] libdecnumber: Fix decNumberSetBCD
From: |
Tom Musta |
Subject: |
[Qemu-ppc] [PATCH 11/37] libdecnumber: Fix decNumberSetBCD |
Date: |
Fri, 18 Apr 2014 09:50:15 -0500 |
Fix a simple bug in the decNumberSetBCD() function. This function
encodes a decNumber with "n" BCD digits. The original code erroneously
computed the number of declets from the dn argument, which is the output
decNumber value, and hence may contain garbage. Instead, the input "n"
value is used.
Signed-off-by: Tom Musta <address@hidden>
---
libdecnumber/decNumber.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index 825fde0..c4269a4 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -3547,7 +3547,7 @@ uByte * decNumberGetBCD(const decNumber *dn, uint8_t
*bcd) {
/* and bcd[0] zero. */
/* ------------------------------------------------------------------ */
decNumber * decNumberSetBCD(decNumber *dn, const uByte *bcd, uInt n) {
- Unit *up=dn->lsu+D2U(dn->digits)-1; /* -> msu [target pointer] */
+ Unit *up = dn->lsu + D2U(n) - 1; /* -> msu [target pointer] */
const uByte *ub=bcd; /* -> source msd */
#if DECDPUN==1 /* trivial simple copy */
--
1.7.1
- [Qemu-ppc] [PATCH 00/37] target-ppc: Decimal Floating Point, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 02/37] libdecnumber: Eliminate #include *Symbols.h, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 03/37] libdecnumber: Prepare libdecnumber for QEMU include structure, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 04/37] libdecnumber: Modify dconfig.h to Integrate with QEMU, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 05/37] libdecnumber: Change gstdint.h to stdint.h, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 06/37] libdecnumber: Eliminate redundant declarations, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 07/37] libdecnumber: Eliminate Unused Variable in decSetSubnormal, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 15/37] target-ppc: Introduce DFP Helper Utilities, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 10/37] libdecnumber: Introduce decNumberIntegralToInt64, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 08/37] target-ppc: Enable Building of libdecnumber, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 11/37] libdecnumber: Fix decNumberSetBCD,
Tom Musta <=
- [Qemu-ppc] [PATCH 09/37] libdecnumber: Introduce decNumberFrom[U]Int64, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 12/37] target-ppc: Define FPR Pointer Type for Helpers, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 13/37] target-ppc: Introduce Generator Macros for DFP Arithmetic Forms, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 14/37] target-ppc: Introduce Decoder Macros for DFP, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 17/37] target-ppc: Introduce DFP Add, Tom Musta, 2014/04/18
- [Qemu-ppc] [PATCH 16/37] target-ppc: Introduce DFP Post Processor Utilities, Tom Musta, 2014/04/18