e9e4d2a4bc
The Open MPI code base assumed that asprintf always behaved like the FreeBSD variant, where ptr is set to NULL on error. However, the C standard (and Linux) only guarantee that the return code will be -1 on error and leave ptr undefined. Rather than fix all the usage in the code, we use opal_asprintf() wrapper instead, which guarantees the BSD-like behavior of ptr always being set to NULL. In addition to being correct, this will fix many, many warnings in the Open MPI code base. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
74 строки
1.6 KiB
C
74 строки
1.6 KiB
C
/*
|
|
* Copyright (c) 2014 Mellanox Technologies, Inc.
|
|
* All rights reserved.
|
|
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
|
|
* Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#include "oshmem_config.h"
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
|
|
#include "opal/util/printf.h"
|
|
|
|
#include "oshmem/constants.h"
|
|
#include "oshmem/util/oshmem_util.h"
|
|
|
|
void oshmem_output_verbose(int level, int output_id, const char* prefix,
|
|
const char* file, int line, const char* function, const char* format, ...)
|
|
{
|
|
va_list args;
|
|
char *buff, *str;
|
|
int ret = 0;
|
|
|
|
if (level <= opal_output_get_verbosity(output_id)) {
|
|
UNREFERENCED_PARAMETER(ret);
|
|
|
|
va_start(args, format);
|
|
|
|
ret = opal_vasprintf(&str, format, args);
|
|
assert(-1 != ret);
|
|
|
|
ret = opal_asprintf(&buff, "%s %s", prefix, str);
|
|
assert(-1 != ret);
|
|
|
|
opal_output(output_id, buff, file, line, function);
|
|
|
|
va_end(args);
|
|
|
|
free(buff);
|
|
free(str);
|
|
}
|
|
}
|
|
|
|
|
|
void oshmem_output(int output_id, const char* prefix, const char* file,
|
|
int line, const char* function, const char* format, ...)
|
|
{
|
|
va_list args;
|
|
char *buff, *str;
|
|
int ret = 0;
|
|
|
|
UNREFERENCED_PARAMETER(ret);
|
|
|
|
va_start(args, format);
|
|
|
|
ret = opal_vasprintf(&str, format, args);
|
|
assert(-1 != ret);
|
|
|
|
ret = opal_asprintf(&buff, "%s %s", prefix, str);
|
|
assert(-1 != ret);
|
|
|
|
opal_output(output_id, buff, file, line, function);
|
|
|
|
va_end(args);
|
|
|
|
free(buff);
|
|
free(str);
|
|
}
|