Skip to content

Commit 314afee

Browse files
committed
btl_base_am_rdma: fix macro expansion compiler warnings
OPAL_THREAD_SCOPED_LOCK is a macro, the second argument of which is "action". If the action is more than one line long, then expanding that macro also must be something that can be expanded as a macro. Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
1 parent 87af993 commit 314afee

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

opal/mca/btl/base/btl_base_am_rdma.c

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -765,29 +765,39 @@ static int mca_btl_base_am_rdma_progress(void)
765765
return 0;
766766
}
767767

768-
OPAL_THREAD_SCOPED_LOCK(&default_module.mutex, ({
769-
mca_btl_base_rdma_operation_t *operation, *next;
770-
OPAL_LIST_FOREACH_SAFE (operation, next, &default_module.queued_responses,
771-
mca_btl_base_rdma_operation_t) {
772-
mca_btl_base_rdma_retry_operation(operation);
773-
}
774-
}));
775-
776-
OPAL_THREAD_SCOPED_LOCK(&default_module.mutex, ({
777-
mca_btl_base_am_rdma_queued_descriptor_t *descriptor, *next;
778-
OPAL_LIST_FOREACH_SAFE (descriptor, next, &default_module.queued_initiator_descriptors,
779-
mca_btl_base_am_rdma_queued_descriptor_t) {
780-
mca_btl_base_rdma_context_t *context = (mca_btl_base_rdma_context_t *)
781-
descriptor->descriptor->des_context;
782-
int ret = descriptor->btl->btl_send(descriptor->btl, descriptor->endpoint,
783-
descriptor->descriptor,
784-
mca_btl_base_rdma_tag(context->type));
785-
if (OPAL_SUCCESS == ret) {
786-
opal_list_remove_item(&default_module.queued_initiator_descriptors,
787-
&descriptor->super);
788-
}
789-
}
790-
}));
768+
// It's a little cleaner, stylistically, to make the multi-line
769+
// ACTION argument to OPAL_THREAD_SCOPED_LOCK be a macro itself
770+
// (vs. using continuation characters in the use of
771+
// OPAL_THREAD_SCOPED_LOCK).
772+
#define ACTION1 \
773+
mca_btl_base_rdma_operation_t *operation, *next; \
774+
OPAL_LIST_FOREACH_SAFE (operation, next, \
775+
&default_module.queued_responses, \
776+
mca_btl_base_rdma_operation_t) { \
777+
mca_btl_base_rdma_retry_operation(operation); \
778+
}
779+
780+
OPAL_THREAD_SCOPED_LOCK(&default_module.mutex, ACTION1);
781+
782+
#define ACTION2 \
783+
mca_btl_base_am_rdma_queued_descriptor_t *descriptor, *next; \
784+
OPAL_LIST_FOREACH_SAFE (descriptor, next, \
785+
&default_module.queued_initiator_descriptors, \
786+
mca_btl_base_am_rdma_queued_descriptor_t) { \
787+
mca_btl_base_rdma_context_t *context = \
788+
(mca_btl_base_rdma_context_t *) \
789+
descriptor->descriptor->des_context; \
790+
int ret = descriptor->btl->btl_send(descriptor->btl, \
791+
descriptor->endpoint, \
792+
descriptor->descriptor, \
793+
mca_btl_base_rdma_tag(context->type)); \
794+
if (OPAL_SUCCESS == ret) { \
795+
opal_list_remove_item(&default_module.queued_initiator_descriptors, \
796+
&descriptor->super); \
797+
} \
798+
}
799+
800+
OPAL_THREAD_SCOPED_LOCK(&default_module.mutex, ACTION2);
791801

792802
return 0;
793803
}

0 commit comments

Comments
 (0)