ams: add -Wno-format-truncation to flags

This commit is contained in:
Michael Scire 2020-06-25 17:32:22 -07:00
parent 9003ad6e49
commit f594de0081
5 changed files with 19 additions and 32 deletions

View file

@ -18,7 +18,9 @@ endif
export ATMOSPHERE_DEFINES := -DATMOSPHERE export ATMOSPHERE_DEFINES := -DATMOSPHERE
export ATMOSPHERE_SETTINGS := -fPIE -g export ATMOSPHERE_SETTINGS := -fPIE -g
export ATMOSPHERE_CFLAGS := -Wall -ffunction-sections -fdata-sections -fno-strict-aliasing -fwrapv \ export ATMOSPHERE_CFLAGS := -Wall -ffunction-sections -fdata-sections -fno-strict-aliasing -fwrapv \
-fno-asynchronous-unwind-tables -fno-unwind-tables -fno-stack-protector -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-stack-protector \
-Wno-format-truncation
export ATMOSPHERE_CXXFLAGS := -fno-rtti -fno-exceptions -std=gnu++20 export ATMOSPHERE_CXXFLAGS := -fno-rtti -fno-exceptions -std=gnu++20
export ATMOSPHERE_ASFLAGS := export ATMOSPHERE_ASFLAGS :=

View file

@ -86,10 +86,7 @@ namespace ams::emummc {
const Storage storage = static_cast<Storage>(g_exo_config.base_cfg.type); const Storage storage = static_cast<Storage>(g_exo_config.base_cfg.type);
g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc; g_is_emummc = g_exo_config.base_cfg.magic == StorageMagic && storage != Storage_Emmc;
/* Format paths. Ignore string format warnings. */ /* Format paths. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
{
if (storage == Storage_SdFile) { if (storage == Storage_SdFile) {
std::snprintf(g_exo_config.file_cfg.path, sizeof(g_exo_config.file_cfg.path), "/%s", paths->file_path); std::snprintf(g_exo_config.file_cfg.path, sizeof(g_exo_config.file_cfg.path), "/%s", paths->file_path);
} }
@ -101,8 +98,6 @@ namespace ams::emummc {
std::snprintf(g_exo_config.emu_dir_path, sizeof(g_exo_config.emu_dir_path), "/emummc/Nintendo_%04x", g_exo_config.base_cfg.id); std::snprintf(g_exo_config.emu_dir_path, sizeof(g_exo_config.emu_dir_path), "/emummc/Nintendo_%04x", g_exo_config.base_cfg.id);
} }
} }
#pragma GCC diagnostic pop
}
g_has_cached = true; g_has_cached = true;
} }

View file

@ -237,10 +237,7 @@ namespace ams::patcher {
} }
/* Print the path for this directory. */ /* Print the path for this directory. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
std::snprintf(path + patches_dir_path_len, sizeof(path) - patches_dir_path_len, "/%s", entry.name); std::snprintf(path + patches_dir_path_len, sizeof(path) - patches_dir_path_len, "/%s", entry.name);
#pragma GCC diagnostic pop
const size_t patch_dir_path_len = patches_dir_path_len + 1 + std::strlen(entry.name); const size_t patch_dir_path_len = patches_dir_path_len + 1 + std::strlen(entry.name);
/* Open the patch directory. */ /* Open the patch directory. */

View file

@ -56,16 +56,12 @@ namespace ams::mitm::settings {
const auto api_info = exosphere::GetApiInfo(); const auto api_info = exosphere::GetApiInfo();
const char emummc_char = emummc::IsActive() ? 'E' : 'S'; const char emummc_char = emummc::IsActive() ? 'E' : 'S';
/* GCC complains about the following snprintf possibly truncating, but this is not a problem and has been carefully accounted for. */ /* NOTE: We have carefully accounted for the size of the string we print. */
#pragma GCC diagnostic push /* No truncation occurs assuming two-digits for all version number components. */
#pragma GCC diagnostic ignored "-Wformat-truncation"
{
char display_version[sizeof(g_ams_firmware_version.display_version)]; char display_version[sizeof(g_ams_firmware_version.display_version)];
std::snprintf(display_version, sizeof(display_version), "%s|AMS %u.%u.%u|%c", g_ams_firmware_version.display_version, api_info.GetMajorVersion(), api_info.GetMinorVersion(), api_info.GetMicroVersion(), emummc_char); std::snprintf(display_version, sizeof(display_version), "%s|AMS %u.%u.%u|%c", g_ams_firmware_version.display_version, api_info.GetMajorVersion(), api_info.GetMinorVersion(), api_info.GetMicroVersion(), emummc_char);
std::memcpy(g_ams_firmware_version.display_version, display_version, sizeof(display_version)); std::memcpy(g_ams_firmware_version.display_version, display_version, sizeof(display_version));
} }
#pragma GCC diagnostic pop
}
g_cached_firmware_version = true; g_cached_firmware_version = true;
} }

View file

@ -138,10 +138,7 @@ int main(int argc, char **argv)
settings::system::GetSerialNumber(std::addressof(serial_number)); settings::system::GetSerialNumber(std::addressof(serial_number));
char os_private[0x60]; char os_private[0x60];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
const auto os_priv_len = std::snprintf(os_private, sizeof(os_private), "%s (%.8s)", firmware_version.display_name, firmware_version.revision); const auto os_priv_len = std::snprintf(os_private, sizeof(os_private), "%s (%.8s)", firmware_version.display_name, firmware_version.revision);
#pragma GCC diagnostic pop
AMS_ASSERT(static_cast<size_t>(os_priv_len) < sizeof(os_private)); AMS_ASSERT(static_cast<size_t>(os_priv_len) < sizeof(os_private));
R_ABORT_UNLESS(erpt::srv::SetSerialNumberAndOsVersion(serial_number.str, R_ABORT_UNLESS(erpt::srv::SetSerialNumberAndOsVersion(serial_number.str,