From 202a5e3724180431de4747a7febf55f02c8865b0 Mon Sep 17 00:00:00 2001
From: Anton Ovchinnikov <revolver112@gmail.com>
Date: Wed, 11 Sep 2013 00:52:30 +0400
Subject: [PATCH] Eliminate less-than-zero checks for unsigned variables

---
 ext/bigdecimal/bigdecimal.c    | 8 ++++----
 ext/digest/md5/md5.c           | 2 +-
 ext/json/fbuffer/fbuffer.h     | 2 +-
 ext/json/generator/generator.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index d1932e7..f00ae45 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;
diff --git a/ext/digest/md5/md5.c b/ext/digest/md5/md5.c
index 518f823..8d7d33c 100644
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -368,7 +368,7 @@ MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
     size_t offset = (pms->count[0] >> 3) & 63;
     uint32_t nbits = (uint32_t)(nbytes << 3);
 
-    if (nbytes <= 0)
+    if (nbytes == 0)
 	return;
 
     /* Update the message length. */
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;
-- 
1.8.3.1

