[nginx] Core: removed meaningless check from ngx_palloc_block().
    Maxim Dounin 
    mdounin at mdounin.ru
       
    Thu Jun 26 00:12:21 UTC 2014
    
    
  
details:   http://hg.nginx.org/nginx/rev/c45c9812cf11
branches:  
changeset: 5742:c45c9812cf11
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Jun 26 03:34:19 2014 +0400
description:
Core: removed meaningless check from ngx_palloc_block().
The check became meaningless after refactoring in 2a92804f4109.
With the loop currently in place, "current" can't be NULL, hence
the check can be dropped.
Additionally, the local variable "current" was removed to
simplify code, and pool->current now used directly instead.
Found by Coverity (CID 714236).
diffstat:
 src/core/ngx_palloc.c |  10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)
diffs (33 lines):
diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c
--- a/src/core/ngx_palloc.c
+++ b/src/core/ngx_palloc.c
@@ -181,7 +181,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_
 {
     u_char      *m;
     size_t       psize;
-    ngx_pool_t  *p, *new, *current;
+    ngx_pool_t  *p, *new;
 
     psize = (size_t) (pool->d.end - (u_char *) pool);
 
@@ -200,18 +200,14 @@ ngx_palloc_block(ngx_pool_t *pool, size_
     m = ngx_align_ptr(m, NGX_ALIGNMENT);
     new->d.last = m + size;
 
-    current = pool->current;
-
-    for (p = current; p->d.next; p = p->d.next) {
+    for (p = pool->current; p->d.next; p = p->d.next) {
         if (p->d.failed++ > 4) {
-            current = p->d.next;
+            pool->current = p->d.next;
         }
     }
 
     p->d.next = new;
 
-    pool->current = current ? current : new;
-
     return m;
 }
 
    
    
More information about the nginx-devel
mailing list