mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
code: Replace printf/scanf with type safe fmt
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "Disassembler.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
Disassembler::Disassembler()
|
||||
{
|
||||
@@ -15,11 +14,11 @@ Disassembler::~Disassembler()
|
||||
void Disassembler::printInstruction(void* code,u64 address)//print a single instruction
|
||||
{
|
||||
ZydisDecodedInstruction instruction;
|
||||
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
|
||||
ZyanStatus status = ZydisDecoderDecodeFull(&m_decoder, code, sizeof(code), &instruction, operands);
|
||||
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
|
||||
ZyanStatus status = ZydisDecoderDecodeFull(&m_decoder, code, sizeof(code), &instruction, operands);
|
||||
if (!ZYAN_SUCCESS(status))
|
||||
{
|
||||
printf("decode instruction failed at %p\n", code);
|
||||
fmt::print("decode instruction failed at {}\n", fmt::ptr(code));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,7 +29,7 @@ void Disassembler::printInstruction(void* code,u64 address)//print a single inst
|
||||
void Disassembler::printInst(ZydisDecodedInstruction& inst, ZydisDecodedOperand* operands,u64 address)
|
||||
{
|
||||
const int bufLen = 256;
|
||||
char szBuffer[bufLen];
|
||||
char szBuffer[bufLen];
|
||||
ZydisFormatterFormatInstruction(&m_formatter, &inst, operands,inst.operand_count_visible, szBuffer, sizeof(szBuffer), address, ZYAN_NULL);
|
||||
printf("instruction: %s\n", szBuffer);
|
||||
}
|
||||
fmt::print("instruction: {}\n", szBuffer);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <fmt/core.h>
|
||||
#include <toml11/toml.hpp>
|
||||
|
||||
namespace Config {
|
||||
@@ -29,7 +30,7 @@ void load(const std::filesystem::path& path) {
|
||||
try {
|
||||
data = toml::parse(path);
|
||||
} catch (std::exception& ex) {
|
||||
printf("Got exception trying to load config file. Exception: %s\n", ex.what());
|
||||
fmt::print("Got exception trying to load config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,14 +62,14 @@ void save(const std::filesystem::path& path) {
|
||||
try {
|
||||
data = toml::parse<toml::preserve_comments>(path);
|
||||
} catch (const std::exception& ex) {
|
||||
printf("Exception trying to parse config file. Exception: %s\n", ex.what());
|
||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (error) {
|
||||
printf("Filesystem error accessing %s (error: %s)\n", path.string().c_str(), error.message().c_str());
|
||||
fmt::print("Filesystem error accessing {} (error: {})\n", path.string(), error.message().c_str());
|
||||
}
|
||||
printf("Saving new configuration file %s\n", path.string().c_str());
|
||||
fmt::print("Saving new configuration file {}\n", path.string());
|
||||
}
|
||||
|
||||
data["General"]["isPS4Pro"] = isNeo;
|
||||
|
||||
Reference in New Issue
Block a user