diff mbox

[5/7] osd_client: improve safety of osd_req_op_data() macro

Message ID 1430154795-17123-6-git-send-email-elder@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder April 27, 2015, 5:13 p.m. UTC
The osd_req_op_data() macro uses (and thus evaluates) two of its
parameters more than once.  This isn't guaranteed safe.  Define and
use some local variables to fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
---
 net/ceph/osd_client.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 6539dfc..4602442 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -120,10 +120,13 @@  static void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data,
 }
 #endif /* CONFIG_BLOCK */
 
-#define osd_req_op_data(oreq, whch, typ, fld)	\
-	({						\
-		BUG_ON(whch >= (oreq)->r_num_ops);	\
-		&(oreq)->r_ops[whch].typ.fld;		\
+#define osd_req_op_data(oreq, whch, typ, fld)				\
+	({								\
+		struct ceph_osd_request *__oreq = (oreq);		\
+		unsigned int __whch = (whch);				\
+									\
+		BUG_ON(__whch >= __oreq->r_num_ops);			\
+		&__oreq->r_ops[__whch].typ.fld;				\
 	})
 
 static struct ceph_osd_data *