1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2013-09-12 13:37:11 +00:00
parent a6f1305380
commit 3f78d84661
5 changed files with 16 additions and 7 deletions

View file

@ -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;