@@ -51,7 +51,7 @@ static int ompi_hook_base_open( mca_base_open_flag_t flags )
51
51
int ret ;
52
52
const mca_base_component_t * * static_components = ompi_hook_base_framework .framework_static_components ;
53
53
mca_base_component_list_item_t * cli = NULL ;
54
- mca_base_component_t * component = NULL ;
54
+ const mca_base_component_t * component = NULL ;
55
55
bool found = false;
56
56
57
57
additional_callback_components = OBJ_NEW (opal_list_t );
@@ -68,21 +68,22 @@ static int ompi_hook_base_open( mca_base_open_flag_t flags )
68
68
*/
69
69
if ( NULL != static_components ) {
70
70
for (int i = 0 ; NULL != static_components [i ]; ++ i ) {
71
- if ( static_components [i ]-> mca_component_flags & MCA_BASE_COMPONENT_FLAG_REQUIRED ) {
71
+ const mca_base_component_t * static_component = static_components [i ];
72
+ if ( static_component -> mca_component_flags & MCA_BASE_COMPONENT_FLAG_REQUIRED ) {
72
73
// Make sure that this component is in the list of components that
73
74
// were included in the earlier framework_components_open() call.
74
75
found = false;
75
76
OPAL_LIST_FOREACH (cli , & ompi_hook_base_framework .framework_components , mca_base_component_list_item_t ) {
76
- component = ( mca_base_component_t * ) cli -> cli_component ;
77
- if ( component == static_components [ i ] ) {
77
+ component = cli -> cli_component ;
78
+ if ( component == static_component ) {
78
79
found = true;
79
80
break ;
80
81
}
81
82
}
82
83
if ( !found ) {
83
84
opal_show_help ("help-mca-hook-base.txt" , "hook:missing-required-component" , true,
84
85
ompi_hook_base_framework .framework_name ,
85
- static_components [ i ] -> mca_component_name );
86
+ static_component -> mca_component_name );
86
87
return OPAL_ERR_NOT_SUPPORTED ;
87
88
}
88
89
}
@@ -180,18 +181,20 @@ MCA_BASE_FRAMEWORK_DECLARE(ompi, hook, "hook hooks",
180
181
* Otherwise we would need to initialize opal outside of ompi_mpi_init and possibly
181
182
* after ompi_mpi_finalize which gets messy (especially when trying to cleanup).
182
183
*/
183
- #define HOOK_CALL_COMMON_HOOK_NOT_INITIALIZED (fn_name , ...) \
184
- do { \
185
- ompi_hook_base_component_t *component; \
186
- int idx; \
187
- \
188
- for(idx = 0; NULL != mca_hook_base_static_components[idx]; ++idx ) { \
189
- component = (ompi_hook_base_component_t*)mca_hook_base_static_components[idx]; \
190
- if( NULL != component->hookm_ ## fn_name && \
191
- ompi_hook_base_ ## fn_name != component->hookm_ ## fn_name ) { \
192
- component->hookm_ ## fn_name ( __VA_ARGS__ ); \
193
- } \
194
- } \
184
+ #define HOOK_CALL_COMMON_HOOK_NOT_INITIALIZED (fn_name , ...) \
185
+ do { \
186
+ const mca_base_component_t **static_components = ompi_hook_base_framework.framework_static_components; \
187
+ \
188
+ if( NULL != static_components ) { \
189
+ for (int i = 0 ; NULL != static_components[i]; ++i) { \
190
+ const mca_base_component_t *base_component = static_components[i]; \
191
+ const ompi_hook_base_component_t *component = (const ompi_hook_base_component_t*)base_component; \
192
+ if( NULL != component->hookm_ ## fn_name && \
193
+ ompi_hook_base_ ## fn_name != component->hookm_ ## fn_name ) { \
194
+ component->hookm_ ## fn_name ( __VA_ARGS__ ); \
195
+ } \
196
+ } \
197
+ } \
195
198
} while(0)
196
199
197
200
/*
@@ -204,18 +207,19 @@ MCA_BASE_FRAMEWORK_DECLARE(ompi, hook, "hook hooks",
204
207
#define HOOK_CALL_COMMON_HOOK_INITIALIZED (fn_name , ...) \
205
208
do { \
206
209
mca_base_component_list_item_t *cli; \
207
- ompi_hook_base_component_t *component; \
208
210
\
209
211
OPAL_LIST_FOREACH(cli, &ompi_hook_base_framework.framework_components, mca_base_component_list_item_t) { \
210
- component = (ompi_hook_base_component_t*)cli->cli_component; \
212
+ const mca_base_component_t *base_component = cli->cli_component; \
213
+ const ompi_hook_base_component_t *component = (const ompi_hook_base_component_t*)base_component; \
211
214
if( NULL != component->hookm_ ## fn_name && \
212
215
ompi_hook_base_ ## fn_name != component->hookm_ ## fn_name ) { \
213
216
component->hookm_ ## fn_name ( __VA_ARGS__ ); \
214
217
} \
215
218
} \
216
219
\
217
220
OPAL_LIST_FOREACH(cli, additional_callback_components, mca_base_component_list_item_t) { \
218
- component = (ompi_hook_base_component_t*)cli->cli_component; \
221
+ const mca_base_component_t *base_component = cli->cli_component; \
222
+ const ompi_hook_base_component_t *component = (const ompi_hook_base_component_t*)base_component; \
219
223
if( NULL != component->hookm_ ## fn_name && \
220
224
ompi_hook_base_ ## fn_name != component->hookm_ ## fn_name ) { \
221
225
component->hookm_ ## fn_name ( __VA_ARGS__ ); \
0 commit comments