[PATCH] Core: enclosed parameters of macros in parentheses.

balus balus at foxmail.com
Fri Jul 24 23:50:22 UTC 2020


Seems more comprehensive and the commit message is more accurate
now, thank you.


------------------ Original ------------------
From:                                                                                                                        "nginx-devel"                                                                                    <ru at nginx.com>;
Date: Sat, Jul 25, 2020 03:58 AM
To: "nginx-devel"<nginx-devel at nginx.org>;

Subject: Re: [PATCH] Core: enclosed parameters of macros in parentheses.



On Sat, Jul 18, 2020 at 08:09:30PM +0800, balus wrote:
> # HG changeset patch
> # User balus <balus at foxmail.com&gt;
> # Date 1595073121 -28800
> #&nbsp; &nbsp; &nbsp; Sat Jul 18 19:52:01 2020 +0800
> # Node ID 92d9878c0c7549345f0a144cd81a6b6d45f21fc6
> # Parent&nbsp; 32a343635b50662979975e1204417bb1fc7e1b1f
> Core: enclosed parameters of macros in parentheses.

I'm going to commit the following updated patch:

# HG changeset patch
# User balus <balus at foxmail.com>
# Date 1595399139 -10800
#      Wed Jul 22 09:25:39 2020 +0300
# Node ID 827f61a45a12382773c4053e7858594c2ce611c0
# Parent  4f30f75dbdf33d6fae9e70086e0df5cbab7db027
Core: enclosed parameters of the ngx_buf.h macros in parentheses.

diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -125,20 +125,20 @@ typedef struct {
 #define NGX_CHAIN_ERROR     (ngx_chain_t *) NGX_ERROR
 
 
-#define ngx_buf_in_memory(b)        (b->temporary || b->memory || b->mmap)
-#define ngx_buf_in_memory_only(b)   (ngx_buf_in_memory(b) && !b->in_file)
+#define ngx_buf_in_memory(b)       ((b)->temporary || (b)->memory || (b)->mmap)
+#define ngx_buf_in_memory_only(b)  (ngx_buf_in_memory(b) && !(b)->in_file)
 
 #define ngx_buf_special(b)                                                   \
-    ((b->flush || b->last_buf || b->sync)                                    \
-     && !ngx_buf_in_memory(b) && !b->in_file)
+    (((b)->flush || (b)->last_buf || (b)->sync)                              \
+     && !ngx_buf_in_memory(b) && !(b)->in_file)
 
 #define ngx_buf_sync_only(b)                                                 \
-    (b->sync                                                                 \
-     && !ngx_buf_in_memory(b) && !b->in_file && !b->flush && !b->last_buf)
+    ((b)->sync && !ngx_buf_in_memory(b)                                      \
+     && !(b)->in_file && !(b)->flush && !(b)->last_buf)
 
 #define ngx_buf_size(b)                                                      \
-    (ngx_buf_in_memory(b) ? (off_t) (b->last - b->pos):                      \
-                            (b->file_last - b->file_pos))
+    (ngx_buf_in_memory(b) ? (off_t) ((b)->last - (b)->pos):                  \
+                            ((b)->file_last - (b)->file_pos))
 
 ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size);
 ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs);
@@ -149,8 +149,8 @@ ngx_chain_t *ngx_create_chain_of_bufs(ng
 
 ngx_chain_t *ngx_alloc_chain_link(ngx_pool_t *pool);
 #define ngx_free_chain(pool, cl)                                             \
-    cl->next = pool->chain;                                                  \
-    pool->chain = cl
+    (cl)->next = (pool)->chain;                                              \
+    (pool)->chain = (cl)
 
 
 
_______________________________________________
nginx-devel mailing list
nginx-devel at nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20200725/2b693fcb/attachment.htm>


More information about the nginx-devel mailing list