# [PATCH] Remove useless tests

- Thread: https://externals.io/message/80883
- Original archive: https://news-web.php.net/php.internals/80883
- Started by Joshua Rogers on 2015-01-20T18:00:26+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #80883 — Joshua Rogers — 2015-01-20T18:00:26+00:00

URL: https://externals.io/message/80883#80883

Respective variables are unsigned and cannot be <0.
---
 sapi/litespeed/lsapilib.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
index 2e60701..20279d1 100644
--- a/sapi/litespeed/lsapilib.c
+++ b/sapi/litespeed/lsapilib.c
@@ -1442,16 +1442,16 @@ int LSAPI_ReqBodyGetLine_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen, in
     char * pBufCur = pBuf;
     char * pCur;
     char * p;
-    if (!pReq || (pReq->m_fd ==-1) ||( !pBuf )||(bufLen < 0 )|| !getLF )
+    if (!pReq || (pReq->m_fd ==-1) ||( !pBuf )|| !getLF )
         return -1;
     *getLF = 0;
     while( (left = pBufEnd - pBufCur ) > 0 )
     {
 
         len = pReq->m_bufRead - pReq->m_bufProcessed;
-        if ( len <= 0 )
+        if ( len = 0 )
         {
-            if ( (len = readBodyToReqBuf( pReq )) <= 0 )
+            if ( (len = readBodyToReqBuf( pReq )) = 0 )
             {
                 *getLF = 1;
                 break;
@@ -1486,7 +1486,7 @@ ssize_t LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen )
     ssize_t len;
     off_t total;
     /* char *pOldBuf = pBuf; */
-    if (!pReq || (pReq->m_fd ==-1) || ( !pBuf )||(bufLen < 0 ))
+    if (!pReq || (pReq->m_fd ==-1) || ( !pBuf ))
         return -1;
 
     total = pReq->m_reqBodyLen - pReq->m_reqBodyRead;
@@ -1517,7 +1517,7 @@ ssize_t LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen )
             pBuf += len;
             bufLen -= len;
         }
-        else if ( len <= 0 )
+        else if ( len = 0 )
         {
             if ( !total)
                 return -1;
-- 
1.9.1

---

## #80884 — Alexey Zakhlestin — 2015-01-20T18:32:52+00:00

URL: https://externals.io/message/80883#80884 · In reply to: #80883

> 
> 
> Respective variables are unsigned and cannot be <0.

Did you mean to use “==“ in comparisons?


> ---
> sapi/litespeed/lsapilib.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
> index 2e60701..20279d1 100644
> --- a/sapi/litespeed/lsapilib.c
> +++ b/sapi/litespeed/lsapilib.c
> @@ -1442,16 +1442,16 @@ int LSAPI_ReqBodyGetLine_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen, in
>     char * pBufCur = pBuf;
>     char * pCur;
>     char * p;
> -    if (!pReq || (pReq->m_fd ==-1) ||( !pBuf )||(bufLen < 0 )|| !getLF )
> +    if (!pReq || (pReq->m_fd ==-1) ||( !pBuf )|| !getLF )
>         return -1;
>     *getLF = 0;
>     while( (left = pBufEnd - pBufCur ) > 0 )
>     {
> 
>         len = pReq->m_bufRead - pReq->m_bufProcessed;
> -        if ( len <= 0 )
> +        if ( len = 0 )
>         {
> -            if ( (len = readBodyToReqBuf( pReq )) <= 0 )
> +            if ( (len = readBodyToReqBuf( pReq )) = 0 )
>             {
>                 *getLF = 1;
>                 break;
> @@ -1486,7 +1486,7 @@ ssize_t LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen )
>     ssize_t len;
>     off_t total;
>     /* char *pOldBuf = pBuf; */
> -    if (!pReq || (pReq->m_fd ==-1) || ( !pBuf )||(bufLen < 0 ))
> +    if (!pReq || (pReq->m_fd ==-1) || ( !pBuf ))
>         return -1;
> 
>     total = pReq->m_reqBodyLen - pReq->m_reqBodyRead;
> @@ -1517,7 +1517,7 @@ ssize_t LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, size_t bufLen )
>             pBuf += len;
>             bufLen -= len;
>         }
> -        else if ( len <= 0 )
> +        else if ( len = 0 )
>         {
>             if ( !total)
>                 return -1;
> --
> 1.9.1
> 
> 
> --
> 
> 
> 

--
Alexey Zakhlestin
CTO at Grids.by/you
https://github.com/indeyets
PGP key: http://indeyets.ru/alexey.zakhlestin.pgp.asc

---

## #80885 — Joshua Rogers — 2015-01-20T18:35:01+00:00

URL: https://externals.io/message/80883#80885 · In reply to: #80884

> > […]
> Did you mean to use “==“ in comparisons?
>
>
Yes.
Fixed it in the pull request:
https://github.com/MegaManSec/php-src/commit/eba0e0348e972219675e48356bd5e74dacb04522

-- 
-- Joshua Rogers <https://internot.info/
