ams: use util::SNPrintf over std:: (size/linker improvements)

This commit is contained in:
Michael Scire 2021-01-12 02:59:41 -08:00
parent 9cfd259c5c
commit 094cede39e
41 changed files with 103 additions and 103 deletions

View file

@ -80,7 +80,7 @@ namespace ams::fs {
namespace ams::fs::impl {
const char *IdString::ToValueString(int id) {
const int len = std::snprintf(this->buffer, sizeof(this->buffer), "%d", id);
const int len = util::SNPrintf(this->buffer, sizeof(this->buffer), "%d", id);
AMS_ASSERT(static_cast<size_t>(len) < sizeof(this->buffer));
return this->buffer;
}
@ -202,7 +202,7 @@ namespace ams::fs::impl {
return;
}
const auto size = std::vsnprintf(log_buffer.get(), log_buffer_size, format, vl);
const auto size = util::VSNPrintf(log_buffer.get(), log_buffer_size, format, vl);
if (size < log_buffer_size) {
break;
}
@ -233,7 +233,7 @@ namespace ams::fs::impl {
return;
}
const auto size = std::vsnprintf(str_buffer.get(), str_buffer_size, format, vl);
const auto size = util::VSNPrintf(str_buffer.get(), str_buffer_size, format, vl);
if (size < str_buffer_size) {
break;
}
@ -269,7 +269,7 @@ namespace ams::fs::impl {
return;
}
log_buffer_size = 1 + std::snprintf(log_buffer.get(), try_size, FormatString, start_ms, end_ms, result.GetValue(), handle, priority, name, str_buffer.get());
log_buffer_size = 1 + util::SNPrintf(log_buffer.get(), try_size, FormatString, start_ms, end_ms, result.GetValue(), handle, priority, name, str_buffer.get());
if (log_buffer_size <= try_size) {
break;
}
@ -312,7 +312,7 @@ namespace ams::fs::impl {
" }\n";
char log_buffer[0x80];
const int len = 1 + std::snprintf(log_buffer, sizeof(log_buffer), StartLog, static_cast<int>(program_index));
const int len = 1 + util::SNPrintf(log_buffer, sizeof(log_buffer), StartLog, static_cast<int>(program_index));
if (static_cast<size_t>(len) <= sizeof(log_buffer)) {
OutputAccessLogImpl(log_buffer, len);
}

View file

@ -33,7 +33,7 @@ namespace ams::fs {
AMS_ABORT_UNLESS(dst_size >= needed_size);
/* Generate the name. */
auto size = std::snprintf(dst, dst_size, "%s:", bis_mount_name);
auto size = util::SNPrintf(dst, dst_size, "%s:", bis_mount_name);
AMS_ASSERT(static_cast<size_t>(size) == needed_size - 1);
return ResultSuccess();

View file

@ -172,7 +172,7 @@ namespace ams::fs {
/* Create a redirection filesystem to the relevant content folder. */
char path[fs::EntryNameLengthMax + 1];
std::snprintf(path, sizeof(path), "/atmosphere/contents/%016lx/exefs", program_id.value);
util::SNPrintf(path, sizeof(path), "/atmosphere/contents/%016lx/exefs", program_id.value);
auto subdir_fs = std::make_unique<fssystem::SubDirectoryFileSystem>(std::move(sd_fs), path);
if (subdir_fs == nullptr) {
@ -190,7 +190,7 @@ namespace ams::fs {
/* Create a path representing the stub. */
char stub_path[fs::EntryNameLengthMax + 1];
std::snprintf(stub_path, sizeof(stub_path), "%s.stub", path);
util::SNPrintf(stub_path, sizeof(stub_path), "%s.stub", path);
/* Query whether we have the file. */
bool has_file;

View file

@ -32,7 +32,7 @@ namespace ams::fs {
AMS_ABORT_UNLESS(dst_size >= needed_size);
/* Generate the name. */
auto size = std::snprintf(dst, dst_size, "%s:", GetContentStorageMountName(id));
auto size = util::SNPrintf(dst, dst_size, "%s:", GetContentStorageMountName(id));
AMS_ASSERT(static_cast<size_t>(size) == needed_size - 1);
return ResultSuccess();

View file

@ -42,7 +42,7 @@ namespace ams::fs {
AMS_ABORT_UNLESS(dst_size >= needed_size);
/* Generate the name. */
auto size = std::snprintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(this->partition), this->handle);
auto size = util::SNPrintf(dst, dst_size, "%s%s%08x:", impl::GameCardFileSystemMountName, GetGameCardMountNameSuffix(this->partition), this->handle);
AMS_ASSERT(static_cast<size_t>(size) == needed_size - 1);
return ResultSuccess();

View file

@ -34,7 +34,7 @@ namespace ams::fs {
AMS_ABORT_UNLESS(dst_size >= needed_size);
/* Generate the name. */
auto size = std::snprintf(dst, dst_size, "%s:", impl::SdCardFileSystemMountName);
auto size = util::SNPrintf(dst, dst_size, "%s:", impl::SdCardFileSystemMountName);
AMS_ASSERT(static_cast<size_t>(size) == needed_size - 1);
return ResultSuccess();

View file

@ -151,7 +151,7 @@ namespace ams::fs {
AMS_FS_R_TRY(accessor->GetCommonMountName(dst, dst_size));
const auto mount_name_len = strnlen(dst, dst_size);
const auto common_path_len = std::snprintf(dst + mount_name_len, dst_size - mount_name_len, "%s", sub_path);
const auto common_path_len = util::SNPrintf(dst + mount_name_len, dst_size - mount_name_len, "%s", sub_path);
AMS_FS_R_UNLESS(static_cast<size_t>(common_path_len) < dst_size - mount_name_len, fs::ResultTooLongPath());
return ResultSuccess();