diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-12 13:37:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-09-12 13:37:11 +0000 |
commit | 3f78d84661b61c686c9b49a51ab742fb3484b4de (patch) | |
tree | 33f4550e7a0fee96aa6a3eabf4a26bcc96c421b3 /ext/bigdecimal | |
parent | a6f13053807a121e2169c3002984ae3916ce089f (diff) | |
download | ruby-3f78d84661b61c686c9b49a51ab742fb3484b4de.tar.gz |
Eliminate less-than-zero checks for unsigned variables
* ext/bigdecimal/bigdecimal.c, ext/digest/md5/md5.c,
ext/json/fbuffer/fbuffer.h, ext/json/generator/generator.c:
Eliminate less-than-zero checks for unsigned variables.
According to section 4.1.5 of C89 standard, size_t is an unsigned
type. These checks were found with 'cppcheck' static analysis tool.
[ruby-core:57117] [Feature #8890]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index d1932e7213..f00ae45c74 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -3936,7 +3936,7 @@ VpAlloc(size_t mx, const char *szVal) } nalloc = (ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */ /* units for szVal[] */ - if (mx <= 0) mx = 1; + if (mx == 0) mx = 1; nalloc = Max(nalloc, mx); mx = nalloc; vp = VpAllocReal(mx); @@ -5029,7 +5029,7 @@ VpFormatSt(char *psz, size_t fFmt) size_t ie, i, nf = 0; char ch; - if (fFmt <= 0) return; + if (fFmt == 0) return; ie = strlen(psz); for (i = 0; i < ie; ++i) { @@ -6162,12 +6162,12 @@ VpVarCheck(Real * v) { size_t i; - if (v->MaxPrec <= 0) { + if (v->MaxPrec == 0) { printf("ERROR(VpVarCheck): Illegal Max. Precision(=%"PRIuSIZE")\n", v->MaxPrec); return 1; } - if (v->Prec <= 0 || v->Prec > v->MaxPrec) { + if (v->Prec == 0 || v->Prec > v->MaxPrec) { printf("ERROR(VpVarCheck): Illegal Precision(=%"PRIuSIZE")\n", v->Prec); printf(" Max. Prec.=%"PRIuSIZE"\n", v->MaxPrec); return 2; |