* [PATCH] ib_srp: Let compiler ignore the useless debug code
@ 2017-02-24 8:44 Minfei Huang
2017-02-24 16:16 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Minfei Huang @ 2017-02-24 8:44 UTC (permalink / raw)
To: bart.vanassche, dledford, sean.hefty, hal.rosenstock
Cc: linux-rdma, linux-kernel, Minfei Huang
"if (0)" is used to make this block of debug code not be executed. There
is a more elegant way to let compiler ignore this code, using
"#if 0 .. #endif" instead.
Although it may be optimised by some compilers with specified parameter,
just for readable.
Signed-off-by: Minfei Huang <mnghuan@gmail.com>
---
drivers/infiniband/ulp/srp/ib_srp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 36529e3..f2d7821 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2023,12 +2023,12 @@ static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc)
opcode = *(u8 *) iu->buf;
- if (0) {
- shost_printk(KERN_ERR, target->scsi_host,
- PFX "recv completion, opcode 0x%02x\n", opcode);
- print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 8, 1,
- iu->buf, wc->byte_len, true);
- }
+#if 0
+ shost_printk(KERN_ERR, target->scsi_host,
+ PFX "recv completion, opcode 0x%02x\n", opcode);
+ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 8, 1,
+ iu->buf, wc->byte_len, true);
+#endif
switch (opcode) {
case SRP_RSP:
--
2.10.1 (Apple Git-78)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ib_srp: Let compiler ignore the useless debug code
2017-02-24 8:44 [PATCH] ib_srp: Let compiler ignore the useless debug code Minfei Huang
@ 2017-02-24 16:16 ` Bart Van Assche
2017-03-05 8:22 ` Leon Romanovsky
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2017-02-24 16:16 UTC (permalink / raw)
To: hal.rosenstock, mnghuan, dledford, sean.hefty; +Cc: linux-kernel, linux-rdma
On Fri, 2017-02-24 at 16:44 +0800, Minfei Huang wrote:
> "if (0)" is used to make this block of debug code not be executed. There
> is a more elegant way to let compiler ignore this code, using
> "#if 0 .. #endif" instead.
>
> Although it may be optimised by some compilers with specified parameter,
> just for readable.
#if 0 / #endif prevents the compiler from checking the syntax of the code.
Such code tends to grow syntax errors. So I'm not sure this patch is an
improvement.
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ib_srp: Let compiler ignore the useless debug code
2017-02-24 16:16 ` Bart Van Assche
@ 2017-03-05 8:22 ` Leon Romanovsky
0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2017-03-05 8:22 UTC (permalink / raw)
To: Bart Van Assche
Cc: hal.rosenstock, mnghuan, dledford, sean.hefty, linux-kernel, linux-rdma
[-- Attachment #1: Type: text/plain, Size: 692 bytes --]
On Fri, Feb 24, 2017 at 04:16:31PM +0000, Bart Van Assche wrote:
> On Fri, 2017-02-24 at 16:44 +0800, Minfei Huang wrote:
> > "if (0)" is used to make this block of debug code not be executed. There
> > is a more elegant way to let compiler ignore this code, using
> > "#if 0 .. #endif" instead.
> >
> > Although it may be optimised by some compilers with specified parameter,
> > just for readable.
>
> #if 0 / #endif prevents the compiler from checking the syntax of the code.
> Such code tends to grow syntax errors. So I'm not sure this patch is an
> improvement.
Agree and especially without support of bloat-o-meter, all these talks
about dumb compiler are not informative.
>
> Bart.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-05 8:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-24 8:44 [PATCH] ib_srp: Let compiler ignore the useless debug code Minfei Huang
2017-02-24 16:16 ` Bart Van Assche
2017-03-05 8:22 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).