Skip to content

Commit 7931d87

Browse files
committed
Add "const" qualifiers to some string print APIs
We frequently pass "const" values to functions, and this generates warnings when passing those values to print them. No need for that, nor for having to cast the "const" away - the print functions never alter the provided value. Signed-off-by: Ralph Castain <[email protected]>
1 parent 534cf08 commit 7931d87

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

include/pmix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,16 +1133,16 @@ PMIX_EXPORT const char* PMIx_Data_type_string(pmix_data_type_t type);
11331133
PMIX_EXPORT const char* PMIx_Alloc_directive_string(pmix_alloc_directive_t directive);
11341134
PMIX_EXPORT const char* PMIx_IOF_channel_string(pmix_iof_channel_t channel);
11351135
PMIX_EXPORT const char* PMIx_Job_state_string(pmix_job_state_t state);
1136-
PMIX_EXPORT const char* PMIx_Get_attribute_string(char *attribute);
1137-
PMIX_EXPORT const char* PMIx_Get_attribute_name(char *attrstring);
1136+
PMIX_EXPORT const char* PMIx_Get_attribute_string(const char *attribute);
1137+
PMIX_EXPORT const char* PMIx_Get_attribute_name(const char *attrstring);
11381138
PMIX_EXPORT const char* PMIx_Link_state_string(pmix_link_state_t state);
11391139
PMIX_EXPORT const char* PMIx_Device_type_string(pmix_device_type_t type);
11401140
PMIX_EXPORT const char* PMIx_Value_comparison_string(pmix_value_cmp_t cmp);
11411141

11421142
/* the following print statements return ALLOCATED strings
11431143
* that the user must release when done */
1144-
PMIX_EXPORT char* PMIx_Info_string(pmix_info_t *info);
1145-
PMIX_EXPORT char* PMIx_Value_string(pmix_value_t *value);
1144+
PMIX_EXPORT char* PMIx_Info_string(const pmix_info_t *info);
1145+
PMIX_EXPORT char* PMIx_Value_string(const pmix_value_t *value);
11461146
PMIX_EXPORT char* PMIx_Info_directives_string(pmix_info_directives_t directives);
11471147

11481148
/* Get the PMIx version string. Note that the provided string is

src/common/pmix_attributes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ PMIX_EXPORT void pmix_attrs_query_support(int sd, short args, void *cbdata)
847847
}
848848

849849
/***** LOCATE A GIVEN ATTRIBUTE *****/
850-
PMIX_EXPORT const char *pmix_attributes_lookup(char *attr)
850+
PMIX_EXPORT const char *pmix_attributes_lookup(const char *attr)
851851
{
852852
size_t n;
853853

@@ -859,7 +859,7 @@ PMIX_EXPORT const char *pmix_attributes_lookup(char *attr)
859859
return NULL;
860860
}
861861

862-
PMIX_EXPORT const char *pmix_attributes_reverse_lookup(char *attrstring)
862+
PMIX_EXPORT const char *pmix_attributes_reverse_lookup(const char *attrstring)
863863
{
864864
size_t n;
865865

src/common/pmix_attributes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
1818
* Copyright (c) 2018 Research Organization for Information Science
1919
* and Technology (RIST). All rights reserved.
20-
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
20+
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
2121
* $COPYRIGHT$
2222
*
2323
* Additional copyrights may follow
@@ -67,8 +67,8 @@ PMIX_EXPORT void pmix_attributes_print_attrs(char ***ans, char *function, pmix_r
6767
PMIX_EXPORT void pmix_attributes_print_headers(char ***ans, char *level);
6868

6969
PMIX_EXPORT void pmix_attrs_query_support(int sd, short args, void *cbdata);
70-
PMIX_EXPORT const char *pmix_attributes_lookup(char *name);
71-
PMIX_EXPORT const char *pmix_attributes_reverse_lookup(char *name);
70+
PMIX_EXPORT const char *pmix_attributes_lookup(const char *name);
71+
PMIX_EXPORT const char *pmix_attributes_reverse_lookup(const char *name);
7272
PMIX_EXPORT const pmix_regattr_input_t *pmix_attributes_lookup_term(char *attr);
7373

7474
END_C_DECLS

src/common/pmix_strings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ PMIX_EXPORT const char *PMIx_Job_state_string(pmix_job_state_t state)
329329
}
330330
}
331331

332-
PMIX_EXPORT const char *PMIx_Get_attribute_string(char *attribute)
332+
PMIX_EXPORT const char *PMIx_Get_attribute_string(const char *attribute)
333333
{
334334
return pmix_attributes_lookup(attribute);
335335
}
336336

337-
PMIX_EXPORT const char *PMIx_Get_attribute_name(char *attrstring)
337+
PMIX_EXPORT const char *PMIx_Get_attribute_name(const char *attrstring)
338338
{
339339
return pmix_attributes_reverse_lookup(attrstring);
340340
}

src/mca/bfrops/base/bfrop_base_print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "src/util/pmix_name_fns.h"
4040
#include "src/util/pmix_printf.h"
4141

42-
char* PMIx_Info_string(pmix_info_t *info)
42+
char* PMIx_Info_string(const pmix_info_t *info)
4343
{
4444
pmix_status_t rc;
4545
char *output = NULL;
@@ -53,7 +53,7 @@ char* PMIx_Info_string(pmix_info_t *info)
5353
return output;
5454
}
5555

56-
char* PMIx_Value_string(pmix_value_t *value)
56+
char* PMIx_Value_string(const pmix_value_t *value)
5757
{
5858
pmix_status_t rc;
5959
char *output = NULL;

0 commit comments

Comments
 (0)