diff --git a/src/lib/ffmpeg/Filter.cxx b/src/lib/ffmpeg/Filter.cxx index ce36bd2ff..7062d82c0 100644 --- a/src/lib/ffmpeg/Filter.cxx +++ b/src/lib/ffmpeg/Filter.cxx @@ -22,8 +22,7 @@ #include "SampleFormat.hxx" #include "pcm/AudioFormat.hxx" #include "lib/fmt/RuntimeError.hxx" - -#include +#include "lib/fmt/ToBuffer.hxx" #include @@ -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)); diff --git a/src/unix/PidFile.hxx b/src/unix/PidFile.hxx index 65fc83840..aedee5c63 100644 --- a/src/unix/PidFile.hxx +++ b/src/unix/PidFile.hxx @@ -24,6 +24,7 @@ #include "fs/FileSystem.hxx" #include "fs/AllocatedPath.hxx" #include "lib/fmt/SystemError.hxx" +#include "lib/fmt/ToBuffer.hxx" #include @@ -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); }