summaryrefslogtreecommitdiff
path: root/ext/json
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-12 13:37:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-12 13:37:11 +0000
commit3f78d84661b61c686c9b49a51ab742fb3484b4de (patch)
tree33f4550e7a0fee96aa6a3eabf4a26bcc96c421b3 /ext/json
parenta6f13053807a121e2169c3002984ae3916ce089f (diff)
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/json')
-rw-r--r--ext/json/fbuffer/fbuffer.h2
-rw-r--r--ext/json/generator/generator.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/ext/json/fbuffer/fbuffer.h b/ext/json/fbuffer/fbuffer.h
index 24bb088..952ab30 100644
--- a/ext/json/fbuffer/fbuffer.h
+++ b/ext/json/fbuffer/fbuffer.h
@@ -67,7 +67,7 @@ static VALUE fbuffer_to_s(FBuffer *fb);
static FBuffer *fbuffer_alloc(unsigned long initial_length)
{
FBuffer *fb;
- if (initial_length <= 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
+ if (initial_length == 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
fb = ALLOC(FBuffer);
memset((void *) fb, 0, sizeof(FBuffer));
fb->initial_length = initial_length;
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 7bc1934..40c9e1e 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -288,7 +288,7 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
static char *fstrndup(const char *ptr, unsigned long len) {
char *result;
- if (len <= 0) return NULL;
+ if (len == 0) return NULL;
result = ALLOC_N(char, len);
memccpy(result, ptr, 0, len);
return result;