libdecnumber: Fix warnings from smatch (missing static, boolean operations)
PATCH 1/1 libdecnumber: Fix warnings from smatch (missing static, boolean operations)
--- libdecnumber/decNumber.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
libdecnumber/decNumber.c +11 -10
@@ -5275,8 +5275,8 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,/* 4. The working precisions for the static buffers are twice the */ /* obvious size to allow for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ -decNumber *decExpOp (decNumber *res,const decNumber *rhs, -decContext *set,uInt *status) { +static decNumber *decExpOp (decNumber *res,const decNumber *rhs, +decContext *set,uInt *status) {uInt ignore=0 ;/* working status */ Int h;/* adjusted exponent for 0.xxxx */ Int p;/* working precision */
@@ -5563,7 +5563,8 @@ decNumber * decExpOp(decNumber *res, const decNumber *rhs,/* where x is truncated (NB) into the range 10 through 99, */ /* and then c = k>>2 and e = k&3. */ /* ------------------------------------------------------------------ */ -const uShort LNnn[90 ]={9016 ,8652 ,8316 ,8008 ,7724 ,7456 ,7208 , +static const uShort LNnn[90 ] = { +9016 ,8652 ,8316 ,8008 ,7724 ,7456 ,7208 ,6972 ,6748 ,6540 ,6340 ,6148 ,5968 ,5792 ,5628 ,5464 ,5312 ,5164 ,5020 ,4884 ,4748 ,4620 ,4496 ,4376 ,4256 ,4144 ,4032 ,39233 ,38181 ,37157 ,36157 ,35181 ,34229 ,33297 ,32389 ,31501 ,30629 ,
@@ -5635,8 +5636,8 @@ const uShort LNnn[90]={9016, 8652, 8316, 8008, 7724, 7456, 7208,/* 5. The static buffers are larger than might be expected to allow */ /* for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ -decNumber *decLnOp (decNumber *res,const decNumber *rhs, -decContext *set,uInt *status) { +static decNumber *decLnOp (decNumber *res,const decNumber *rhs, +decContext *set,uInt *status) {uInt ignore=0 ;/* working status accumulator */ uInt needbytes;/* for space calculations */ Int residue;/* rounding residue */
@@ -6052,9 +6053,9 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,/* The emphasis here is on speed for common cases, and avoiding */ /* coefficient comparison if possible. */ /* ------------------------------------------------------------------ */ -decNumber *decCompareOp (decNumber *res,const decNumber *lhs, -const decNumber *rhs,decContext *set, -Flag op,uInt *status) { +static decNumber *decCompareOp (decNumber *res,const decNumber *lhs, +const decNumber *rhs,decContext *set, +Flag op,uInt *status) {#if DECSUBSET decNumber *alloclhs=NULL ;/* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL ;/* .., rhs */
@@ -6086,11 +6087,11 @@ decNumber * decCompareOp(decNumber *res, const decNumber *lhs,/* If total ordering then handle differing signs 'up front' */ if (op==COMPTOTAL ) {/* total ordering */ -if (decNumberIsNegative (lhs) & !decNumberIsNegative (rhs)) { +if (decNumberIsNegative (lhs) && !decNumberIsNegative (rhs)) { result=-1 ;break ; } -if (!decNumberIsNegative (lhs) &decNumberIsNegative (rhs)) { +if (!decNumberIsNegative (lhs) &&decNumberIsNegative (rhs)) { result=+1 ;break ; }
Signature · 1 line
1.7.10.4
Michael Tokarev
AppliedApplied to -trivial, thank you!
But I've a small concern - should we really do this on "external" sources, and divirge from upstream needlessly?
Thanks,
/mjt
Am 24.08.2014 11:21, schrieb Michael Tokarev:
Quoted 8 lines
Applied to -trivial, thank you!
But I've a small concern - should we really do this on "external" sources, and divirge from upstream needlessly?
Thanks,
/mjt
In general, I agree. In this case, the code was part of gcc, and newer versions of gcc use GPL 3 which is incompatible with QEMU, so I assume that the code in QEMU is no longer available from a maintained upstream.
Stefan
Quoted 6 lines · Stefan Weil
Am 24.08.2014 11:21, schrieb Michael Tokarev:
Quoted 5 lines
Applied to -trivial, thank you!
But I've a small concern - should we really do this on "external" sources, and divirge from upstream needlessly?
Quoted 8 lines
Quoted 3 lines
Thanks,
/mjt
In general, I agree. In this case, the code was part of gcc, and newer versions of gcc use GPL 3 which is incompatible with QEMU, so I assume that the code in QEMU is no longer available from a maintained upstream.
Upstream switched to another license != upstream is no longer maintained.
If you license your contribution under GPLv2+, both upstream and downstream should be able to use it just fine.
Have you checked the current upstream code for presence of these issues?
Quoted 6 lines · Stefan Weil
Am 24.08.2014 11:21, schrieb Michael Tokarev:
Quoted 5 lines
Applied to -trivial, thank you!
But I've a small concern - should we really do this on "external" sources, and divirge from upstream needlessly?
Quoted 10 lines
Quoted 3 lines
Thanks,
/mjt
In general, I agree. In this case, the code was part of gcc, and newer versions of gcc use GPL 3 which is incompatible with QEMU, so I assume that the code in QEMU is no longer available from a maintained upstream.
Stefan
Yes. We had to effectively fork a copy the code to deal with the license issues.
FWIW ... Alex has suggested a reformat of the libdecnumber code to make it compatible with QEMU formatting (http://lists.nongnu.org/archive/html/qemu-ppc/2014-05/msg00085.html). This is on my todo list. Obviously, such a reformat would make it even harder to synchronize with upstream gcc.