Resolve deprecation warnings by replacing use of sprintf with FmtBuffer
This commit is contained in:
parent
e0df0b6d74
commit
f248fe2dec
|
@ -22,8 +22,7 @@
|
|||
#include "SampleFormat.hxx"
|
||||
#include "pcm/AudioFormat.hxx"
|
||||
#include "lib/fmt/RuntimeError.hxx"
|
||||
|
||||
#include <cinttypes>
|
||||
#include "lib/fmt/ToBuffer.hxx"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -81,9 +80,8 @@ MakeAudioBufferSource(AudioFormat &audio_format,
|
|||
}
|
||||
}
|
||||
|
||||
char abuffer_args[256];
|
||||
sprintf(abuffer_args,
|
||||
"sample_rate=%u:sample_fmt=%s:channel_layout=0x%" PRIx64 ":time_base=1/%u",
|
||||
const auto abuffer_args = FmtBuffer<256>(
|
||||
"sample_rate={}:sample_fmt={}:channel_layout={:#x}:time_base=1/{}",
|
||||
audio_format.sample_rate,
|
||||
av_get_sample_fmt_name(src_format),
|
||||
ToFfmpegChannelLayout(audio_format.channels),
|
||||
|
@ -119,9 +117,8 @@ MakeAformat(AudioFormat &audio_format,
|
|||
}
|
||||
}
|
||||
|
||||
char args[256];
|
||||
sprintf(args,
|
||||
"sample_rates=%u:sample_fmts=%s:channel_layouts=0x%" PRIx64,
|
||||
const auto args = FmtBuffer<256>(
|
||||
"sample_rates={}:sample_fmts={}:channel_layouts={:#x}",
|
||||
audio_format.sample_rate,
|
||||
av_get_sample_fmt_name(dest_format),
|
||||
ToFfmpegChannelLayout(audio_format.channels));
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "lib/fmt/SystemError.hxx"
|
||||
#include "lib/fmt/ToBuffer.hxx"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
@ -71,10 +72,9 @@ public:
|
|||
if (fd < 0)
|
||||
return;
|
||||
|
||||
char buffer[64];
|
||||
sprintf(buffer, "%lu\n", (unsigned long)pid);
|
||||
const auto s = FmtBuffer<64>("{}\n", pid);
|
||||
|
||||
write(fd, buffer, strlen(buffer));
|
||||
write(fd, s.c_str(), strlen(s.c_str()));
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue