From f5a3f799c3cc299d5d276d047b4e6a8879c35c4e Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 22 Jan 2015 05:06:45 +0000 Subject: [PATCH] [PATCH] scst_main: Suppress a checkpatch warning triggered by INIT_CACHEP{,_ALIGN} Avoid that checkpatch v3.18 reports the following warning for these two macros: WARNING: Macros with flow control statements should be avoided This patch does not change any functionality. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5985 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 70 +++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 093905358..6c40d22ea 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -2500,55 +2500,59 @@ static int __init init_scst(void) } /* Used for rarely used or read-mostly on fast path structures */ -#define INIT_CACHEP(p, s, o) do { \ - p = KMEM_CACHE(s, SCST_SLAB_FLAGS); \ - TRACE_MEM("Slab create: %s at %p size %zd", #s, p, \ +#define INIT_CACHEP(p, s) ({ \ + (p) = KMEM_CACHE(s, SCST_SLAB_FLAGS); \ + TRACE_MEM("Slab create: %s at %p size %zd", #s, (p), \ sizeof(struct s)); \ - if (p == NULL) { \ - res = -ENOMEM; \ - goto o; \ - } \ - } while (0) + (p); \ + }) /* Used for structures with fast path write access */ -#define INIT_CACHEP_ALIGN(p, s, o) do { \ - p = KMEM_CACHE(s, SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN); \ - TRACE_MEM("Slab create: %s at %p size %zd", #s, p, \ +#define INIT_CACHEP_ALIGN(p, s) ({ \ + (p) = KMEM_CACHE(s, SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN);\ + TRACE_MEM("Slab create: %s at %p size %zd", #s, (p), \ sizeof(struct s)); \ - if (p == NULL) { \ - res = -ENOMEM; \ - goto o; \ - } \ - } while (0) + (p); \ + }) - INIT_CACHEP(scst_mgmt_cachep, scst_mgmt_cmd, out_lib_exit); - INIT_CACHEP(scst_mgmt_stub_cachep, scst_mgmt_cmd_stub, - out_destroy_mgmt_cache); - INIT_CACHEP(scst_ua_cachep, scst_tgt_dev_UA, - out_destroy_mgmt_stub_cache); + res = -ENOMEM; + if (!INIT_CACHEP(scst_mgmt_cachep, scst_mgmt_cmd)) + goto out_lib_exit; + if (!INIT_CACHEP(scst_mgmt_stub_cachep, scst_mgmt_cmd_stub)) + goto out_destroy_mgmt_cache; + if (!INIT_CACHEP(scst_ua_cachep, scst_tgt_dev_UA)) + goto out_destroy_mgmt_stub_cache; { struct scst_sense { uint8_t s[SCST_SENSE_BUFFERSIZE]; }; - INIT_CACHEP(scst_sense_cachep, scst_sense, - out_destroy_ua_cache); + if (!INIT_CACHEP(scst_sense_cachep, scst_sense)) + goto out_destroy_ua_cache; } - INIT_CACHEP(scst_aen_cachep, scst_aen, out_destroy_sense_cache); /* read-mostly */ - INIT_CACHEP_ALIGN(scst_cmd_cachep, scst_cmd, out_destroy_aen_cache); + if (!INIT_CACHEP(scst_aen_cachep, scst_aen)) /* read-mostly */ + goto out_destroy_sense_cache; + if (!INIT_CACHEP_ALIGN(scst_cmd_cachep, scst_cmd)) + goto out_destroy_aen_cache; #ifdef CONFIG_SCST_MEASURE_LATENCY - INIT_CACHEP_ALIGN(scst_sess_cachep, scst_session, - out_destroy_cmd_cache); + if (!INIT_CACHEP_ALIGN(scst_sess_cachep, scst_session)) + goto out_destroy_cmd_cache; #else /* Big enough with read-mostly head and tail */ - INIT_CACHEP(scst_sess_cachep, scst_session, out_destroy_cmd_cache); + if (!INIT_CACHEP(scst_sess_cachep, scst_session)) + goto out_destroy_cmd_cache; #endif - INIT_CACHEP(scst_dev_cachep, scst_device, out_destroy_sess_cache); /* big enough */ - INIT_CACHEP(scst_tgt_cachep, scst_tgt, out_destroy_dev_cache); /* read-mostly */ + if (!INIT_CACHEP(scst_dev_cachep, scst_device)) /* big enough */ + goto out_destroy_sess_cache; + if (!INIT_CACHEP(scst_tgt_cachep, scst_tgt)) /* read-mostly */ + goto out_destroy_dev_cache; #ifdef CONFIG_SCST_MEASURE_LATENCY - INIT_CACHEP_ALIGN(scst_tgtd_cachep, scst_tgt_dev, out_destroy_tgt_cache); /* big enough */ + if (!INIT_CACHEP_ALIGN(scst_tgtd_cachep, scst_tgt_dev)) /* big enough */ + goto out_destroy_tgt_cache; #else /* Big enough with read-mostly head and tail */ - INIT_CACHEP(scst_tgtd_cachep, scst_tgt_dev, out_destroy_tgt_cache); /* big enough */ + if (!INIT_CACHEP(scst_tgtd_cachep, scst_tgt_dev)) /* big enough */ + goto out_destroy_tgt_cache; #endif - INIT_CACHEP(scst_acgd_cachep, scst_acg_dev, out_destroy_tgtd_cache); /* read-mostly */ + if (!INIT_CACHEP(scst_acgd_cachep, scst_acg_dev)) /* read-mostly */ + goto out_destroy_tgtd_cache; scst_mgmt_mempool = mempool_create(64, mempool_alloc_slab, mempool_free_slab, scst_mgmt_cachep);