From 48acb6d369f7ca5cf99671b3418b4c10f744f53f Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sat, 6 Feb 2021 12:36:58 +0000 Subject: [PATCH] Address a bunch of issues detected by clang-tidy --- .../main/cpp/skyline/audio/adpcm_decoder.cpp | 2 +- .../main/cpp/skyline/audio/adpcm_decoder.h | 2 +- app/src/main/cpp/skyline/audio/common.h | 2 +- app/src/main/cpp/skyline/audio/track.cpp | 2 +- app/src/main/cpp/skyline/audio/track.h | 4 +- app/src/main/cpp/skyline/common.cpp | 2 +- app/src/main/cpp/skyline/common.h | 17 ++-- .../main/cpp/skyline/common/circular_buffer.h | 4 +- .../main/cpp/skyline/common/circular_queue.h | 22 ++--- app/src/main/cpp/skyline/common/signal.h | 2 +- app/src/main/cpp/skyline/crypto/aes_cipher.h | 6 +- app/src/main/cpp/skyline/crypto/key_store.cpp | 2 +- app/src/main/cpp/skyline/crypto/key_store.h | 2 +- app/src/main/cpp/skyline/gpu.h | 2 +- app/src/main/cpp/skyline/gpu/engines/gpfifo.h | 2 +- .../main/cpp/skyline/gpu/engines/maxwell_3d.h | 2 +- .../cpp/skyline/gpu/macro_interpreter.cpp | 2 + .../main/cpp/skyline/gpu/memory_manager.cpp | 2 +- app/src/main/cpp/skyline/gpu/memory_manager.h | 2 +- app/src/main/cpp/skyline/gpu/syncpoint.cpp | 6 +- app/src/main/cpp/skyline/gpu/texture.cpp | 8 +- app/src/main/cpp/skyline/input.h | 2 +- app/src/main/cpp/skyline/input/npad_device.h | 7 +- app/src/main/cpp/skyline/jvm.h | 4 +- app/src/main/cpp/skyline/kernel/ipc.h | 38 +++------ app/src/main/cpp/skyline/kernel/memory.cpp | 4 +- app/src/main/cpp/skyline/kernel/memory.h | 4 +- app/src/main/cpp/skyline/kernel/scheduler.h | 6 +- .../skyline/kernel/types/KPrivateMemory.cpp | 2 +- .../cpp/skyline/kernel/types/KPrivateMemory.h | 8 +- .../cpp/skyline/kernel/types/KProcess.cpp | 3 +- .../main/cpp/skyline/kernel/types/KProcess.h | 4 +- .../skyline/kernel/types/KSharedMemory.cpp | 2 +- .../cpp/skyline/kernel/types/KSharedMemory.h | 2 +- .../main/cpp/skyline/kernel/types/KThread.cpp | 2 +- app/src/main/cpp/skyline/loader/loader.cpp | 4 +- app/src/main/cpp/skyline/loader/loader.h | 6 +- app/src/main/cpp/skyline/loader/nca.cpp | 6 +- app/src/main/cpp/skyline/loader/nca.h | 6 +- app/src/main/cpp/skyline/loader/nro.cpp | 4 +- app/src/main/cpp/skyline/loader/nro.h | 6 +- app/src/main/cpp/skyline/loader/nso.cpp | 6 +- app/src/main/cpp/skyline/loader/nso.h | 6 +- app/src/main/cpp/skyline/loader/nsp.cpp | 4 +- app/src/main/cpp/skyline/loader/nsp.h | 4 +- app/src/main/cpp/skyline/nce/instructions.h | 82 +++---------------- app/src/main/cpp/skyline/os.cpp | 10 +-- app/src/main/cpp/skyline/os.h | 2 +- .../skyline/services/am/storage/IStorage.h | 2 +- .../services/am/storage/IStorageAccessor.cpp | 2 +- .../cpp/skyline/services/audio/IAudioOut.cpp | 2 +- .../skyline/services/audio/IAudioOutManager.h | 2 +- .../audio/IAudioRenderer/IAudioRenderer.cpp | 2 +- .../services/audio/IAudioRenderer/effect.h | 2 +- .../audio/IAudioRenderer/revision_info.h | 14 ++-- .../services/audio/IAudioRenderer/voice.cpp | 2 +- .../services/audio/IAudioRenderer/voice.h | 2 +- .../main/cpp/skyline/services/base_service.h | 4 +- .../main/cpp/skyline/services/common/fence.h | 2 +- .../main/cpp/skyline/services/common/parcel.h | 2 +- .../cpp/skyline/services/fssrv/IDirectory.cpp | 2 +- .../main/cpp/skyline/services/fssrv/IFile.cpp | 2 +- .../main/cpp/skyline/services/fssrv/IFile.h | 2 +- .../skyline/services/fssrv/IFileSystem.cpp | 6 +- .../services/fssrv/IFileSystemProxy.cpp | 6 +- .../skyline/services/fssrv/IFileSystemProxy.h | 2 +- .../cpp/skyline/services/fssrv/IStorage.cpp | 2 +- .../cpp/skyline/services/fssrv/IStorage.h | 2 +- .../hosbinder/GraphicBufferProducer.cpp | 4 +- .../hosbinder/GraphicBufferProducer.h | 2 +- .../skyline/services/nvdrv/INvDrvServices.cpp | 1 - .../skyline/services/nvdrv/devices/nvdevice.h | 6 +- .../services/nvdrv/devices/nvhost_channel.h | 2 +- .../services/nvdrv/devices/nvhost_ctrl.cpp | 5 +- .../services/nvdrv/devices/nvhost_ctrl.h | 2 +- .../services/nvdrv/devices/nvhost_ctrl_gpu.h | 2 +- .../skyline/services/nvdrv/devices/nvmap.h | 2 +- .../main/cpp/skyline/services/nvdrv/driver.h | 2 +- .../main/cpp/skyline/services/serviceman.h | 2 +- .../services/timesrv/ITimeZoneService.cpp | 2 +- app/src/main/cpp/skyline/vfs/backing.h | 6 +- .../cpp/skyline/vfs/ctr_encrypted_backing.cpp | 2 +- .../cpp/skyline/vfs/ctr_encrypted_backing.h | 2 +- app/src/main/cpp/skyline/vfs/filesystem.h | 4 +- app/src/main/cpp/skyline/vfs/nca.cpp | 5 +- app/src/main/cpp/skyline/vfs/nca.h | 2 +- app/src/main/cpp/skyline/vfs/npdm.h | 2 +- app/src/main/cpp/skyline/vfs/os_backing.cpp | 6 +- .../main/cpp/skyline/vfs/os_filesystem.cpp | 2 +- app/src/main/cpp/skyline/vfs/os_filesystem.h | 2 +- .../cpp/skyline/vfs/partition_filesystem.cpp | 6 +- .../cpp/skyline/vfs/partition_filesystem.h | 4 +- .../main/cpp/skyline/vfs/rom_filesystem.cpp | 6 +- app/src/main/cpp/skyline/vfs/rom_filesystem.h | 2 +- 94 files changed, 197 insertions(+), 277 deletions(-) diff --git a/app/src/main/cpp/skyline/audio/adpcm_decoder.cpp b/app/src/main/cpp/skyline/audio/adpcm_decoder.cpp index b05e6a84..cea9364e 100644 --- a/app/src/main/cpp/skyline/audio/adpcm_decoder.cpp +++ b/app/src/main/cpp/skyline/audio/adpcm_decoder.cpp @@ -5,7 +5,7 @@ #include "adpcm_decoder.h" namespace skyline::audio { - AdpcmDecoder::AdpcmDecoder(const std::vector> &coefficients) : coefficients(coefficients) {} + AdpcmDecoder::AdpcmDecoder(std::vector> coefficients) : coefficients(std::move(coefficients)) {} std::vector AdpcmDecoder::Decode(span adpcmData) { constexpr size_t BytesPerFrame{0x8}; diff --git a/app/src/main/cpp/skyline/audio/adpcm_decoder.h b/app/src/main/cpp/skyline/audio/adpcm_decoder.h index 8ccf9966..f8556156 100644 --- a/app/src/main/cpp/skyline/audio/adpcm_decoder.h +++ b/app/src/main/cpp/skyline/audio/adpcm_decoder.h @@ -26,7 +26,7 @@ namespace skyline::audio { std::vector> coefficients; //!< The coefficients for decoding the ADPCM stream public: - AdpcmDecoder(const std::vector> &coefficients); + AdpcmDecoder(std::vector> coefficients); /** * @brief Decodes a buffer of ADPCM data into I16 PCM diff --git a/app/src/main/cpp/skyline/audio/common.h b/app/src/main/cpp/skyline/audio/common.h index 996e84f2..1fbd487d 100644 --- a/app/src/main/cpp/skyline/audio/common.h +++ b/app/src/main/cpp/skyline/audio/common.h @@ -12,7 +12,7 @@ namespace skyline { constexpr u8 ChannelCount{2}; //!< The common amount of channels to use for audio output constexpr u16 MixBufferSize{960}; //!< The size of the mix buffer by default constexpr auto PcmFormat{oboe::AudioFormat::I16}; //!< The common PCM data format to use for audio output - }; + } namespace audio { enum class AudioFormat : u8 { diff --git a/app/src/main/cpp/skyline/audio/track.cpp b/app/src/main/cpp/skyline/audio/track.cpp index 912713bd..07c02239 100644 --- a/app/src/main/cpp/skyline/audio/track.cpp +++ b/app/src/main/cpp/skyline/audio/track.cpp @@ -4,7 +4,7 @@ #include "track.h" namespace skyline::audio { - AudioTrack::AudioTrack(u8 channelCount, u32 sampleRate, const std::function &releaseCallback) : channelCount(channelCount), sampleRate(sampleRate), releaseCallback(releaseCallback) { + AudioTrack::AudioTrack(u8 channelCount, u32 sampleRate, std::function releaseCallback) : channelCount(channelCount), sampleRate(sampleRate), releaseCallback(std::move(releaseCallback)) { if (sampleRate != constant::SampleRate) throw exception("Unsupported audio sample rate: {}", sampleRate); diff --git a/app/src/main/cpp/skyline/audio/track.h b/app/src/main/cpp/skyline/audio/track.h index acf7b742..9bdabb19 100644 --- a/app/src/main/cpp/skyline/audio/track.h +++ b/app/src/main/cpp/skyline/audio/track.h @@ -31,12 +31,12 @@ namespace skyline::audio { * @param sampleRate The sample rate to use for the track * @param releaseCallback A callback to call when a buffer has been played */ - AudioTrack(u8 channelCount, u32 sampleRate, const std::function &releaseCallback); + AudioTrack(u8 channelCount, u32 sampleRate, std::function releaseCallback); /** * @brief Starts audio playback using data from appended buffers */ - inline void Start() { + void Start() { playbackState = AudioOutState::Started; } diff --git a/app/src/main/cpp/skyline/common.cpp b/app/src/main/cpp/skyline/common.cpp index 63621af4..4940de97 100644 --- a/app/src/main/cpp/skyline/common.cpp +++ b/app/src/main/cpp/skyline/common.cpp @@ -39,7 +39,7 @@ namespace skyline { logFile << "\0360\035" << str << '\n'; } - void Logger::Write(LogLevel level, const std::string& str) { + void Logger::Write(LogLevel level, const std::string &str) { constexpr std::array levelCharacter{'E', 'W', 'I', 'D', 'V'}; // The LogLevel as written out to a file constexpr std::array levelAlog{ANDROID_LOG_ERROR, ANDROID_LOG_WARN, ANDROID_LOG_INFO, ANDROID_LOG_DEBUG, ANDROID_LOG_VERBOSE}; // This corresponds to LogLevel and provides its equivalent for NDK Logging diff --git a/app/src/main/cpp/skyline/common.h b/app/src/main/cpp/skyline/common.h index 946bbc26..211826ea 100644 --- a/app/src/main/cpp/skyline/common.h +++ b/app/src/main/cpp/skyline/common.h @@ -73,10 +73,7 @@ namespace skyline { */ Result() = default; - constexpr Result(u16 module, u16 id) { - this->module = module; - this->id = id; - } + constexpr Result(u16 module, u16 id) : module(module), id(id) {} constexpr operator u32() const { return raw; @@ -121,7 +118,7 @@ namespace skyline { * @param args The arguments based on format_str */ template - inline exception(const S &formatStr, Args &&... args) : runtime_error(fmt::format(formatStr, util::FmtCast(args)...)) {} + exception(const S &formatStr, Args &&... args) : runtime_error(fmt::format(formatStr, util::FmtCast(args)...)) {} }; namespace util { @@ -434,31 +431,31 @@ namespace skyline { void Write(LogLevel level, const std::string &str); template - inline void Error(const S &formatStr, Args &&... args) { + void Error(const S &formatStr, Args &&... args) { if (LogLevel::Error <= configLevel) Write(LogLevel::Error, fmt::format(formatStr, util::FmtCast(args)...)); } template - inline void Warn(const S &formatStr, Args &&... args) { + void Warn(const S &formatStr, Args &&... args) { if (LogLevel::Warn <= configLevel) Write(LogLevel::Warn, fmt::format(formatStr, util::FmtCast(args)...)); } template - inline void Info(const S &formatStr, Args &&... args) { + void Info(const S &formatStr, Args &&... args) { if (LogLevel::Info <= configLevel) Write(LogLevel::Info, fmt::format(formatStr, util::FmtCast(args)...)); } template - inline void Debug(const S &formatStr, Args &&... args) { + void Debug(const S &formatStr, Args &&... args) { if (LogLevel::Debug <= configLevel) Write(LogLevel::Debug, fmt::format(formatStr, util::FmtCast(args)...)); } template - inline void Verbose(const S &formatStr, Args &&... args) { + void Verbose(const S &formatStr, Args &&... args) { if (LogLevel::Verbose <= configLevel) Write(LogLevel::Verbose, fmt::format(formatStr, util::FmtCast(args)...)); } diff --git a/app/src/main/cpp/skyline/common/circular_buffer.h b/app/src/main/cpp/skyline/common/circular_buffer.h index a2c30261..a08defcb 100644 --- a/app/src/main/cpp/skyline/common/circular_buffer.h +++ b/app/src/main/cpp/skyline/common/circular_buffer.h @@ -28,7 +28,7 @@ namespace skyline { * @param copyOffset The offset into the buffer after which to use memcpy rather than copyFunction, -1 will use it for the entire buffer * @return The amount of data written into the input buffer in units of Type */ - inline size_t Read(span buffer, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) { + size_t Read(span buffer, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) { std::lock_guard guard(mtx); if (empty) @@ -91,7 +91,7 @@ namespace skyline { /** * @brief Appends data from the specified buffer into this buffer */ - inline void Append(span buffer) { + void Append(span buffer) { std::lock_guard guard(mtx); Type *pointer{buffer.data()}; diff --git a/app/src/main/cpp/skyline/common/circular_queue.h b/app/src/main/cpp/skyline/common/circular_queue.h index f8fcb3d0..00508c42 100644 --- a/app/src/main/cpp/skyline/common/circular_queue.h +++ b/app/src/main/cpp/skyline/common/circular_queue.h @@ -24,19 +24,19 @@ namespace skyline { /** * @note The internal allocation is an item larger as we require a sentinel value */ - inline CircularQueue(size_t size) : vector((size + 1) * sizeof(Type)) {} + CircularQueue(size_t size) : vector((size + 1) * sizeof(Type)) {} - inline CircularQueue(const CircularQueue &) = delete; + CircularQueue(const CircularQueue &) = delete; - inline CircularQueue &operator=(const CircularQueue &) = delete; + CircularQueue &operator=(const CircularQueue &) = delete; - inline CircularQueue(CircularQueue &&other) : vector(std::move(other.vector)), consumptionMutex(std::move(other.consumptionMutex)), consumeCondition(std::move(other.consumeCondition)), productionMutex(std::move(other.productionMutex)), produceCondition(std::move(other.produceCondition)) { - this->start = other.start; - this->end = other.end; + CircularQueue(CircularQueue &&other) : vector(std::move(other.vector)), consumptionMutex(std::move(other.consumptionMutex)), consumeCondition(std::move(other.consumeCondition)), productionMutex(std::move(other.productionMutex)), produceCondition(std::move(other.produceCondition)) { + start = other.start; + end = other.end; other.start = other.end = nullptr; } - inline ~CircularQueue() { + ~CircularQueue() { while (start != end) { auto next{start + 1}; next = (next == reinterpret_cast(vector.end().base())) ? reinterpret_cast(vector.begin().base()) : next; @@ -50,7 +50,7 @@ namespace skyline { * @param function A function that is called for each item (with the only parameter as a reference to that item) */ template - [[noreturn]] inline void Process(F function) { + [[noreturn]] void Process(F function) { while (true) { if (start == end) { std::unique_lock lock(productionMutex); @@ -68,7 +68,7 @@ namespace skyline { } } - inline void Push(const Type &item) { + void Push(const Type &item) { std::unique_lock lock(productionMutex); end = (end == reinterpret_cast(vector.end().base()) - 1) ? reinterpret_cast(vector.begin().base()) : end; if (start == end + 1) { @@ -79,7 +79,7 @@ namespace skyline { produceCondition.notify_one(); } - inline void Append(span buffer) { + void Append(span buffer) { std::unique_lock lock(productionMutex); for (const auto &item : buffer) { auto next{end + 1}; @@ -99,7 +99,7 @@ namespace skyline { * @param tranformation A function that takes in an item of TransformedType as input and returns an item of Type */ template - inline void AppendTranform(span buffer, Transformation transformation) { + void AppendTranform(span buffer, Transformation transformation) { std::unique_lock lock(productionMutex); for (const auto &item : buffer) { auto next{end + 1}; diff --git a/app/src/main/cpp/skyline/common/signal.h b/app/src/main/cpp/skyline/common/signal.h index c4a5d1cb..bc0a9ea7 100644 --- a/app/src/main/cpp/skyline/common/signal.h +++ b/app/src/main/cpp/skyline/common/signal.h @@ -49,7 +49,7 @@ namespace skyline::signal { void *fault{}; std::vector frames; //!< A vector of all stack frame entries prior to the signal occuring - inline std::string what() const { + std::string what() const { if (!fault) return fmt::format("Signal: {} (PC: 0x{:X})", strsignal(signal), reinterpret_cast(pc)); else diff --git a/app/src/main/cpp/skyline/crypto/aes_cipher.h b/app/src/main/cpp/skyline/crypto/aes_cipher.h index b9d9c8f5..211f7d03 100644 --- a/app/src/main/cpp/skyline/crypto/aes_cipher.h +++ b/app/src/main/cpp/skyline/crypto/aes_cipher.h @@ -19,7 +19,7 @@ namespace skyline::crypto { /** * @brief Calculates IV for XTS, basically just big to little endian conversion */ - inline static std::array GetTweak(size_t sector) { + static std::array GetTweak(size_t sector) { std::array tweak{}; size_t le{__builtin_bswap64(sector)}; std::memcpy(tweak.data() + 8, &le, 8); @@ -45,7 +45,7 @@ namespace skyline::crypto { /** * @brief Decrypts the supplied data in-place */ - inline void Decrypt(span data) { + void Decrypt(span data) { Decrypt(data.data(), data.data(), data.size()); } @@ -57,7 +57,7 @@ namespace skyline::crypto { /** * @brief Decrypts data with XTS and writes back to it */ - inline void XtsDecrypt(span data, size_t sector, size_t sectorSize) { + void XtsDecrypt(span data, size_t sector, size_t sectorSize) { XtsDecrypt(data.data(), data.data(), data.size(), sector, sectorSize); } }; diff --git a/app/src/main/cpp/skyline/crypto/key_store.cpp b/app/src/main/cpp/skyline/crypto/key_store.cpp index 633af314..71b04929 100644 --- a/app/src/main/cpp/skyline/crypto/key_store.cpp +++ b/app/src/main/cpp/skyline/crypto/key_store.cpp @@ -35,7 +35,7 @@ namespace skyline::crypto { void KeyStore::PopulateTitleKeys(std::string_view keyName, std::string_view value) { Key128 key{util::HexStringToArray<16>(keyName)}; Key128 valueArray{util::HexStringToArray<16>(value)}; - titleKeys.insert({std::move(key), std::move(valueArray)}); + titleKeys.emplace(key, valueArray); } void KeyStore::PopulateKeys(std::string_view keyName, std::string_view value) { diff --git a/app/src/main/cpp/skyline/crypto/key_store.h b/app/src/main/cpp/skyline/crypto/key_store.h index 9e4eb2e9..cad786fa 100644 --- a/app/src/main/cpp/skyline/crypto/key_store.h +++ b/app/src/main/cpp/skyline/crypto/key_store.h @@ -47,7 +47,7 @@ namespace skyline::crypto { void PopulateKeys(std::string_view keyName, std::string_view value); public: - inline std::optional GetTitleKey(const Key128 &title) { + std::optional GetTitleKey(const Key128 &title) { auto it{titleKeys.find(title)}; if (it == titleKeys.end()) return std::nullopt; diff --git a/app/src/main/cpp/skyline/gpu.h b/app/src/main/cpp/skyline/gpu.h index c5036525..23ad3cb2 100644 --- a/app/src/main/cpp/skyline/gpu.h +++ b/app/src/main/cpp/skyline/gpu.h @@ -27,6 +27,6 @@ namespace skyline::gpu { std::array syncpoints{}; gpfifo::GPFIFO gpfifo; - inline GPU(const DeviceState &state) : state(state), presentation(state), memoryManager(state), gpfifo(state), fermi2D(std::make_shared(state)), keplerMemory(std::make_shared(state)), maxwell3D(std::make_shared(state)), maxwellCompute(std::make_shared(state)), maxwellDma(std::make_shared(state)) {} + GPU(const DeviceState &state) : state(state), presentation(state), memoryManager(state), gpfifo(state), fermi2D(std::make_shared(state)), keplerMemory(std::make_shared(state)), maxwell3D(std::make_shared(state)), maxwellCompute(std::make_shared(state)), maxwellDma(std::make_shared(state)) {} }; } diff --git a/app/src/main/cpp/skyline/gpu/engines/gpfifo.h b/app/src/main/cpp/skyline/gpu/engines/gpfifo.h index 95aa0630..c2526a62 100644 --- a/app/src/main/cpp/skyline/gpu/engines/gpfifo.h +++ b/app/src/main/cpp/skyline/gpu/engines/gpfifo.h @@ -169,7 +169,7 @@ namespace skyline { public: GPFIFO(const DeviceState &state) : Engine(state) {} - void CallMethod(MethodParams params) { + void CallMethod(MethodParams params) override { state.logger->Debug("Called method in GPFIFO: 0x{:X} args: 0x{:X}", params.method, params.argument); registers.raw[params.method] = params.argument; diff --git a/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h b/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h index ab929956..266996fb 100644 --- a/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h +++ b/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h @@ -569,7 +569,7 @@ namespace skyline { */ void ResetRegs(); - void CallMethod(MethodParams params); + void CallMethod(MethodParams params) override; }; } } diff --git a/app/src/main/cpp/skyline/gpu/macro_interpreter.cpp b/app/src/main/cpp/skyline/gpu/macro_interpreter.cpp index a537a79a..e8e2912e 100644 --- a/app/src/main/cpp/skyline/gpu/macro_interpreter.cpp +++ b/app/src/main/cpp/skyline/gpu/macro_interpreter.cpp @@ -91,6 +91,8 @@ namespace skyline::gpu { } break; } + default: + throw exception("Unknown MME opcode encountered: 0x{:X}", static_cast(opcode->operation)); } if (opcode->exit && (delayedOpcode == nullptr)) { diff --git a/app/src/main/cpp/skyline/gpu/memory_manager.cpp b/app/src/main/cpp/skyline/gpu/memory_manager.cpp index b0c8aca2..d0c960a0 100644 --- a/app/src/main/cpp/skyline/gpu/memory_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/memory_manager.cpp @@ -124,7 +124,7 @@ namespace skyline::gpu::vmm { u64 MemoryManager::MapFixed(u64 virtAddr, u8 *cpuPtr, u64 size) { if (!util::IsAligned(virtAddr, constant::GpuPageSize)) - return false; + return 0; size = util::AlignUp(size, constant::GpuPageSize); diff --git a/app/src/main/cpp/skyline/gpu/memory_manager.h b/app/src/main/cpp/skyline/gpu/memory_manager.h index cbe1cff5..b01cd39c 100644 --- a/app/src/main/cpp/skyline/gpu/memory_manager.h +++ b/app/src/main/cpp/skyline/gpu/memory_manager.h @@ -29,7 +29,7 @@ namespace skyline { * @return If the given chunk can be contained wholly within this chunk */ inline bool CanContain(const ChunkDescriptor &chunk) { - return (chunk.virtAddr >= this->virtAddr) && ((this->size + this->virtAddr) >= (chunk.size + chunk.virtAddr)); + return (chunk.virtAddr >= virtAddr) && ((size + virtAddr) >= (chunk.size + chunk.virtAddr)); } }; diff --git a/app/src/main/cpp/skyline/gpu/syncpoint.cpp b/app/src/main/cpp/skyline/gpu/syncpoint.cpp index 88d6745f..c48d438b 100644 --- a/app/src/main/cpp/skyline/gpu/syncpoint.cpp +++ b/app/src/main/cpp/skyline/gpu/syncpoint.cpp @@ -11,7 +11,7 @@ namespace skyline::gpu { } std::lock_guard guard(waiterLock); - waiterMap.insert({nextWaiterId, Waiter{threshold, callback}}); + waiterMap.emplace(nextWaiterId, Waiter{threshold, callback}); return nextWaiterId++; } @@ -42,7 +42,7 @@ namespace skyline::gpu { std::condition_variable cv; bool flag{}; - if (timeout == timeout.max()) + if (timeout == std::chrono::steady_clock::duration::max()) timeout = std::chrono::seconds(1); if (!RegisterWaiter(threshold, [&cv, &mtx, &flag] { @@ -57,5 +57,5 @@ namespace skyline::gpu { std::unique_lock lock(mtx); return cv.wait_for(lock, timeout, [&flag] { return flag; }); } -}; +} diff --git a/app/src/main/cpp/skyline/gpu/texture.cpp b/app/src/main/cpp/skyline/gpu/texture.cpp index 55c134ad..217e1c33 100644 --- a/app/src/main/cpp/skyline/gpu/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture.cpp @@ -9,15 +9,15 @@ namespace skyline::gpu { GuestTexture::GuestTexture(const DeviceState &state, u8 *pointer, texture::Dimensions dimensions, texture::Format format, texture::TileMode tiling, texture::TileConfig layout) : state(state), pointer(pointer), dimensions(dimensions), format(format), tileMode(tiling), tileConfig(layout) {} - std::shared_ptr GuestTexture::InitializeTexture(std::optional format, std::optional dimensions, texture::Swizzle swizzle) { + std::shared_ptr GuestTexture::InitializeTexture(std::optional pFormat, std::optional pDimensions, texture::Swizzle swizzle) { if (!host.expired()) throw exception("Trying to create multiple Texture objects from a single GuestTexture"); - auto sharedHost{std::make_shared(state, shared_from_this(), dimensions ? *dimensions : this->dimensions, format ? *format : this->format, swizzle)}; + auto sharedHost{std::make_shared(state, shared_from_this(), pDimensions ? *pDimensions : dimensions, pFormat ? *pFormat : format, swizzle)}; host = sharedHost; return sharedHost; } - Texture::Texture(const DeviceState &state, std::shared_ptr guest, texture::Dimensions dimensions, texture::Format format, texture::Swizzle swizzle) : state(state), guest(guest), dimensions(dimensions), format(format), swizzle(swizzle) { + Texture::Texture(const DeviceState &state, std::shared_ptr guest, texture::Dimensions dimensions, texture::Format format, texture::Swizzle swizzle) : state(state), guest(std::move(guest)), dimensions(dimensions), format(format), swizzle(swizzle) { SynchronizeHost(); } @@ -25,7 +25,7 @@ namespace skyline::gpu { auto pointer{guest->pointer}; auto size{format.GetSize(dimensions)}; backing.resize(size); - auto output{reinterpret_cast(backing.data())}; + auto output{backing.data()}; if (guest->tileMode == texture::TileMode::Block) { // Reference on Block-linear tiling: https://gist.github.com/PixelyIon/d9c35050af0ef5690566ca9f0965bc32 diff --git a/app/src/main/cpp/skyline/input.h b/app/src/main/cpp/skyline/input.h index 80195900..382768c9 100644 --- a/app/src/main/cpp/skyline/input.h +++ b/app/src/main/cpp/skyline/input.h @@ -24,6 +24,6 @@ namespace skyline::input { NpadManager npad; TouchManager touch; - inline Input(const DeviceState &state) : state(state), kHid(std::make_shared(state, sizeof(HidSharedMemory))), hid(reinterpret_cast(kHid->kernel.ptr)), npad(state, hid), touch(state, hid) {} + Input(const DeviceState &state) : state(state), kHid(std::make_shared(state, sizeof(HidSharedMemory))), hid(reinterpret_cast(kHid->kernel.ptr)), npad(state, hid), touch(state, hid) {} }; } diff --git a/app/src/main/cpp/skyline/input/npad_device.h b/app/src/main/cpp/skyline/input/npad_device.h index 6ab4c589..96816250 100644 --- a/app/src/main/cpp/skyline/input/npad_device.h +++ b/app/src/main/cpp/skyline/input/npad_device.h @@ -89,8 +89,9 @@ namespace skyline::input { return NpadControllerType::JoyconLeft; case 7: return NpadControllerType::JoyconRight; + default: + return NpadControllerType::None; } - return NpadControllerType::None; } }; @@ -146,11 +147,11 @@ namespace skyline::input { NpadDevice(NpadManager &manager, NpadSection §ion, NpadId id); - inline void SetAssignment(NpadJoyAssignment assignment) { + void SetAssignment(NpadJoyAssignment assignment) { section.header.assignment = assignment; } - inline NpadJoyAssignment GetAssignment() { + NpadJoyAssignment GetAssignment() { return section.header.assignment; } diff --git a/app/src/main/cpp/skyline/jvm.h b/app/src/main/cpp/skyline/jvm.h index a5006e93..3de3b151 100644 --- a/app/src/main/cpp/skyline/jvm.h +++ b/app/src/main/cpp/skyline/jvm.h @@ -35,7 +35,7 @@ namespace skyline { * @return The contents of the field as objectType */ template - inline objectType GetField(const char *key) { + objectType GetField(const char *key) { JNIEnv *env{GetEnv()}; if constexpr(std::is_same()) return env->GetBooleanField(instance, env->GetFieldID(instanceClass, key, "Z")); @@ -53,6 +53,8 @@ namespace skyline { return env->GetFloatField(instance, env->GetFieldID(instanceClass, key, "F")); else if constexpr(std::is_same()) return env->GetDoubleField(instance, env->GetFieldID(instanceClass, key, "D")); + else + throw exception("GetField: Unhandled object type"); } /** diff --git a/app/src/main/cpp/skyline/kernel/ipc.h b/app/src/main/cpp/skyline/kernel/ipc.h index d6cd0e20..c86e1cca 100644 --- a/app/src/main/cpp/skyline/kernel/ipc.h +++ b/app/src/main/cpp/skyline/kernel/ipc.h @@ -129,19 +129,11 @@ namespace skyline { u16 size : 16; //!< The 16 bit size of the buffer u32 address0_31 : 32; //!< The first 32-bits of the address - BufferDescriptorX(u64 address, u16 counter, u16 size) : size(size) { - address0_31 = static_cast(address & 0x7FFFFFFF80000000); - address32_35 = static_cast(address & 0x78000000); - address36_38 = static_cast(address & 0x7000000); - counter0_5 = static_cast(address & 0x7E00); - counter9_11 = static_cast(address & 0x38); - } - - inline u8 *Pointer() { + u8 *Pointer() { return reinterpret_cast(static_cast(address0_31) | static_cast(address32_35) << 32 | static_cast(address36_38) << 36); } - inline u16 Counter() { + u16 Counter() { return static_cast(counter0_5) | static_cast(counter9_11) << 9; } }; @@ -159,19 +151,11 @@ namespace skyline { u8 size32_35 : 4; //!< Bit 32-35 of the size u8 address32_35 : 4; //!< Bit 32-35 of the address - BufferDescriptorABW(u64 address, u64 size) { - address0_31 = static_cast(address & 0x7FFFFFFF80000000); - address32_35 = static_cast(address & 0x78000000); - address36_38 = static_cast(address & 0x7000000); - size0_31 = static_cast(size & 0x7FFFFFFF80000000); - size32_35 = static_cast(size & 0x78000000); - } - - inline u8 *Pointer() { + u8 *Pointer() { return reinterpret_cast(static_cast(address0_31) | static_cast(address32_35) << 32 | static_cast(address36_38) << 36); } - inline u64 Size() { + u64 Size() { return static_cast(size0_31) | static_cast(size32_35) << 32; } }; @@ -184,11 +168,9 @@ namespace skyline { u64 address : 48; //!< The 48-bit address of the buffer u32 size : 16; //!< The 16-bit size of the buffer - inline u8 *Pointer() { + u8 *Pointer() { return reinterpret_cast(address); } - - BufferDescriptorC(u64 address, u16 size) : address(address), size(size) {} }; static_assert(sizeof(BufferDescriptorC) == 8); @@ -228,7 +210,7 @@ namespace skyline { * @brief Returns a reference to an item from the top of the payload */ template - inline ValueType &Pop() { + ValueType &Pop() { ValueType &value{*reinterpret_cast(payloadOffset)}; payloadOffset += sizeof(ValueType); return value; @@ -238,7 +220,7 @@ namespace skyline { * @brief Returns a std::string_view from the payload * @param size The length of the string (0 means the string is null terminated) */ - inline std::string_view PopString(size_t size = 0) { + std::string_view PopString(size_t size = 0) { auto view{size ? std::string_view(reinterpret_cast(payloadOffset), size) : std::string_view(reinterpret_cast(payloadOffset))}; payloadOffset += view.length(); return view; @@ -248,7 +230,7 @@ namespace skyline { * @brief Skips an object to pop off the top */ template - inline void Skip() { + void Skip() { payloadOffset += sizeof(ValueType); } }; @@ -276,7 +258,7 @@ namespace skyline { * @param value A reference to the object to be written */ template - inline void Push(const ValueType &value) { + void Push(const ValueType &value) { auto size{payload.size()}; payload.resize(size + sizeof(ValueType)); std::memcpy(payload.data() + size, reinterpret_cast(&value), sizeof(ValueType)); @@ -286,7 +268,7 @@ namespace skyline { * @brief Writes a string to the payload * @param string The string to write to the payload */ - inline void Push(std::string_view string) { + void Push(std::string_view string) { auto size{payload.size()}; payload.resize(size + string.size()); std::memcpy(payload.data() + size, string.data(), string.size()); diff --git a/app/src/main/cpp/skyline/kernel/memory.cpp b/app/src/main/cpp/skyline/kernel/memory.cpp index a8b19321..f0f1c597 100644 --- a/app/src/main/cpp/skyline/kernel/memory.cpp +++ b/app/src/main/cpp/skyline/kernel/memory.cpp @@ -61,7 +61,9 @@ namespace skyline::kernel { if (!base.address) throw exception("Cannot find a suitable carveout for the guest address space"); - mmap(reinterpret_cast(base.address), base.size, PROT_NONE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + auto result{mmap(reinterpret_cast(base.address), base.size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)}; + if (result == MAP_FAILED) [[unlikely]] + throw exception("Failed to mmap guest address space: {}", strerror(errno)); chunks = { ChunkDescriptor{ diff --git a/app/src/main/cpp/skyline/kernel/memory.h b/app/src/main/cpp/skyline/kernel/memory.h index 04f80a17..3a809928 100644 --- a/app/src/main/cpp/skyline/kernel/memory.h +++ b/app/src/main/cpp/skyline/kernel/memory.h @@ -25,7 +25,7 @@ namespace skyline { */ constexpr Permission(bool read, bool write, bool execute) : r(read), w(write), x(execute) {} - inline bool operator==(const Permission &rhs) const { return (this->r == rhs.r && this->w == rhs.w && this->x == rhs.x); } + inline bool operator==(const Permission &rhs) const { return r == rhs.r && w == rhs.w && x == rhs.x; } inline bool operator!=(const Permission &rhs) const { return !operator==(rhs); } @@ -176,7 +176,7 @@ namespace skyline { constexpr MemoryState KernelStack{0x00002013}; constexpr MemoryState CodeReadOnly{0x00402214}; constexpr MemoryState CodeWritable{0x00402015}; - }; + } struct Region { u64 address; diff --git a/app/src/main/cpp/skyline/kernel/scheduler.h b/app/src/main/cpp/skyline/kernel/scheduler.h index 54b88f60..acfb5e96 100644 --- a/app/src/main/cpp/skyline/kernel/scheduler.h +++ b/app/src/main/cpp/skyline/kernel/scheduler.h @@ -62,7 +62,7 @@ namespace skyline { * @note 'KThread::coreMigrationMutex' **must** be locked by the calling thread prior to calling this * @note This is used to handle non-cooperative core affinity mask changes where the resident core is not in its new affinity mask */ - void MigrateToCore(const std::shared_ptr &thread, CoreContext *¤tCore, CoreContext* targetCore, std::unique_lock &lock); + void MigrateToCore(const std::shared_ptr &thread, CoreContext *¤tCore, CoreContext *targetCore, std::unique_lock &lock); public: static constexpr std::chrono::milliseconds PreemptiveTimeslice{10}; //!< The duration of time a preemptive thread can run before yielding @@ -149,11 +149,11 @@ namespace skyline { const DeviceState &state; public: - inline SchedulerScopedLock(const DeviceState &state) : state(state) { + SchedulerScopedLock(const DeviceState &state) : state(state) { state.scheduler->RemoveThread(); } - inline ~SchedulerScopedLock() { + ~SchedulerScopedLock() { state.scheduler->InsertThread(state.thread); state.scheduler->WaitSchedule(); } diff --git a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.cpp b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.cpp index 06bb0f0e..95a2cf51 100644 --- a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.cpp @@ -87,4 +87,4 @@ namespace skyline::kernel::type { .state = memory::states::Unmapped, }); } -}; +} diff --git a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h index 35f634f2..a836ef1d 100644 --- a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h +++ b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h @@ -29,16 +29,10 @@ namespace skyline::kernel::type { */ void Remap(u8 *ptr, size_t size); - inline span Get() override { + span Get() override { return span(ptr, size); } - /** - * @brief Updates the permissions of a block of mapped memory - * @param address The starting address to change the permissions at - * @param size The size of the partition to change the permissions of - * @param permission The new permissions to be set for the memory - */ void UpdatePermission(u8 *ptr, size_t size, memory::Permission permission) override; /** diff --git a/app/src/main/cpp/skyline/kernel/types/KProcess.cpp b/app/src/main/cpp/skyline/kernel/types/KProcess.cpp index 8f97d927..b9ab5a59 100644 --- a/app/src/main/cpp/skyline/kernel/types/KProcess.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KProcess.cpp @@ -4,10 +4,11 @@ #include #include #include + #include "KProcess.h" namespace skyline::kernel::type { - KProcess::TlsPage::TlsPage(const std::shared_ptr &memory) : memory(memory) {} + KProcess::TlsPage::TlsPage(std::shared_ptr memory) : memory(std::move(memory)) {} u8 *KProcess::TlsPage::ReserveSlot() { if (index == constant::TlsSlots) diff --git a/app/src/main/cpp/skyline/kernel/types/KProcess.h b/app/src/main/cpp/skyline/kernel/types/KProcess.h index 2d93c17f..327f5732 100644 --- a/app/src/main/cpp/skyline/kernel/types/KProcess.h +++ b/app/src/main/cpp/skyline/kernel/types/KProcess.h @@ -43,7 +43,7 @@ namespace skyline { u8 index{}; //!< The slots are assigned sequentially, this holds the index of the last TLS slot reserved std::shared_ptr memory; //!< A single page sized memory allocation for this TLS page - TlsPage(const std::shared_ptr &memory); + TlsPage(std::shared_ptr memory); /** * @return A non-null pointer to a TLS page slot on success, a nullptr will be returned if this page is full @@ -197,7 +197,7 @@ namespace skyline { /** * @brief Closes a handle in the handle table */ - inline void CloseHandle(KHandle handle) { + void CloseHandle(KHandle handle) { handles.at(handle - constant::BaseHandleIndex) = nullptr; } diff --git a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.cpp b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.cpp index 68b73dec..9d96b9e6 100644 --- a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.cpp @@ -75,4 +75,4 @@ namespace skyline::kernel::type { close(fd); } -}; +} diff --git a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h index ae9866cc..47a01c47 100644 --- a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h +++ b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h @@ -31,7 +31,7 @@ namespace skyline::kernel::type { */ u8 *Map(u8 *ptr, u64 size, memory::Permission permission); - inline span Get() override { + span Get() override { return span(guest.ptr, guest.size); } diff --git a/app/src/main/cpp/skyline/kernel/types/KThread.cpp b/app/src/main/cpp/skyline/kernel/types/KThread.cpp index 23390c24..a500d335 100644 --- a/app/src/main/cpp/skyline/kernel/types/KThread.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KThread.cpp @@ -260,7 +260,7 @@ namespace skyline::kernel::type { if (ownerPriority != currentPriority) { std::lock_guard waiterLock(waitingOn->waiterMutex); auto nextThread{waitingOn->waitThread}; - if (nextThread){ + if (nextThread) { // We need to update the location of the owner thread in the waiter queue of the thread it's waiting on std::lock_guard nextWaiterLock(nextThread->waiterMutex); auto &piWaiters{nextThread->waiters}; diff --git a/app/src/main/cpp/skyline/loader/loader.cpp b/app/src/main/cpp/skyline/loader/loader.cpp index e94e0919..ec464ace 100644 --- a/app/src/main/cpp/skyline/loader/loader.cpp +++ b/app/src/main/cpp/skyline/loader/loader.cpp @@ -10,7 +10,7 @@ #include "loader.h" namespace skyline::loader { - Loader::ExecutableLoadInfo Loader::LoadExecutable(const std::shared_ptr process, const DeviceState &state, Executable &executable, size_t offset, const std::string &name) { + Loader::ExecutableLoadInfo Loader::LoadExecutable(const std::shared_ptr &process, const DeviceState &state, Executable &executable, size_t offset, const std::string &name) { u8 *base{reinterpret_cast(process->memory.base.address + offset)}; u64 textSize{executable.text.contents.size()}; @@ -109,7 +109,7 @@ namespace skyline::loader { return trace; } - std::string Loader::GetStackTrace(const std::vector frames) { + std::string Loader::GetStackTrace(const std::vector &frames) { std::string trace; for (const auto &frame : frames) trace += GetFunctionStackTrace(this, frame); diff --git a/app/src/main/cpp/skyline/loader/loader.h b/app/src/main/cpp/skyline/loader/loader.h index e39e718a..b5a4119c 100644 --- a/app/src/main/cpp/skyline/loader/loader.h +++ b/app/src/main/cpp/skyline/loader/loader.h @@ -80,7 +80,7 @@ namespace skyline::loader { * @param name An optional name for the executable, used for symbol resolution * @return An ExecutableLoadInfo struct containing the load base and size */ - ExecutableLoadInfo LoadExecutable(const std::shared_ptr process, const DeviceState &state, Executable &executable, size_t offset = 0, const std::string &name = {}); + ExecutableLoadInfo LoadExecutable(const std::shared_ptr &process, const DeviceState &state, Executable &executable, size_t offset = 0, const std::string &name = {}); std::optional nacp; std::shared_ptr romFs; @@ -94,7 +94,7 @@ namespace skyline::loader { /** * @return Entry point to the start of the main executable in the ROM */ - virtual void *LoadProcessData(const std::shared_ptr process, const DeviceState &state) = 0; + virtual void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) = 0; /** * @note The lifetime of the data contained within is tied to the lifetime of the Loader class it was obtained from (as this points to symbols from the executables loaded into memory directly) @@ -119,6 +119,6 @@ namespace skyline::loader { /** * @return A string with the stack trace based on the stack frames in the supplied vector */ - std::string GetStackTrace(const std::vector frames); + std::string GetStackTrace(const std::vector &frames); }; } diff --git a/app/src/main/cpp/skyline/loader/nca.cpp b/app/src/main/cpp/skyline/loader/nca.cpp index 292f1ef0..bbffef15 100644 --- a/app/src/main/cpp/skyline/loader/nca.cpp +++ b/app/src/main/cpp/skyline/loader/nca.cpp @@ -7,12 +7,12 @@ #include "nca.h" namespace skyline::loader { - NcaLoader::NcaLoader(const std::shared_ptr &backing, const std::shared_ptr &keyStore) : nca(backing, keyStore) { + NcaLoader::NcaLoader(std::shared_ptr backing, std::shared_ptr keyStore) : nca(std::move(backing), std::move(keyStore)) { if (nca.exeFs == nullptr) throw exception("Only NCAs with an ExeFS can be loaded directly"); } - void *NcaLoader::LoadExeFs(Loader *loader, const std::shared_ptr &exeFs, const std::shared_ptr process, const DeviceState &state) { + void *NcaLoader::LoadExeFs(Loader *loader, const std::shared_ptr &exeFs, const std::shared_ptr &process, const DeviceState &state) { if (exeFs == nullptr) throw exception("Cannot load a null ExeFS"); @@ -45,7 +45,7 @@ namespace skyline::loader { return entry; } - void *NcaLoader::LoadProcessData(const std::shared_ptr process, const DeviceState &state) { + void *NcaLoader::LoadProcessData(const std::shared_ptr &process, const DeviceState &state) { process->npdm = vfs::NPDM(nca.exeFs->OpenFile("main.npdm"), state); return LoadExeFs(this, nca.exeFs, process, state); } diff --git a/app/src/main/cpp/skyline/loader/nca.h b/app/src/main/cpp/skyline/loader/nca.h index 8bc9a5bf..a138004e 100644 --- a/app/src/main/cpp/skyline/loader/nca.h +++ b/app/src/main/cpp/skyline/loader/nca.h @@ -16,14 +16,14 @@ namespace skyline::loader { vfs::NCA nca; //!< The backing NCA of the loader public: - NcaLoader(const std::shared_ptr &backing, const std::shared_ptr &keyStore); + NcaLoader(std::shared_ptr backing, std::shared_ptr keyStore); /** * @brief Loads an ExeFS into memory and processes it accordingly for execution * @param exefs A filesystem object containing the ExeFS filesystem to load into memory */ - static void *LoadExeFs(Loader *loader, const std::shared_ptr &exefs, const std::shared_ptr process, const DeviceState &state); + static void *LoadExeFs(Loader *loader, const std::shared_ptr &exefs, const std::shared_ptr &process, const DeviceState &state); - void *LoadProcessData(const std::shared_ptr process, const DeviceState &state); + void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) override; }; } diff --git a/app/src/main/cpp/skyline/loader/nro.cpp b/app/src/main/cpp/skyline/loader/nro.cpp index f9628f53..0e80fac0 100644 --- a/app/src/main/cpp/skyline/loader/nro.cpp +++ b/app/src/main/cpp/skyline/loader/nro.cpp @@ -8,7 +8,7 @@ #include "nro.h" namespace skyline::loader { - NroLoader::NroLoader(const std::shared_ptr &backing) : backing(backing) { + NroLoader::NroLoader(std::shared_ptr pBacking) : backing(std::move(pBacking)) { header = backing->Read(); if (header.magic != util::MakeMagic("NRO0")) @@ -44,7 +44,7 @@ namespace skyline::loader { return buffer; } - void *NroLoader::LoadProcessData(const std::shared_ptr process, const DeviceState &state) { + void *NroLoader::LoadProcessData(const std::shared_ptr &process, const DeviceState &state) { Executable executable{}; executable.text.contents = GetSegment(header.text); diff --git a/app/src/main/cpp/skyline/loader/nro.h b/app/src/main/cpp/skyline/loader/nro.h index 03644ed0..38206161 100644 --- a/app/src/main/cpp/skyline/loader/nro.h +++ b/app/src/main/cpp/skyline/loader/nro.h @@ -68,10 +68,10 @@ namespace skyline::loader { std::vector GetSegment(const NroSegmentHeader &segment); public: - NroLoader(const std::shared_ptr &backing); + NroLoader(std::shared_ptr backing); - std::vector GetIcon(); + std::vector GetIcon() override; - void *LoadProcessData(const std::shared_ptr process, const DeviceState &state); + void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) override; }; } diff --git a/app/src/main/cpp/skyline/loader/nso.cpp b/app/src/main/cpp/skyline/loader/nso.cpp index 77f3acc5..71411901 100644 --- a/app/src/main/cpp/skyline/loader/nso.cpp +++ b/app/src/main/cpp/skyline/loader/nso.cpp @@ -7,7 +7,7 @@ #include "nso.h" namespace skyline::loader { - NsoLoader::NsoLoader(const std::shared_ptr &backing) : backing(backing) { + NsoLoader::NsoLoader(std::shared_ptr pBacking) : backing(std::move(pBacking)) { u32 magic{backing->Read()}; if (magic != util::MakeMagic("NSO0")) @@ -29,7 +29,7 @@ namespace skyline::loader { return outputBuffer; } - Loader::ExecutableLoadInfo NsoLoader::LoadNso(Loader *loader, const std::shared_ptr &backing, const std::shared_ptr process, const DeviceState &state, size_t offset, const std::string &name) { + Loader::ExecutableLoadInfo NsoLoader::LoadNso(Loader *loader, const std::shared_ptr &backing, const std::shared_ptr &process, const DeviceState &state, size_t offset, const std::string &name) { auto header{backing->Read()}; if (header.magic != util::MakeMagic("NSO0")) @@ -59,7 +59,7 @@ namespace skyline::loader { return loader->LoadExecutable(process, state, executable, offset, name); } - void *NsoLoader::LoadProcessData(const std::shared_ptr process, const DeviceState &state) { + void *NsoLoader::LoadProcessData(const std::shared_ptr &process, const DeviceState &state) { state.process->memory.InitializeVmm(memory::AddressSpaceType::AddressSpace39Bit); auto loadInfo{LoadNso(this, backing, process, state)}; state.process->memory.InitializeRegions(loadInfo.base, loadInfo.size); diff --git a/app/src/main/cpp/skyline/loader/nso.h b/app/src/main/cpp/skyline/loader/nso.h index 3d61a2cc..8ba29dce 100644 --- a/app/src/main/cpp/skyline/loader/nso.h +++ b/app/src/main/cpp/skyline/loader/nso.h @@ -78,7 +78,7 @@ namespace skyline::loader { static std::vector GetSegment(const std::shared_ptr &backing, const NsoSegmentHeader &segment, u32 compressedSize); public: - NsoLoader(const std::shared_ptr &backing); + NsoLoader(std::shared_ptr backing); /** * @brief Loads an NSO into memory, offset by the given amount @@ -87,8 +87,8 @@ namespace skyline::loader { * @param name An optional name for the NSO, used for symbol resolution * @return An ExecutableLoadInfo struct containing the load base and size */ - static ExecutableLoadInfo LoadNso(Loader *loader, const std::shared_ptr &backing, const std::shared_ptr process, const DeviceState &state, size_t offset = 0, const std::string &name = {}); + static ExecutableLoadInfo LoadNso(Loader *loader, const std::shared_ptr &backing, const std::shared_ptr &process, const DeviceState &state, size_t offset = 0, const std::string &name = {}); - void *LoadProcessData(const std::shared_ptr process, const DeviceState &state); + void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) override; }; } diff --git a/app/src/main/cpp/skyline/loader/nsp.cpp b/app/src/main/cpp/skyline/loader/nsp.cpp index b8ee49df..77d18e8c 100644 --- a/app/src/main/cpp/skyline/loader/nsp.cpp +++ b/app/src/main/cpp/skyline/loader/nsp.cpp @@ -10,7 +10,7 @@ namespace skyline::loader { auto root{nsp->OpenDirectory("", {false, true})}; for (const auto &entry : root->Read()) { - if (entry.name.substr(entry.name.find_last_of(".") + 1) != "nca") + if (entry.name.substr(entry.name.find_last_of('.') + 1) != "nca") continue; try { @@ -35,7 +35,7 @@ namespace skyline::loader { nacp.emplace(controlRomFs->OpenFile("control.nacp")); } - void *NspLoader::LoadProcessData(const std::shared_ptr process, const DeviceState &state) { + void *NspLoader::LoadProcessData(const std::shared_ptr &process, const DeviceState &state) { process->npdm = vfs::NPDM(programNca->exeFs->OpenFile("main.npdm"), state); return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state); } diff --git a/app/src/main/cpp/skyline/loader/nsp.h b/app/src/main/cpp/skyline/loader/nsp.h index 93a1ed96..36f4642a 100644 --- a/app/src/main/cpp/skyline/loader/nsp.h +++ b/app/src/main/cpp/skyline/loader/nsp.h @@ -24,8 +24,8 @@ namespace skyline::loader { public: NspLoader(const std::shared_ptr &backing, const std::shared_ptr &keyStore); - std::vector GetIcon(); + std::vector GetIcon() override; - void *LoadProcessData(const std::shared_ptr process, const DeviceState &state); + void *LoadProcessData(const std::shared_ptr &process, const DeviceState &state) override; }; } diff --git a/app/src/main/cpp/skyline/nce/instructions.h b/app/src/main/cpp/skyline/nce/instructions.h index dd71c226..665a9cd1 100644 --- a/app/src/main/cpp/skyline/nce/instructions.h +++ b/app/src/main/cpp/skyline/nce/instructions.h @@ -19,13 +19,8 @@ namespace skyline::nce { struct Brk { /** * @brief Creates a BRK instruction with a specific immediate value, used for generating BRK opcodes - * @param value The immediate value of the instruction */ - constexpr Brk(u16 value) { - sig0 = 0x0; - this->value = value; - sig1 = 0x6A1; - } + constexpr Brk(u16 value) : sig0(0x0), value(value), sig1(0x6A1) {} constexpr bool Verify() { return (sig0 == 0x0 && sig1 == 0x6A1); @@ -65,15 +60,7 @@ namespace skyline::nce { * @url https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/mrs-move-system-register */ struct Mrs { - /** - * @param srcReg The source system register - * @param dstReg The destination Xn register - */ - constexpr Mrs(u32 srcReg, registers::X dstReg) { - this->srcReg = srcReg; - this->destReg = dstReg; - sig = 0xD53; - } + constexpr Mrs(u32 srcReg, registers::X destReg) : srcReg(srcReg), destReg(destReg), sig(0xD54) {} constexpr bool Verify() { return (sig == 0xD53); @@ -115,12 +102,9 @@ namespace skyline::nce { struct B { public: /** - * @param offset The relative offset to branch to (In 32-bit units) + * @param negate The direction of the supplied offset */ - constexpr B(i64 offset, bool negate = false) { - this->offset = negate ? -offset : offset; - sig = 0x5; - } + constexpr B(i64 offset, bool negate = false) : offset(negate ? -offset : offset), sig(0x5) {} /** * @return The offset encoded within the instruction in bytes @@ -148,13 +132,7 @@ namespace skyline::nce { */ struct BL { public: - /** - * @param offset The relative offset to branch to (In 32-bit units) - */ - constexpr BL(i32 offset) { - this->offset = offset; - sig = 0x25; - } + constexpr BL(i32 offset) : offset(offset), sig(0x25) {} /** * @return The offset encoded within the instruction in bytes @@ -187,26 +165,14 @@ namespace skyline::nce { * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - constexpr Movz(registers::X destReg, u16 imm16, u8 shift = 0) { - this->destReg = static_cast(destReg); - this->imm16 = imm16; - hw = shift; - sig = 0xA5; - sf = 1; - } + constexpr Movz(registers::X destReg, u16 imm16, u8 shift = 0) : destReg(static_cast(destReg)), imm16(imm16), hw(shift), sig(0xA5), sf(1) {} /** * @param destReg The destination Wn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - constexpr Movz(registers::W destReg, u16 imm16, u8 shift = 0) { - this->destReg = static_cast(destReg); - this->imm16 = imm16; - hw = shift; - sig = 0xA5; - sf = 0; - } + constexpr Movz(registers::W destReg, u16 imm16, u8 shift = 0) : destReg(static_cast(destReg)), imm16(imm16), hw(shift), sig(0xA5), sf(0) {} /** * @return The shift encoded within the instruction in bytes @@ -242,26 +208,14 @@ namespace skyline::nce { * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - constexpr Movk(registers::X destReg, u16 imm16, u8 shift = 0) { - this->destReg = static_cast(destReg); - this->imm16 = imm16; - hw = shift; - sig = 0xE5; - sf = 1; - } + constexpr Movk(registers::X destReg, u16 imm16, u8 shift = 0) : destReg(static_cast(destReg)), imm16(imm16), hw(shift), sig(0xE5), sf(1) {} /** * @param destReg The destination Wn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - constexpr Movk(registers::W destReg, u16 imm16, u8 shift = 0) { - this->destReg = static_cast(destReg); - this->imm16 = imm16; - hw = shift; - sig = 0xE5; - sf = 0; - } + constexpr Movk(registers::W destReg, u16 imm16, u8 shift = 0) : destReg(static_cast(destReg)), imm16(imm16), hw(shift), sig(0xE5), sf(0) {} /** * @return The shift encoded within the instruction in bytes @@ -329,28 +283,14 @@ namespace skyline::nce { * @param destReg The destination Xn register to store the value in * @param srcReg The source Xn register to retrieve the value from */ - constexpr Mov(registers::X destReg, registers::X srcReg) { - this->destReg = static_cast(destReg); - sig0 = 0x1F; - imm = 0; - this->srcReg = static_cast(srcReg); - sig1 = 0x150; - sf = 1; - } + constexpr Mov(registers::X destReg, registers::X srcReg) : destReg(static_cast(destReg)), sig0(0x1F), imm(0), srcReg(static_cast(srcReg)), sig1(0x150), sf(1) {} /** * @brief Creates a MOV instruction * @param destReg The destination Wn register to store the value in * @param srcReg The source Wn register to retrieve the value from */ - constexpr Mov(registers::W destReg, registers::W srcReg) { - this->destReg = static_cast(destReg); - sig0 = 0x1F; - imm = 0; - this->srcReg = static_cast(srcReg); - sig1 = 0x150; - sf = 0; - } + constexpr Mov(registers::W destReg, registers::W srcReg) : destReg(static_cast(destReg)), sig0(0x1F), imm(0), srcReg(static_cast(srcReg)), sig1(0x150), sf(0) {} constexpr bool Verify() { return (sig0 == 0x1F) && (sig1 == 0x150); diff --git a/app/src/main/cpp/skyline/os.cpp b/app/src/main/cpp/skyline/os.cpp index 018119e8..fe7544f6 100644 --- a/app/src/main/cpp/skyline/os.cpp +++ b/app/src/main/cpp/skyline/os.cpp @@ -12,20 +12,20 @@ #include "os.h" namespace skyline::kernel { - OS::OS(std::shared_ptr &jvmManager, std::shared_ptr &logger, std::shared_ptr &settings, const std::string &appFilesPath) : state(this, jvmManager, settings, logger), serviceManager(state), appFilesPath(appFilesPath) {} + OS::OS(std::shared_ptr &jvmManager, std::shared_ptr &logger, std::shared_ptr &settings, std::string appFilesPath) : state(this, jvmManager, settings, logger), serviceManager(state), appFilesPath(std::move(appFilesPath)) {} void OS::Execute(int romFd, loader::RomFormat romType) { auto romFile{std::make_shared(romFd)}; auto keyStore{std::make_shared(appFilesPath)}; - state.loader = [=]() -> std::shared_ptr { + state.loader = [&]() -> std::shared_ptr { switch (romType) { case loader::RomFormat::NRO: - return std::make_shared(romFile); + return std::make_shared(std::move(romFile)); case loader::RomFormat::NSO: - return std::make_shared(romFile); + return std::make_shared(std::move(romFile)); case loader::RomFormat::NCA: - return std::make_shared(romFile, keyStore); + return std::make_shared(std::move(romFile), std::move(keyStore)); case loader::RomFormat::NSP: return std::make_shared(romFile, keyStore); default: diff --git a/app/src/main/cpp/skyline/os.h b/app/src/main/cpp/skyline/os.h index ca6703d1..802a565a 100644 --- a/app/src/main/cpp/skyline/os.h +++ b/app/src/main/cpp/skyline/os.h @@ -21,7 +21,7 @@ namespace skyline::kernel { * @param settings An instance of the Settings class * @param window The ANativeWindow object to draw the screen to */ - OS(std::shared_ptr &jvmManager, std::shared_ptr &logger, std::shared_ptr &settings, const std::string &appFilesPath); + OS(std::shared_ptr &jvmManager, std::shared_ptr &logger, std::shared_ptr &settings, std::string appFilesPath); /** * @brief Execute a particular ROM file diff --git a/app/src/main/cpp/skyline/services/am/storage/IStorage.h b/app/src/main/cpp/skyline/services/am/storage/IStorage.h index e815e2a5..54914a18 100644 --- a/app/src/main/cpp/skyline/services/am/storage/IStorage.h +++ b/app/src/main/cpp/skyline/services/am/storage/IStorage.h @@ -28,7 +28,7 @@ namespace skyline::service::am { * @brief Writes an object to the storage */ template - inline void Push(const ValueType &value) { + void Push(const ValueType &value) { if (offset + sizeof(ValueType) > content.size()) throw exception("The supplied value cannot fit into the IStorage"); diff --git a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp index 09aaccd9..f88150bb 100644 --- a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp +++ b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.cpp @@ -5,7 +5,7 @@ #include "IStorageAccessor.h" namespace skyline::service::am { - IStorageAccessor::IStorageAccessor(const DeviceState &state, ServiceManager &manager, std::shared_ptr parent) : parent(parent), BaseService(state, manager) {} + IStorageAccessor::IStorageAccessor(const DeviceState &state, ServiceManager &manager, std::shared_ptr parent) : parent(std::move(parent)), BaseService(state, manager) {} Result IStorageAccessor::GetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { response.Push(parent->content.size()); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioOut.cpp b/app/src/main/cpp/skyline/services/audio/IAudioOut.cpp index db974dd7..6a0ad062 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioOut.cpp +++ b/app/src/main/cpp/skyline/services/audio/IAudioOut.cpp @@ -6,7 +6,7 @@ namespace skyline::service::audio { IAudioOut::IAudioOut(const DeviceState &state, ServiceManager &manager, u8 channelCount, u32 sampleRate) : sampleRate(sampleRate), channelCount(channelCount), releaseEvent(std::make_shared(state, false)), BaseService(state, manager) { - track = state.audio->OpenTrack(channelCount, constant::SampleRate, [this]() { this->releaseEvent->Signal(); }); + track = state.audio->OpenTrack(channelCount, constant::SampleRate, [this]() { releaseEvent->Signal(); }); } IAudioOut::~IAudioOut() { diff --git a/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h b/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h index 80438533..d1332407 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h @@ -9,7 +9,7 @@ namespace skyline { namespace constant { constexpr std::string_view DefaultAudioOutName{"DeviceOut"}; //!< The default audio output device name - }; + } namespace service::audio { /** diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.cpp b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.cpp index a7dd5c5b..842c4f39 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.cpp +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.cpp @@ -7,7 +7,7 @@ namespace skyline::service::audio::IAudioRenderer { IAudioRenderer::IAudioRenderer(const DeviceState &state, ServiceManager &manager, AudioRendererParameters ¶meters) : systemEvent(std::make_shared(state, true)), parameters(parameters), BaseService(state, manager) { - track = state.audio->OpenTrack(constant::ChannelCount, constant::SampleRate, [&]() {systemEvent->Signal();}); + track = state.audio->OpenTrack(constant::ChannelCount, constant::SampleRate, [&]() { systemEvent->Signal(); }); track->Start(); memoryPools.resize(parameters.effectCount + parameters.voiceCount * 4); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h index 190ae1b3..df085b97 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h @@ -37,7 +37,7 @@ namespace skyline::service::audio::IAudioRenderer { public: EffectOut output{}; - inline void ProcessInput(const EffectIn &input) { + void ProcessInput(const EffectIn &input) { if (input.isNew) output.state = EffectState::New; } diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h index 772ce979..a693b35e 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h @@ -17,7 +17,7 @@ namespace skyline { constexpr u32 PerformanceMetricsDataFormatV2{5}; //!< The revision a new performance metrics format is used constexpr u32 VaradicCommandBufferSize{5}; //!< The revision support for varying command buffer sizes was added constexpr u32 ElapsedFrameCount{5}; //!< The revision support for counting elapsed frames was added - }; + } } namespace service::audio::IAudioRenderer { @@ -42,7 +42,7 @@ namespace skyline { * @brief Extracts the audren revision from the magic and sets the behaviour revision to it * @param revision The revision magic from guest */ - inline void SetUserRevision(u32 revision) { + void SetUserRevision(u32 revision) { userRevision = ExtractVersionFromRevision(revision); if (userRevision > constant::SupportedRevision) @@ -52,35 +52,35 @@ namespace skyline { /** * @return Whether the splitter is supported */ - inline bool SplitterSupported() { + bool SplitterSupported() { return userRevision >= constant::supportTags::Splitter; } /** * @return Whether the splitter is fixed */ - inline bool SplitterBugFixed() { + bool SplitterBugFixed() { return userRevision >= constant::supportTags::SplitterBugFix; } /** * @return Whether the new performance metrics format is used */ - inline bool UsesPerformanceMetricDataFormatV2() { + bool UsesPerformanceMetricDataFormatV2() { return userRevision >= constant::supportTags::PerformanceMetricsDataFormatV2; } /** * @return Whether varying command buffer sizes are supported */ - inline bool VaradicCommandBufferSizeSupported() { + bool VaradicCommandBufferSizeSupported() { return userRevision >= constant::supportTags::VaradicCommandBufferSize; } /** * @return Whether elapsed frame counting is supported */ - inline bool ElapsedFrameCountSupported() { + bool ElapsedFrameCountSupported() { return userRevision >= constant::supportTags::ElapsedFrameCount; } }; diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.cpp b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.cpp index 7b95e5bb..52db99d7 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.cpp +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.cpp @@ -45,7 +45,7 @@ namespace skyline::service::audio::IAudioRenderer { std::vector> adpcmCoefficients(input.adpcmCoeffsSize / (sizeof(u16) * 2)); span(adpcmCoefficients).copy_from(span(input.adpcmCoeffs, input.adpcmCoeffsSize / sizeof(u32))); - adpcmDecoder = skyline::audio::AdpcmDecoder(adpcmCoefficients); + adpcmDecoder = skyline::audio::AdpcmDecoder(std::move(adpcmCoefficients)); } SetWaveBufferIndex(static_cast(input.baseWaveBufferIndex)); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h index ee3134c3..e289949f 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h @@ -122,7 +122,7 @@ namespace skyline::service::audio::IAudioRenderer { /** * @return If the voice is currently playable */ - inline bool Playable() { + bool Playable() { return acquired && playbackState == skyline::audio::AudioOutState::Started && waveBuffers[bufferIndex].size != 0; } }; diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index e21b94e6..6f2bd7cd 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -10,7 +10,7 @@ #define SERVICE_DECL_AUTO(name, value) decltype(value) name = value #define SERVICE_DECL(...) \ SERVICE_DECL_AUTO(functions, frz::make_unordered_map({__VA_ARGS__})); \ -std::pair, std::string_view> GetServiceFunction(u32 id) { \ +std::pair, std::string_view> GetServiceFunction(u32 id) override { \ auto& function{functions.at(id)}; \ return std::make_pair(std::bind(function.first, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), function.second); \ } @@ -63,6 +63,6 @@ namespace skyline::service { /** * @brief Handles an IPC Request to a service */ - Result HandleRequest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);; + Result HandleRequest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); }; } diff --git a/app/src/main/cpp/skyline/services/common/fence.h b/app/src/main/cpp/skyline/services/common/fence.h index 28aab664..8407811d 100644 --- a/app/src/main/cpp/skyline/services/common/fence.h +++ b/app/src/main/cpp/skyline/services/common/fence.h @@ -16,7 +16,7 @@ namespace skyline::service::nvdrv { /** * @brief Synchronizes the fence's value with its underlying syncpoint */ - inline void UpdateValue(NvHostSyncpoint &hostSyncpoint) { + void UpdateValue(NvHostSyncpoint &hostSyncpoint) { value = hostSyncpoint.UpdateMin(id); } }; diff --git a/app/src/main/cpp/skyline/services/common/parcel.h b/app/src/main/cpp/skyline/services/common/parcel.h index 46b4031a..faac6805 100644 --- a/app/src/main/cpp/skyline/services/common/parcel.h +++ b/app/src/main/cpp/skyline/services/common/parcel.h @@ -43,7 +43,7 @@ namespace skyline::service { * @return A reference to an item from the top of data */ template - inline ValueType &Pop() { + ValueType &Pop() { ValueType &value{*reinterpret_cast(data.data() + dataOffset)}; dataOffset += sizeof(ValueType); return value; diff --git a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp index eeb08a93..7471c8c3 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IDirectory.cpp @@ -21,7 +21,7 @@ namespace skyline::service::fssrv { u64 size; }; - IDirectory::IDirectory(std::shared_ptr backing, std::shared_ptr backingFs, const DeviceState &state, ServiceManager &manager) : backing(backing), backingFs(backingFs), BaseService(state, manager) {} + IDirectory::IDirectory(std::shared_ptr backing, std::shared_ptr backingFs, const DeviceState &state, ServiceManager &manager) : backing(std::move(backing)), backingFs(std::move(backingFs)), BaseService(state, manager) {} Result IDirectory::Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto entries{backing->Read()}; diff --git a/app/src/main/cpp/skyline/services/fssrv/IFile.cpp b/app/src/main/cpp/skyline/services/fssrv/IFile.cpp index 9d336e99..96c89df5 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFile.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IFile.cpp @@ -5,7 +5,7 @@ #include "IFile.h" namespace skyline::service::fssrv { - IFile::IFile(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager) : backing(backing), BaseService(state, manager) {} + IFile::IFile(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager) : backing(std::move(backing)), BaseService(state, manager) {} Result IFile::Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto readOption{request.Pop()}; diff --git a/app/src/main/cpp/skyline/services/fssrv/IFile.h b/app/src/main/cpp/skyline/services/fssrv/IFile.h index 5742fc42..44afe910 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFile.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFile.h @@ -16,7 +16,7 @@ namespace skyline::service::fssrv { std::shared_ptr backing; public: - IFile(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager); + IFile(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager); /** * @brief Reads a buffer from a region of an IFile diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp index 179aa47f..2b8fa0c9 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.cpp @@ -7,7 +7,7 @@ #include "IFileSystem.h" namespace skyline::service::fssrv { - IFileSystem::IFileSystem(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager) : backing(backing), BaseService(state, manager) {} + IFileSystem::IFileSystem(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager) : backing(std::move(backing)), BaseService(state, manager) {} Result IFileSystem::CreateFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { std::string path(request.inputBuf.at(0).as_string(true)); @@ -42,7 +42,7 @@ namespace skyline::service::fssrv { if (file == nullptr) return result::UnexpectedFailure; else - manager.RegisterService(std::make_shared(file, state, manager), session, response); + manager.RegisterService(std::make_shared(std::move(file), state, manager), session, response); return {}; } @@ -56,7 +56,7 @@ namespace skyline::service::fssrv { auto listMode{request.Pop()}; auto directory{backing->OpenDirectory(path, listMode)}; - manager.RegisterService(std::make_shared(directory, backing, state, manager), session, response); + manager.RegisterService(std::make_shared(std::move(directory), backing, state, manager), session, response); return {}; } diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp index 1c337776..13ffff5d 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.cpp @@ -12,7 +12,7 @@ namespace skyline::service::fssrv { IFileSystemProxy::IFileSystemProxy(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} Result IFileSystemProxy::SetCurrentProcess(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - process = request.Pop(); + process = request.Pop(); return {}; } @@ -39,7 +39,7 @@ namespace skyline::service::fssrv { return "/nand/temp"; default: throw exception("Unsupported savedata ID: {}", spaceId); - }; + } }()}; switch (attribute.type) { @@ -54,7 +54,7 @@ namespace skyline::service::fssrv { return fmt::format("{}/save/cache/{:016X}/", spaceIdStr, attribute.programId); default: throw exception("Unsupported savedata type: {}", attribute.type); - }; + } }()}; manager.RegisterService(std::make_shared(std::make_shared(state.os->appFilesPath + "/switch" + saveDataPath), state, manager), session, response); diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h index ac85e25d..09279ce6 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h @@ -48,7 +48,7 @@ namespace skyline::service::fssrv { */ class IFileSystemProxy : public BaseService { public: - pid_t process{}; //!< The PID as set by SetCurrentProcess + u64 process{}; //!< The PID as set by SetCurrentProcess IFileSystemProxy(const DeviceState &state, ServiceManager &manager); diff --git a/app/src/main/cpp/skyline/services/fssrv/IStorage.cpp b/app/src/main/cpp/skyline/services/fssrv/IStorage.cpp index b6c2eda9..7c1c547d 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IStorage.cpp +++ b/app/src/main/cpp/skyline/services/fssrv/IStorage.cpp @@ -5,7 +5,7 @@ #include "IStorage.h" namespace skyline::service::fssrv { - IStorage::IStorage(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager) : backing(backing), BaseService(state, manager) {} + IStorage::IStorage(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager) : backing(std::move(backing)), BaseService(state, manager) {} Result IStorage::Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { auto offset{request.Pop()}; diff --git a/app/src/main/cpp/skyline/services/fssrv/IStorage.h b/app/src/main/cpp/skyline/services/fssrv/IStorage.h index 866a480b..35032a64 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IStorage.h +++ b/app/src/main/cpp/skyline/services/fssrv/IStorage.h @@ -16,7 +16,7 @@ namespace skyline::service::fssrv { std::shared_ptr backing; public: - IStorage(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager); + IStorage(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager); /** * @brief Reads a buffer from a region of an IStorage diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp index 9950b397..dba07dfd 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp @@ -10,7 +10,7 @@ #include "GraphicBufferProducer.h" namespace skyline::service::hosbinder { - Buffer::Buffer(const GbpBuffer &gbpBuffer, const std::shared_ptr &texture) : gbpBuffer(gbpBuffer), texture(texture) {} + Buffer::Buffer(const GbpBuffer &gbpBuffer, std::shared_ptr texture) : gbpBuffer(gbpBuffer), texture(std::move(texture)) {} GraphicBufferProducer::GraphicBufferProducer(const DeviceState &state) : state(state) {} @@ -35,7 +35,7 @@ namespace skyline::service::hosbinder { std::optional slot{std::nullopt}; while (!slot) { for (auto &buffer : queue) { - if (buffer.second->status == BufferStatus::Free && (format ? buffer.second->gbpBuffer.format == format : true) && buffer.second->gbpBuffer.width == width && buffer.second->gbpBuffer.height == height && (buffer.second->gbpBuffer.usage & usage) == usage) { + if (buffer.second->status == BufferStatus::Free && (format == 0 || buffer.second->gbpBuffer.format == format) && buffer.second->gbpBuffer.width == width && buffer.second->gbpBuffer.height == height && (buffer.second->gbpBuffer.usage & usage) == usage) { slot = buffer.first; buffer.second->status = BufferStatus::Dequeued; break; diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h index a4ad1d25..d6355f7b 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h @@ -50,7 +50,7 @@ namespace skyline::service::hosbinder { std::shared_ptr texture; GbpBuffer gbpBuffer; - Buffer(const GbpBuffer &gbpBuffer, const std::shared_ptr &texture); + Buffer(const GbpBuffer &gbpBuffer, std::shared_ptr texture); }; /** diff --git a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp index 0ad93b7d..e25127e0 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.cpp @@ -140,7 +140,6 @@ namespace skyline::service::nvdrv { else buffer = request.outputBuf[0]; - response.Push(device->HandleIoctl(cmd, device::IoctlType::Ioctl3, buffer, request.outputBuf.size() >= 2 ? request.outputBuf[1] : span())); return {}; } diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h index 9d4a85f8..58d6e554 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h @@ -10,7 +10,7 @@ #define NVDEVICE_DECL_AUTO(name, value) decltype(value) name = value #define NVDEVICE_DECL(...) \ NVDEVICE_DECL_AUTO(functions, frz::make_unordered_map({__VA_ARGS__})); \ -std::pair, span)>, std::string_view> GetIoctlFunction(u32 id) { \ +std::pair, span)>, std::string_view> GetIoctlFunction(u32 id) override { \ auto& function{functions.at(id)}; \ return std::make_pair(std::bind(function.first, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), function.second); \ } @@ -68,7 +68,7 @@ namespace skyline::service::nvdrv::device { const DeviceState &state; public: - inline NvDevice(const DeviceState &state) : state(state) {} + NvDevice(const DeviceState &state) : state(state) {} virtual ~NvDevice() = default; @@ -86,7 +86,7 @@ namespace skyline::service::nvdrv::device { */ NvStatus HandleIoctl(u32 cmd, IoctlType type, span buffer, span inlineBuffer); - inline virtual std::shared_ptr QueryEvent(u32 eventId) { + virtual std::shared_ptr QueryEvent(u32 eventId) { return nullptr; } }; diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h index 0da5632c..8e45ea8e 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h @@ -88,7 +88,7 @@ namespace skyline::service::nvdrv::device { */ NvStatus SetUserData(IoctlType type, span buffer, span inlineBuffer); - std::shared_ptr QueryEvent(u32 eventId); + std::shared_ptr QueryEvent(u32 eventId) override; NVDEVICE_DECL( NVFUNC(0x4801, NvHostChannel, SetNvmapFd), diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.cpp index c749d7b1..9ad1a5ba 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.cpp @@ -54,15 +54,14 @@ namespace skyline::service::nvdrv::device { event->ResetSignal(); } - void SyncpointEvent::Wait(const std::shared_ptr &gpuState, const Fence &fence) { + void SyncpointEvent::Wait(const std::shared_ptr &gpuState, const Fence &pFence) { std::lock_guard lock(mutex); - this->fence = fence; + fence = pFence; state = State::Waiting; waiterId = gpuState->syncpoints.at(fence.id).RegisterWaiter(fence.value, [this] { Signal(); }); } - NvHostCtrl::NvHostCtrl(const DeviceState &state) : NvDevice(state) {} u32 NvHostCtrl::FindFreeSyncpointEvent(u32 syncpointId) { diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h index 667efb9e..b2b0f682 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h @@ -99,7 +99,7 @@ namespace skyline { */ NvStatus SyncpointRegisterEvent(IoctlType type, span buffer, span inlineBuffer); - std::shared_ptr QueryEvent(u32 eventId); + std::shared_ptr QueryEvent(u32 eventId) override; NVDEVICE_DECL( NVFUNC(0x001B, NvHostCtrl, GetConfig), diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h index ff7009f2..8128486d 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h @@ -48,7 +48,7 @@ namespace skyline::service::nvdrv::device { */ NvStatus GetActiveSlotMask(IoctlType type, span buffer, span inlineBuffer); - std::shared_ptr QueryEvent(u32 eventId); + std::shared_ptr QueryEvent(u32 eventId) override; NVDEVICE_DECL( NVFUNC(0x4701, NvHostCtrlGpu, ZCullGetCtxSize), diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h index 53fabec2..a40fef9b 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h @@ -39,7 +39,7 @@ namespace skyline::service::nvdrv::device { NvMap(const DeviceState &state); - inline std::shared_ptr GetObject(u32 handle) { + std::shared_ptr GetObject(u32 handle) { if (handle-- == 0) throw std::out_of_range("0 is an invalid nvmap handle"); std::shared_lock lock(mapMutex); diff --git a/app/src/main/cpp/skyline/services/nvdrv/driver.h b/app/src/main/cpp/skyline/services/nvdrv/driver.h index 377153ae..45cb0ab3 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/driver.h +++ b/app/src/main/cpp/skyline/services/nvdrv/driver.h @@ -62,7 +62,7 @@ namespace skyline::service::nvdrv { * @return A shared pointer to the device */ template - inline std::shared_ptr GetDevice(u32 fd) { + std::shared_ptr GetDevice(u32 fd) { return std::static_pointer_cast(GetDevice(fd)); } diff --git a/app/src/main/cpp/skyline/services/serviceman.h b/app/src/main/cpp/skyline/services/serviceman.h index 777d00bc..f983434d 100644 --- a/app/src/main/cpp/skyline/services/serviceman.h +++ b/app/src/main/cpp/skyline/services/serviceman.h @@ -47,7 +47,7 @@ namespace skyline::service { void RegisterService(std::shared_ptr serviceObject, type::KSession &session, ipc::IpcResponse &response); template - inline void RegisterService(std::shared_ptr serviceObject, type::KSession &session, ipc::IpcResponse &response) { + void RegisterService(std::shared_ptr serviceObject, type::KSession &session, ipc::IpcResponse &response) { RegisterService(std::static_pointer_cast(serviceObject), session, response); } diff --git a/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.cpp b/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.cpp index 0b6788ca..9b7d2a3e 100644 --- a/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.cpp +++ b/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.cpp @@ -7,7 +7,7 @@ namespace skyline::service::timesrv { ITimeZoneService::ITimeZoneService(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} Result ITimeZoneService::ToCalendarTimeWithMyRule(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - auto& time{request.Pop()}; + auto &time{request.Pop()}; auto calender{*std::gmtime(reinterpret_cast(&time))}; CalendarTime calendarTime{ diff --git a/app/src/main/cpp/skyline/vfs/backing.h b/app/src/main/cpp/skyline/vfs/backing.h index aec2bcd7..8eca7d8b 100644 --- a/app/src/main/cpp/skyline/vfs/backing.h +++ b/app/src/main/cpp/skyline/vfs/backing.h @@ -48,7 +48,7 @@ namespace skyline::vfs { * @brief Implicit casting for reading into spans of different types */ template, bool>::type = true> - inline size_t Read(span output, size_t offset = 0) { + size_t Read(span output, size_t offset = 0) { return Read(output.template cast(), offset); } @@ -58,7 +58,7 @@ namespace skyline::vfs { * @return The object that was read */ template - inline T Read(size_t offset = 0) { + T Read(size_t offset = 0) { T object; Read(span(reinterpret_cast(&object), sizeof(T)), offset); return object; @@ -80,7 +80,7 @@ namespace skyline::vfs { * @param offset The offset where the input should be written */ template - inline void WriteObject(const T &object, size_t offset = 0) { + void WriteObject(const T &object, size_t offset = 0) { size_t size; if ((size = Write(span(reinterpret_cast(&object), sizeof(T)), offset)) != sizeof(T)) throw exception("Object wasn't written fully into output backing: {}/{}", size, sizeof(T)); diff --git a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.cpp b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.cpp index 75157e61..d9e15d08 100644 --- a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.cpp +++ b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.cpp @@ -6,7 +6,7 @@ namespace skyline::vfs { constexpr size_t SectorSize{0x10}; - CtrEncryptedBacking::CtrEncryptedBacking(crypto::KeyStore::Key128 &ctr, crypto::KeyStore::Key128 &key, const std::shared_ptr &backing, size_t baseOffset) : Backing({true, false, false}), ctr(ctr), cipher(key, MBEDTLS_CIPHER_AES_128_CTR), backing(backing), baseOffset(baseOffset) {} + CtrEncryptedBacking::CtrEncryptedBacking(crypto::KeyStore::Key128 ctr, crypto::KeyStore::Key128 key, std::shared_ptr backing, size_t baseOffset) : Backing({true, false, false}), ctr(ctr), cipher(key, MBEDTLS_CIPHER_AES_128_CTR), backing(std::move(backing)), baseOffset(baseOffset) {} void CtrEncryptedBacking::UpdateCtr(u64 offset) { offset >>= 4; diff --git a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h index b97d8e80..4809d8dc 100644 --- a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h +++ b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h @@ -25,7 +25,7 @@ namespace skyline::vfs { void UpdateCtr(u64 offset); public: - CtrEncryptedBacking(crypto::KeyStore::Key128 &ctr, crypto::KeyStore::Key128 &key, const std::shared_ptr &backing, size_t baseOffset); + CtrEncryptedBacking(crypto::KeyStore::Key128 ctr, crypto::KeyStore::Key128 key, std::shared_ptr backing, size_t baseOffset); size_t Read(span output, size_t offset = 0) override; }; diff --git a/app/src/main/cpp/skyline/vfs/filesystem.h b/app/src/main/cpp/skyline/vfs/filesystem.h index 5178326b..c292625f 100644 --- a/app/src/main/cpp/skyline/vfs/filesystem.h +++ b/app/src/main/cpp/skyline/vfs/filesystem.h @@ -61,7 +61,7 @@ namespace skyline::vfs { * @param path The path to the file * @return Whether the file exists */ - inline bool FileExists(const std::string &path) { + bool FileExists(const std::string &path) { auto entry{GetEntryType(path)}; return entry && *entry == Directory::EntryType::File; } @@ -71,7 +71,7 @@ namespace skyline::vfs { * @param path The path to the directory * @return Whether the directory exists */ - inline bool DirectoryExists(const std::string &path) { + bool DirectoryExists(const std::string &path) { auto entry{GetEntryType(path)}; return entry && *entry == Directory::EntryType::Directory; } diff --git a/app/src/main/cpp/skyline/vfs/nca.cpp b/app/src/main/cpp/skyline/vfs/nca.cpp index 4abb2a09..b276845c 100644 --- a/app/src/main/cpp/skyline/vfs/nca.cpp +++ b/app/src/main/cpp/skyline/vfs/nca.cpp @@ -3,6 +3,7 @@ #include #include + #include "ctr_encrypted_backing.h" #include "region_backing.h" #include "partition_filesystem.h" @@ -13,7 +14,7 @@ namespace skyline::vfs { using namespace loader; - NCA::NCA(const std::shared_ptr &backing, const std::shared_ptr &keyStore) : backing(backing), keyStore(keyStore) { + NCA::NCA(std::shared_ptr pBacking, std::shared_ptr pKeyStore) : backing(std::move(pBacking)), keyStore(std::move(pKeyStore)) { header = backing->Read(); if (header.magic != util::MakeMagic("NCA3")) { @@ -116,7 +117,7 @@ namespace skyline::vfs { } crypto::KeyStore::Key128 NCA::GetKeyAreaKey(NCA::NcaSectionEncryptionType type) { - auto keyArea{[&](crypto::KeyStore::IndexedKeys128 &keys) { + auto keyArea{[this, &type](crypto::KeyStore::IndexedKeys128 &keys) { u8 keyGeneration{GetKeyGeneration()}; auto &keyArea{keys[keyGeneration]}; diff --git a/app/src/main/cpp/skyline/vfs/nca.h b/app/src/main/cpp/skyline/vfs/nca.h index 0ebe94b7..ca2a8296 100644 --- a/app/src/main/cpp/skyline/vfs/nca.h +++ b/app/src/main/cpp/skyline/vfs/nca.h @@ -193,7 +193,7 @@ namespace skyline { std::shared_ptr romFs; //!< The backing for this NCA's RomFS section NcaContentType contentType; //!< The content type of the NCA - NCA(const std::shared_ptr &backing, const std::shared_ptr &keyStore); + NCA(std::shared_ptr backing, std::shared_ptr keyStore); }; } } diff --git a/app/src/main/cpp/skyline/vfs/npdm.h b/app/src/main/cpp/skyline/vfs/npdm.h index fefc8c4d..628cfec7 100644 --- a/app/src/main/cpp/skyline/vfs/npdm.h +++ b/app/src/main/cpp/skyline/vfs/npdm.h @@ -19,7 +19,7 @@ namespace skyline { u32 size; template - inline T Read(const std::shared_ptr &backing, size_t baseOffset = 0) { + T Read(const std::shared_ptr &backing, size_t baseOffset = 0) { if (sizeof(T) > size) throw exception("Section size ({}) smaller than Read type size ({})", size, sizeof(T)); return backing->Read(baseOffset + offset); diff --git a/app/src/main/cpp/skyline/vfs/os_backing.cpp b/app/src/main/cpp/skyline/vfs/os_backing.cpp index fb56d789..a0e8f41f 100644 --- a/app/src/main/cpp/skyline/vfs/os_backing.cpp +++ b/app/src/main/cpp/skyline/vfs/os_backing.cpp @@ -42,11 +42,11 @@ namespace skyline::vfs { return static_cast(ret); } - void OsBacking::Resize(size_t size) { - int ret{ftruncate(fd, size)}; + void OsBacking::Resize(size_t pSize) { + int ret{ftruncate(fd, pSize)}; if (ret < 0) throw exception("Failed to resize file: {}", strerror(errno)); - this->size = size; + size = pSize; } } diff --git a/app/src/main/cpp/skyline/vfs/os_filesystem.cpp b/app/src/main/cpp/skyline/vfs/os_filesystem.cpp index d851701e..f93f575a 100644 --- a/app/src/main/cpp/skyline/vfs/os_filesystem.cpp +++ b/app/src/main/cpp/skyline/vfs/os_filesystem.cpp @@ -88,7 +88,7 @@ namespace skyline::vfs { return std::make_shared(basePath + path, listMode); } - OsFileSystemDirectory::OsFileSystemDirectory(const std::string &path, Directory::ListMode listMode) : Directory(listMode), path(path) {} + OsFileSystemDirectory::OsFileSystemDirectory(std::string path, Directory::ListMode listMode) : Directory(listMode), path(std::move(path)) {} std::vector OsFileSystemDirectory::Read() { if (!listMode.file && !listMode.directory) diff --git a/app/src/main/cpp/skyline/vfs/os_filesystem.h b/app/src/main/cpp/skyline/vfs/os_filesystem.h index 0df30c14..5404daeb 100644 --- a/app/src/main/cpp/skyline/vfs/os_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/os_filesystem.h @@ -35,7 +35,7 @@ namespace skyline::vfs { std::string path; public: - OsFileSystemDirectory(const std::string &path, ListMode listMode); + OsFileSystemDirectory(std::string path, ListMode listMode); std::vector Read(); }; diff --git a/app/src/main/cpp/skyline/vfs/partition_filesystem.cpp b/app/src/main/cpp/skyline/vfs/partition_filesystem.cpp index 117b055f..c92bbcd5 100644 --- a/app/src/main/cpp/skyline/vfs/partition_filesystem.cpp +++ b/app/src/main/cpp/skyline/vfs/partition_filesystem.cpp @@ -5,7 +5,7 @@ #include "partition_filesystem.h" namespace skyline::vfs { - PartitionFileSystem::PartitionFileSystem(std::shared_ptr backing) : FileSystem(), backing(backing) { + PartitionFileSystem::PartitionFileSystem(const std::shared_ptr &backing) : FileSystem(), backing(backing) { header = backing->Read(); if (header.magic == util::MakeMagic("PFS0")) @@ -27,7 +27,7 @@ namespace skyline::vfs { auto entry{backing->Read(entryOffset)}; std::string name(&stringTable[entry.stringTableOffset]); - fileMap.emplace(name, std::move(entry)); + fileMap.emplace(name, entry); } } @@ -59,7 +59,7 @@ namespace skyline::vfs { return std::make_shared(fileList, listMode); } - PartitionFileSystemDirectory::PartitionFileSystemDirectory(const std::vector &fileList, ListMode listMode) : Directory(listMode), fileList(fileList) {} + PartitionFileSystemDirectory::PartitionFileSystemDirectory(std::vector fileList, ListMode listMode) : Directory(listMode), fileList(std::move(fileList)) {} std::vector PartitionFileSystemDirectory::Read() { if (listMode.file) diff --git a/app/src/main/cpp/skyline/vfs/partition_filesystem.h b/app/src/main/cpp/skyline/vfs/partition_filesystem.h index 78d5b625..5be41be0 100644 --- a/app/src/main/cpp/skyline/vfs/partition_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/partition_filesystem.h @@ -40,7 +40,7 @@ namespace skyline::vfs { std::unordered_map fileMap; //!< A map that maps file names to their corresponding entry public: - PartitionFileSystem(std::shared_ptr backing); + PartitionFileSystem(const std::shared_ptr &backing); std::shared_ptr OpenFile(const std::string &path, Backing::Mode mode = {true, false, false}); @@ -57,7 +57,7 @@ namespace skyline::vfs { std::vector fileList; //!< A list of every file in the PFS root directory public: - PartitionFileSystemDirectory(const std::vector &fileList, ListMode listMode); + PartitionFileSystemDirectory(std::vector fileList, ListMode listMode); std::vector Read(); }; diff --git a/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp b/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp index d791aa95..39dcd7a6 100644 --- a/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp +++ b/app/src/main/cpp/skyline/vfs/rom_filesystem.cpp @@ -5,7 +5,7 @@ #include "rom_filesystem.h" namespace skyline::vfs { - RomFileSystem::RomFileSystem(std::shared_ptr backing) : FileSystem(), backing(backing) { + RomFileSystem::RomFileSystem(std::shared_ptr pBacking) : FileSystem(), backing(std::move(pBacking)) { header = backing->Read(); TraverseDirectory(0, ""); } @@ -30,7 +30,7 @@ namespace skyline::vfs { void RomFileSystem::TraverseDirectory(u32 offset, const std::string &path) { auto entry{backing->Read(header.dirMetaTableOffset + offset)}; - std::string childPath{path}; + std::string childPath(path); if (entry.nameSize) { std::vector name(entry.nameSize); backing->Read(span(name), header.dirMetaTableOffset + offset + sizeof(RomFsDirectoryEntry)); @@ -76,7 +76,7 @@ namespace skyline::vfs { } } - RomFileSystemDirectory::RomFileSystemDirectory(const std::shared_ptr &backing, const RomFileSystem::RomFsHeader &header, const RomFileSystem::RomFsDirectoryEntry &ownEntry, ListMode listMode) : Directory(listMode), backing(backing), header(header), ownEntry(ownEntry) {} + RomFileSystemDirectory::RomFileSystemDirectory(std::shared_ptr backing, const RomFileSystem::RomFsHeader &header, const RomFileSystem::RomFsDirectoryEntry &ownEntry, ListMode listMode) : Directory(listMode), backing(std::move(backing)), header(header), ownEntry(ownEntry) {} std::vector RomFileSystemDirectory::Read() { std::vector contents; diff --git a/app/src/main/cpp/skyline/vfs/rom_filesystem.h b/app/src/main/cpp/skyline/vfs/rom_filesystem.h index 43ea8f46..2883e5cd 100644 --- a/app/src/main/cpp/skyline/vfs/rom_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/rom_filesystem.h @@ -87,7 +87,7 @@ namespace skyline { std::shared_ptr backing; public: - RomFileSystemDirectory(const std::shared_ptr &backing, const RomFileSystem::RomFsHeader &header, const RomFileSystem::RomFsDirectoryEntry &ownEntry, ListMode listMode); + RomFileSystemDirectory(std::shared_ptr backing, const RomFileSystem::RomFsHeader &header, const RomFileSystem::RomFsDirectoryEntry &ownEntry, ListMode listMode); std::vector Read(); };