replace stdarg.h with cstdarg

The former was deprecated in C++14. The Standard says they are the same: The contents of the header<cstdarg>are the same as the C standard library header<stdarg.h>, with the following changes: The restrictions that ISO C places on the second parameter to the va_start macro in header<stdarg.h> are different in this International Standard. The parameter parmN is the rightmost parameter in the variable parameter list of the function definition (the one just before the...).219If the parameter parmN is a pack expansion (17.5.3) or an entity resulting from a lambda capture (8.1.5), the program is ill-formed, no diagnostic required. If the parameter parmN is of a reference type, or of a type that is not compatible with the type that results when passing an argument for which there is no parameter, the behavior is undefined. Also changed va_list to the std:: namespace version, which is the same. Signed-off-by: 's avatarRosen Penev <rosenp@gmail.com>
parent 69a51e12
......@@ -30,7 +30,7 @@ static constexpr Domain exception_domain("exception");
void
LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, va_list ap) noexcept
const char *fmt, std::va_list ap) noexcept
{
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, ap);
......@@ -40,7 +40,7 @@ LogFormatV(LogLevel level, const Domain &domain,
void
LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(level, domain, fmt, ap);
va_end(ap);
......@@ -49,7 +49,7 @@ LogFormat(LogLevel level, const Domain &domain, const char *fmt, ...) noexcept
void
FormatDebug(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::DEBUG, domain, fmt, ap);
va_end(ap);
......@@ -58,7 +58,7 @@ FormatDebug(const Domain &domain, const char *fmt, ...) noexcept
void
FormatInfo(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::INFO, domain, fmt, ap);
va_end(ap);
......@@ -67,7 +67,7 @@ FormatInfo(const Domain &domain, const char *fmt, ...) noexcept
void
FormatDefault(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::DEFAULT, domain, fmt, ap);
va_end(ap);
......@@ -76,7 +76,7 @@ FormatDefault(const Domain &domain, const char *fmt, ...) noexcept
void
FormatWarning(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::WARNING, domain, fmt, ap);
va_end(ap);
......@@ -85,7 +85,7 @@ FormatWarning(const Domain &domain, const char *fmt, ...) noexcept
void
FormatError(const Domain &domain, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::ERROR, domain, fmt, ap);
va_end(ap);
......@@ -107,7 +107,7 @@ void
LogFormat(LogLevel level, const std::exception &e, const char *fmt, ...) noexcept
{
char msg[1024];
va_list ap;
std::va_list ap;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
......@@ -132,7 +132,7 @@ void
LogFormat(LogLevel level, const std::exception_ptr &ep, const char *fmt, ...) noexcept
{
char msg[1024];
va_list ap;
std::va_list ap;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
......@@ -153,7 +153,7 @@ LogErrno(const Domain &domain, const char *msg) noexcept
}
static void
FormatErrnoV(const Domain &domain, int e, const char *fmt, va_list ap) noexcept
FormatErrnoV(const Domain &domain, int e, const char *fmt, std::va_list ap) noexcept
{
char msg[1024];
vsnprintf(msg, sizeof(msg), fmt, ap);
......@@ -164,7 +164,7 @@ FormatErrnoV(const Domain &domain, int e, const char *fmt, va_list ap) noexcept
void
FormatErrno(const Domain &domain, int e, const char *fmt, ...) noexcept
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
FormatErrnoV(domain, e, fmt, ap);
va_end(ap);
......@@ -175,7 +175,7 @@ FormatErrno(const Domain &domain, const char *fmt, ...) noexcept
{
const int e = errno;
va_list ap;
std::va_list ap;
va_start(ap, fmt);
FormatErrnoV(domain, e, fmt, ap);
va_end(ap);
......
......@@ -22,10 +22,10 @@
#include "Log.hxx" // IWYU pragma: export
#include <stdarg.h>
#include <cstdarg>
void
LogFormatV(LogLevel level, const Domain &domain,
const char *fmt, va_list ap) noexcept;
const char *fmt, std::va_list ap) noexcept;
#endif /* LOG_H */
......@@ -36,7 +36,7 @@ LogListener::OnLog(JNIEnv *env, int priority,
assert(method);
va_list args;
std::va_list args;
va_start(args, fmt);
const auto log = FormatStringV(fmt, args);
va_end(args);
......
......@@ -41,7 +41,7 @@ Response::Write(const char *data) noexcept
}
bool
Response::FormatV(const char *fmt, va_list args) noexcept
Response::FormatV(const char *fmt, std::va_list args) noexcept
{
return Write(FormatStringV(fmt, args).c_str());
}
......@@ -49,7 +49,7 @@ Response::FormatV(const char *fmt, va_list args) noexcept
bool
Response::Format(const char *fmt, ...) noexcept
{
va_list args;
std::va_list args;
va_start(args, fmt);
bool success = FormatV(fmt, args);
va_end(args);
......@@ -78,7 +78,7 @@ Response::FormatError(enum ack code, const char *fmt, ...) noexcept
Format("ACK [%i@%u] {%s} ",
(int)code, list_index, command);
va_list args;
std::va_list args;
va_start(args, fmt);
FormatV(fmt, args);
va_end(args);
......
......@@ -23,8 +23,9 @@
#include "protocol/Ack.hxx"
#include "util/Compiler.h"
#include <cstdarg>
#include <stddef.h>
#include <stdarg.h>
template<typename T> struct ConstBuffer;
class Client;
......@@ -74,7 +75,7 @@ public:
bool Write(const void *data, size_t length) noexcept;
bool Write(const char *data) noexcept;
bool FormatV(const char *fmt, va_list args) noexcept;
bool FormatV(const char *fmt, std::va_list args) noexcept;
bool Format(const char *fmt, ...) noexcept;
static constexpr size_t MAX_BINARY_SIZE = 8192;
......
......@@ -30,7 +30,8 @@
#include "BufferedOutputStream.hxx"
#include "OutputStream.hxx"
#include <stdarg.h>
#include <cstdarg>
#include <string.h>
#include <stdio.h>
......@@ -85,7 +86,7 @@ BufferedOutputStream::Format(const char *fmt, ...)
}
/* format into the buffer */
va_list ap;
std::va_list ap;
va_start(ap, fmt);
size_t size = vsnprintf(r.data, r.size, fmt, ap);
va_end(ap);
......
......@@ -47,7 +47,7 @@ FfmpegImportLogLevel(int level) noexcept
}
void
FfmpegLogCallback(gcc_unused void *ptr, int level, const char *fmt, va_list vl)
FfmpegLogCallback(gcc_unused void *ptr, int level, const char *fmt, std::va_list vl)
{
const AVClass * cls = nullptr;
......
......@@ -20,9 +20,9 @@
#ifndef MPD_FFMPEG_LOG_CALLBACK_HXX
#define MPD_FFMPEG_LOG_CALLBACK_HXX
#include <stdarg.h>
#include <cstdarg>
void
FfmpegLogCallback(void *ptr, int level, const char *fmt, va_list vl);
FfmpegLogCallback(void *ptr, int level, const char *fmt, std::va_list vl);
#endif
......@@ -21,8 +21,9 @@
#include "util/Domain.hxx"
#include "LogV.hxx"
#include <cstdarg>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -52,7 +53,7 @@ FatalError(const char *msg)
void
FormatFatalError(const char *fmt, ...)
{
va_list ap;
std::va_list ap;
va_start(ap, fmt);
LogFormatV(LogLevel::ERROR, fatal_error_domain, fmt, ap);
va_end(ap);
......@@ -91,7 +92,7 @@ void
FormatFatalSystemError(const char *fmt, ...)
{
char buffer[1024];
va_list ap;
std::va_list ap;
va_start(ap, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
......
......@@ -24,9 +24,9 @@
#include <stdlib.h>
AllocatedString<>
FormatStringV(const char *fmt, va_list args) noexcept
FormatStringV(const char *fmt, std::va_list args) noexcept
{
va_list tmp;
std::va_list tmp;
va_copy(tmp, args);
const int length = vsnprintf(nullptr, 0, fmt, tmp);
va_end(tmp);
......@@ -43,7 +43,7 @@ FormatStringV(const char *fmt, va_list args) noexcept
AllocatedString<>
FormatString(const char *fmt, ...) noexcept
{
va_list args;
std::va_list args;
va_start(args, fmt);
auto p = FormatStringV(fmt, args);
va_end(args);
......
......@@ -22,7 +22,7 @@
#include "Compiler.h"
#include <stdarg.h>
#include <cstdarg>
template<typename T> class AllocatedString;
......@@ -32,7 +32,7 @@ template<typename T> class AllocatedString;
*/
gcc_nonnull_all
AllocatedString<char>
FormatStringV(const char *fmt, va_list args) noexcept;
FormatStringV(const char *fmt, std::va_list args) noexcept;
/**
* Format into a newly allocated string. The caller frees the return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment