1
1

misc: passing a bool to va_start() is undefined

According to clang on MacOS, passing a bool parameter -- which
undergoes default parameter promotion -- to va_start() results in
undefined behavior.  So just change these params to int and avoid the
issue.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
Этот коммит содержится в:
Jeff Squyres 2018-09-11 17:59:37 -04:00
родитель 8f2620d3af
Коммит 3970b06134
6 изменённых файлов: 34 добавлений и 22 удалений

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -32,7 +33,7 @@
static const char *path_sep = OPAL_PATH_SEP;
char *opal_os_path(bool relative, ...)
char *opal_os_path(int relative, ...)
{
va_list ap;
char *element, *path;

Просмотреть файл

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2018 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -62,8 +63,13 @@ BEGIN_C_DECLS
* provided path elements, separated by the path separator character
* appropriate to the local operating system. The path_name string has been malloc'd
* and therefore the user is responsible for free'ing the field.
*/
OPAL_DECLSPEC char *opal_os_path(bool relative, ...) __opal_attribute_malloc__ __opal_attribute_sentinel__ __opal_attribute_warn_unused_result__;
*
* Note that the "relative" argument is int instead of bool, because
* passing a parameter that undergoes default argument promotion to
* va_start() has undefined behavior (according to clang warnings on
* MacOS High Sierra).
*/
OPAL_DECLSPEC char *opal_os_path(int relative, ...) __opal_attribute_malloc__ __opal_attribute_sentinel__ __opal_attribute_warn_unused_result__;
/**
* Convert the path to be OS friendly. On UNIX this function will

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
@ -48,9 +48,9 @@ static char **search_dirs = NULL;
* Local functions
*/
static int opal_show_vhelp_internal(const char *filename, const char *topic,
bool want_error_header, va_list arglist);
int want_error_header, va_list arglist);
static int opal_show_help_internal(const char *filename, const char *topic,
bool want_error_header, ...);
int want_error_header, ...);
opal_show_help_fn_t opal_show_help = opal_show_help_internal;
opal_show_vhelp_fn_t opal_show_vhelp = opal_show_vhelp_internal;
@ -89,7 +89,7 @@ int opal_show_help_finalize(void)
* not optimization. :-)
*/
static int array2string(char **outstring,
bool want_error_header, char **lines)
int want_error_header, char **lines)
{
int i, count;
size_t len;
@ -293,7 +293,7 @@ static int load_array(char ***array, const char *filename, const char *topic)
}
char *opal_show_help_vstring(const char *filename, const char *topic,
bool want_error_header, va_list arglist)
int want_error_header, va_list arglist)
{
int rc;
char *single_string, *output, **array = NULL;
@ -317,7 +317,7 @@ char *opal_show_help_vstring(const char *filename, const char *topic,
}
char *opal_show_help_string(const char *filename, const char *topic,
bool want_error_handler, ...)
int want_error_handler, ...)
{
char *output;
va_list arglist;
@ -331,7 +331,7 @@ char *opal_show_help_string(const char *filename, const char *topic,
}
static int opal_show_vhelp_internal(const char *filename, const char *topic,
bool want_error_header, va_list arglist)
int want_error_header, va_list arglist)
{
char *output;
@ -349,7 +349,7 @@ static int opal_show_vhelp_internal(const char *filename, const char *topic,
}
static int opal_show_help_internal(const char *filename, const char *topic,
bool want_error_header, ...)
int want_error_header, ...)
{
va_list arglist;
int rc;

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -127,9 +127,14 @@ OPAL_DECLSPEC int opal_show_help_finalize(void);
* (typically $prefix/share/openmpi), and looks up the message
* based on the topic, and displays it. If want_error_header is
* true, a header and footer of asterisks are also displayed.
*
* Note that the "want_error_header" argument is int instead of bool,
* because passing a parameter that undergoes default argument
* promotion to va_start() has undefined behavior (according to clang
* warnings on MacOS High Sierra).
*/
typedef int (*opal_show_help_fn_t)(const char *filename, const char *topic,
bool want_error_header, ...);
int want_error_header, ...);
OPAL_DECLSPEC extern opal_show_help_fn_t opal_show_help;
/**
@ -137,7 +142,7 @@ OPAL_DECLSPEC extern opal_show_help_fn_t opal_show_help;
* a va_list form of varargs.
*/
typedef int (*opal_show_vhelp_fn_t)(const char *filename, const char *topic,
bool want_error_header, va_list ap);
int want_error_header, va_list ap);
OPAL_DECLSPEC extern opal_show_vhelp_fn_t opal_show_vhelp;
/**
@ -146,7 +151,7 @@ OPAL_DECLSPEC extern opal_show_vhelp_fn_t opal_show_vhelp;
*/
OPAL_DECLSPEC char* opal_show_help_string(const char *filename,
const char *topic,
bool want_error_header, ...);
int want_error_header, ...);
/**
* This function does the same thing as opal_show_help_string(), but
@ -154,7 +159,7 @@ OPAL_DECLSPEC char* opal_show_help_string(const char *filename,
*/
OPAL_DECLSPEC char* opal_show_help_vstring(const char *filename,
const char *topic,
bool want_error_header, va_list ap);
int want_error_header, va_list ap);
/**
* This function adds another search location for the files that

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
@ -591,7 +591,7 @@ void orte_show_help_finalize(void)
}
int orte_show_help(const char *filename, const char *topic,
bool want_error_header, ...)
int want_error_header, ...)
{
int rc = ORTE_SUCCESS;
va_list arglist;
@ -623,7 +623,7 @@ static void cbfunc(int status, void *cbdata)
}
int orte_show_help_norender(const char *filename, const char *topic,
bool want_error_header, const char *output)
int want_error_header, const char *output)
{
int rc = ORTE_SUCCESS;
int8_t have_output = 1;

Просмотреть файл

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved.
* $COPYRIGHT$
*
@ -78,7 +78,7 @@ ORTE_DECLSPEC void orte_show_help_finalize(void);
* (e.g., cray).
*/
ORTE_DECLSPEC int orte_show_help(const char *filename, const char *topic,
bool want_error_header, ...);
int want_error_header, ...);
/**
* Exactly the same as orte_show_help, but pass in a rendered string,
@ -86,7 +86,7 @@ ORTE_DECLSPEC int orte_show_help(const char *filename, const char *topic,
*/
ORTE_DECLSPEC int orte_show_help_norender(const char *filename,
const char *topic,
bool want_error_header,
int want_error_header,
const char *output);
/**