summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2020-11-18 02:06:42 -0500
committerGravatar Lioncash2020-11-18 02:06:44 -0500
commitbcaadac22ca8a7320a46644e8199ef333edce8e9 (patch)
tree968303f713e9efe6b65ac668f057a5f63495134f /src
parentMerge pull request #4866 from Morph1984/mjolnir-p3-prod (diff)
downloadyuzu-bcaadac22ca8a7320a46644e8199ef333edce8e9.tar.gz
yuzu-bcaadac22ca8a7320a46644e8199ef333edce8e9.tar.xz
yuzu-bcaadac22ca8a7320a46644e8199ef333edce8e9.zip
core: Make use of [[nodiscard]] with the System class
Given this is a central class, we should flag cases where the return value of some functions not being used is likely a bug.
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp6
-rw-r--r--src/core/core.h153
-rw-r--r--src/yuzu_cmd/yuzu.cpp4
-rw-r--r--src/yuzu_tester/yuzu.cpp4
4 files changed, 82 insertions, 85 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 242796008..e33ed77cd 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -632,7 +632,11 @@ const std::string& System::GetStatusDetails() const {
632 return impl->status_details; 632 return impl->status_details;
633} 633}
634 634
635Loader::AppLoader& System::GetAppLoader() const { 635Loader::AppLoader& System::GetAppLoader() {
636 return *impl->app_loader;
637}
638
639const Loader::AppLoader& System::GetAppLoader() const {
636 return *impl->app_loader; 640 return *impl->app_loader;
637} 641}
638 642
diff --git a/src/core/core.h b/src/core/core.h
index 6db896bae..e1cc2975d 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -144,19 +144,19 @@ public:
144 * Run the OS and Application 144 * Run the OS and Application
145 * This function will start emulation and run the relevant devices 145 * This function will start emulation and run the relevant devices
146 */ 146 */
147 ResultStatus Run(); 147 [[nodiscard]] ResultStatus Run();
148 148
149 /** 149 /**
150 * Pause the OS and Application 150 * Pause the OS and Application
151 * This function will pause emulation and stop the relevant devices 151 * This function will pause emulation and stop the relevant devices
152 */ 152 */
153 ResultStatus Pause(); 153 [[nodiscard]] ResultStatus Pause();
154 154
155 /** 155 /**
156 * Step the CPU one instruction 156 * Step the CPU one instruction
157 * @return Result status, indicating whether or not the operation succeeded. 157 * @return Result status, indicating whether or not the operation succeeded.
158 */ 158 */
159 ResultStatus SingleStep(); 159 [[nodiscard]] ResultStatus SingleStep();
160 160
161 /** 161 /**
162 * Invalidate the CPU instruction caches 162 * Invalidate the CPU instruction caches
@@ -175,20 +175,20 @@ public:
175 * @param filepath String path to the executable application to load on the host file system. 175 * @param filepath String path to the executable application to load on the host file system.
176 * @returns ResultStatus code, indicating if the operation succeeded. 176 * @returns ResultStatus code, indicating if the operation succeeded.
177 */ 177 */
178 ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath); 178 [[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath);
179 179
180 /** 180 /**
181 * Indicates if the emulated system is powered on (all subsystems initialized and able to run an 181 * Indicates if the emulated system is powered on (all subsystems initialized and able to run an
182 * application). 182 * application).
183 * @returns True if the emulated system is powered on, otherwise false. 183 * @returns True if the emulated system is powered on, otherwise false.
184 */ 184 */
185 bool IsPoweredOn() const; 185 [[nodiscard]] bool IsPoweredOn() const;
186 186
187 /// Gets a reference to the telemetry session for this emulation session. 187 /// Gets a reference to the telemetry session for this emulation session.
188 Core::TelemetrySession& TelemetrySession(); 188 [[nodiscard]] Core::TelemetrySession& TelemetrySession();
189 189
190 /// Gets a reference to the telemetry session for this emulation session. 190 /// Gets a reference to the telemetry session for this emulation session.
191 const Core::TelemetrySession& TelemetrySession() const; 191 [[nodiscard]] const Core::TelemetrySession& TelemetrySession() const;
192 192
193 /// Prepare the core emulation for a reschedule 193 /// Prepare the core emulation for a reschedule
194 void PrepareReschedule(); 194 void PrepareReschedule();
@@ -197,185 +197,178 @@ public:
197 void PrepareReschedule(u32 core_index); 197 void PrepareReschedule(u32 core_index);
198 198
199 /// Gets and resets core performance statistics 199 /// Gets and resets core performance statistics
200 PerfStatsResults GetAndResetPerfStats(); 200 [[nodiscard]] PerfStatsResults GetAndResetPerfStats();
201 201
202 /// Gets an ARM interface to the CPU core that is currently running 202 /// Gets an ARM interface to the CPU core that is currently running
203 ARM_Interface& CurrentArmInterface(); 203 [[nodiscard]] ARM_Interface& CurrentArmInterface();
204 204
205 /// Gets an ARM interface to the CPU core that is currently running 205 /// Gets an ARM interface to the CPU core that is currently running
206 const ARM_Interface& CurrentArmInterface() const; 206 [[nodiscard]] const ARM_Interface& CurrentArmInterface() const;
207 207
208 /// Gets the index of the currently running CPU core 208 /// Gets the index of the currently running CPU core
209 std::size_t CurrentCoreIndex() const; 209 [[nodiscard]] std::size_t CurrentCoreIndex() const;
210 210
211 /// Gets the scheduler for the CPU core that is currently running 211 /// Gets the scheduler for the CPU core that is currently running
212 Kernel::Scheduler& CurrentScheduler(); 212 [[nodiscard]] Kernel::Scheduler& CurrentScheduler();
213 213
214 /// Gets the scheduler for the CPU core that is currently running 214 /// Gets the scheduler for the CPU core that is currently running
215 const Kernel::Scheduler& CurrentScheduler() const; 215 [[nodiscard]] const Kernel::Scheduler& CurrentScheduler() const;
216 216
217 /// Gets the physical core for the CPU core that is currently running 217 /// Gets the physical core for the CPU core that is currently running
218 Kernel::PhysicalCore& CurrentPhysicalCore(); 218 [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore();
219 219
220 /// Gets the physical core for the CPU core that is currently running 220 /// Gets the physical core for the CPU core that is currently running
221 const Kernel::PhysicalCore& CurrentPhysicalCore() const; 221 [[nodiscard]] const Kernel::PhysicalCore& CurrentPhysicalCore() const;
222 222
223 /// Gets a reference to an ARM interface for the CPU core with the specified index 223 /// Gets a reference to an ARM interface for the CPU core with the specified index
224 ARM_Interface& ArmInterface(std::size_t core_index); 224 [[nodiscard]] ARM_Interface& ArmInterface(std::size_t core_index);
225 225
226 /// Gets a const reference to an ARM interface from the CPU core with the specified index 226 /// Gets a const reference to an ARM interface from the CPU core with the specified index
227 const ARM_Interface& ArmInterface(std::size_t core_index) const; 227 [[nodiscard]] const ARM_Interface& ArmInterface(std::size_t core_index) const;
228 228
229 CpuManager& GetCpuManager(); 229 /// Gets a reference to the underlying CPU manager.
230 [[nodiscard]] CpuManager& GetCpuManager();
230 231
231 const CpuManager& GetCpuManager() const; 232 /// Gets a const reference to the underlying CPU manager
233 [[nodiscard]] const CpuManager& GetCpuManager() const;
232 234
233 /// Gets a reference to the exclusive monitor 235 /// Gets a reference to the exclusive monitor
234 ExclusiveMonitor& Monitor(); 236 [[nodiscard]] ExclusiveMonitor& Monitor();
235 237
236 /// Gets a constant reference to the exclusive monitor 238 /// Gets a constant reference to the exclusive monitor
237 const ExclusiveMonitor& Monitor() const; 239 [[nodiscard]] const ExclusiveMonitor& Monitor() const;
238 240
239 /// Gets a mutable reference to the system memory instance. 241 /// Gets a mutable reference to the system memory instance.
240 Core::Memory::Memory& Memory(); 242 [[nodiscard]] Core::Memory::Memory& Memory();
241 243
242 /// Gets a constant reference to the system memory instance. 244 /// Gets a constant reference to the system memory instance.
243 const Core::Memory::Memory& Memory() const; 245 [[nodiscard]] const Core::Memory::Memory& Memory() const;
244 246
245 /// Gets a mutable reference to the GPU interface 247 /// Gets a mutable reference to the GPU interface
246 Tegra::GPU& GPU(); 248 [[nodiscard]] Tegra::GPU& GPU();
247 249
248 /// Gets an immutable reference to the GPU interface. 250 /// Gets an immutable reference to the GPU interface.
249 const Tegra::GPU& GPU() const; 251 [[nodiscard]] const Tegra::GPU& GPU() const;
250 252
251 /// Gets a mutable reference to the renderer. 253 /// Gets a mutable reference to the renderer.
252 VideoCore::RendererBase& Renderer(); 254 [[nodiscard]] VideoCore::RendererBase& Renderer();
253 255
254 /// Gets an immutable reference to the renderer. 256 /// Gets an immutable reference to the renderer.
255 const VideoCore::RendererBase& Renderer() const; 257 [[nodiscard]] const VideoCore::RendererBase& Renderer() const;
256 258
257 /// Gets the scheduler for the CPU core with the specified index 259 /// Gets the scheduler for the CPU core with the specified index
258 Kernel::Scheduler& Scheduler(std::size_t core_index); 260 [[nodiscard]] Kernel::Scheduler& Scheduler(std::size_t core_index);
259 261
260 /// Gets the scheduler for the CPU core with the specified index 262 /// Gets the scheduler for the CPU core with the specified index
261 const Kernel::Scheduler& Scheduler(std::size_t core_index) const; 263 [[nodiscard]] const Kernel::Scheduler& Scheduler(std::size_t core_index) const;
262 264
263 /// Gets the global scheduler 265 /// Gets the global scheduler
264 Kernel::GlobalScheduler& GlobalScheduler(); 266 [[nodiscard]] Kernel::GlobalScheduler& GlobalScheduler();
265 267
266 /// Gets the global scheduler 268 /// Gets the global scheduler
267 const Kernel::GlobalScheduler& GlobalScheduler() const; 269 [[nodiscard]] const Kernel::GlobalScheduler& GlobalScheduler() const;
268 270
269 /// Gets the manager for the guest device memory 271 /// Gets the manager for the guest device memory
270 Core::DeviceMemory& DeviceMemory(); 272 [[nodiscard]] Core::DeviceMemory& DeviceMemory();
271 273
272 /// Gets the manager for the guest device memory 274 /// Gets the manager for the guest device memory
273 const Core::DeviceMemory& DeviceMemory() const; 275 [[nodiscard]] const Core::DeviceMemory& DeviceMemory() const;
274 276
275 /// Provides a pointer to the current process 277 /// Provides a pointer to the current process
276 Kernel::Process* CurrentProcess(); 278 [[nodiscard]] Kernel::Process* CurrentProcess();
277 279
278 /// Provides a constant pointer to the current process. 280 /// Provides a constant pointer to the current process.
279 const Kernel::Process* CurrentProcess() const; 281 [[nodiscard]] const Kernel::Process* CurrentProcess() const;
280 282
281 /// Provides a reference to the core timing instance. 283 /// Provides a reference to the core timing instance.
282 Timing::CoreTiming& CoreTiming(); 284 [[nodiscard]] Timing::CoreTiming& CoreTiming();
283 285
284 /// Provides a constant reference to the core timing instance. 286 /// Provides a constant reference to the core timing instance.
285 const Timing::CoreTiming& CoreTiming() const; 287 [[nodiscard]] const Timing::CoreTiming& CoreTiming() const;
286 288
287 /// Provides a reference to the interrupt manager instance. 289 /// Provides a reference to the interrupt manager instance.
288 Core::Hardware::InterruptManager& InterruptManager(); 290 [[nodiscard]] Core::Hardware::InterruptManager& InterruptManager();
289 291
290 /// Provides a constant reference to the interrupt manager instance. 292 /// Provides a constant reference to the interrupt manager instance.
291 const Core::Hardware::InterruptManager& InterruptManager() const; 293 [[nodiscard]] const Core::Hardware::InterruptManager& InterruptManager() const;
292 294
293 /// Provides a reference to the kernel instance. 295 /// Provides a reference to the kernel instance.
294 Kernel::KernelCore& Kernel(); 296 [[nodiscard]] Kernel::KernelCore& Kernel();
295 297
296 /// Provides a constant reference to the kernel instance. 298 /// Provides a constant reference to the kernel instance.
297 const Kernel::KernelCore& Kernel() const; 299 [[nodiscard]] const Kernel::KernelCore& Kernel() const;
298 300
299 /// Provides a reference to the internal PerfStats instance. 301 /// Provides a reference to the internal PerfStats instance.
300 Core::PerfStats& GetPerfStats(); 302 [[nodiscard]] Core::PerfStats& GetPerfStats();
301 303
302 /// Provides a constant reference to the internal PerfStats instance. 304 /// Provides a constant reference to the internal PerfStats instance.
303 const Core::PerfStats& GetPerfStats() const; 305 [[nodiscard]] const Core::PerfStats& GetPerfStats() const;
304 306
305 /// Provides a reference to the frame limiter; 307 /// Provides a reference to the frame limiter;
306 Core::FrameLimiter& FrameLimiter(); 308 [[nodiscard]] Core::FrameLimiter& FrameLimiter();
307 309
308 /// Provides a constant referent to the frame limiter 310 /// Provides a constant referent to the frame limiter
309 const Core::FrameLimiter& FrameLimiter() const; 311 [[nodiscard]] const Core::FrameLimiter& FrameLimiter() const;
310 312
311 /// Gets the name of the current game 313 /// Gets the name of the current game
312 Loader::ResultStatus GetGameName(std::string& out) const; 314 [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const;
313 315
314 void SetStatus(ResultStatus new_status, const char* details); 316 void SetStatus(ResultStatus new_status, const char* details);
315 317
316 const std::string& GetStatusDetails() const; 318 [[nodiscard]] const std::string& GetStatusDetails() const;
317 319
318 Loader::AppLoader& GetAppLoader() const; 320 [[nodiscard]] Loader::AppLoader& GetAppLoader();
321 [[nodiscard]] const Loader::AppLoader& GetAppLoader() const;
319 322
320 Service::SM::ServiceManager& ServiceManager(); 323 [[nodiscard]] Service::SM::ServiceManager& ServiceManager();
321 const Service::SM::ServiceManager& ServiceManager() const; 324 [[nodiscard]] const Service::SM::ServiceManager& ServiceManager() const;
322 325
323 void SetFilesystem(FileSys::VirtualFilesystem vfs); 326 void SetFilesystem(FileSys::VirtualFilesystem vfs);
324 327
325 FileSys::VirtualFilesystem GetFilesystem() const; 328 [[nodiscard]] FileSys::VirtualFilesystem GetFilesystem() const;
326 329
327 void RegisterCheatList(const std::vector<Memory::CheatEntry>& list, 330 void RegisterCheatList(const std::vector<Memory::CheatEntry>& list,
328 const std::array<u8, 0x20>& build_id, VAddr main_region_begin, 331 const std::array<u8, 0x20>& build_id, VAddr main_region_begin,
329 u64 main_region_size); 332 u64 main_region_size);
330 333
331 void SetAppletFrontendSet(Service::AM::Applets::AppletFrontendSet&& set); 334 void SetAppletFrontendSet(Service::AM::Applets::AppletFrontendSet&& set);
332
333 void SetDefaultAppletFrontendSet(); 335 void SetDefaultAppletFrontendSet();
334 336
335 Service::AM::Applets::AppletManager& GetAppletManager(); 337 [[nodiscard]] Service::AM::Applets::AppletManager& GetAppletManager();
336 338 [[nodiscard]] const Service::AM::Applets::AppletManager& GetAppletManager() const;
337 const Service::AM::Applets::AppletManager& GetAppletManager() const;
338 339
339 void SetContentProvider(std::unique_ptr<FileSys::ContentProviderUnion> provider); 340 void SetContentProvider(std::unique_ptr<FileSys::ContentProviderUnion> provider);
340 341
341 FileSys::ContentProvider& GetContentProvider(); 342 [[nodiscard]] FileSys::ContentProvider& GetContentProvider();
342 343 [[nodiscard]] const FileSys::ContentProvider& GetContentProvider() const;
343 const FileSys::ContentProvider& GetContentProvider() const;
344 344
345 Service::FileSystem::FileSystemController& GetFileSystemController(); 345 [[nodiscard]] Service::FileSystem::FileSystemController& GetFileSystemController();
346 346 [[nodiscard]] const Service::FileSystem::FileSystemController& GetFileSystemController() const;
347 const Service::FileSystem::FileSystemController& GetFileSystemController() const;
348 347
349 void RegisterContentProvider(FileSys::ContentProviderUnionSlot slot, 348 void RegisterContentProvider(FileSys::ContentProviderUnionSlot slot,
350 FileSys::ContentProvider* provider); 349 FileSys::ContentProvider* provider);
351 350
352 void ClearContentProvider(FileSys::ContentProviderUnionSlot slot); 351 void ClearContentProvider(FileSys::ContentProviderUnionSlot slot);
353 352
354 const Reporter& GetReporter() const; 353 [[nodiscard]] const Reporter& GetReporter() const;
355
356 Service::Glue::ARPManager& GetARPManager();
357 354
358 const Service::Glue::ARPManager& GetARPManager() const; 355 [[nodiscard]] Service::Glue::ARPManager& GetARPManager();
356 [[nodiscard]] const Service::Glue::ARPManager& GetARPManager() const;
359 357
360 Service::APM::Controller& GetAPMController(); 358 [[nodiscard]] Service::APM::Controller& GetAPMController();
359 [[nodiscard]] const Service::APM::Controller& GetAPMController() const;
361 360
362 const Service::APM::Controller& GetAPMController() const; 361 [[nodiscard]] Service::LM::Manager& GetLogManager();
362 [[nodiscard]] const Service::LM::Manager& GetLogManager() const;
363 363
364 Service::LM::Manager& GetLogManager(); 364 [[nodiscard]] Service::Time::TimeManager& GetTimeManager();
365 365 [[nodiscard]] const Service::Time::TimeManager& GetTimeManager() const;
366 const Service::LM::Manager& GetLogManager() const;
367
368 Service::Time::TimeManager& GetTimeManager();
369
370 const Service::Time::TimeManager& GetTimeManager() const;
371 366
372 void SetExitLock(bool locked); 367 void SetExitLock(bool locked);
373 368 [[nodiscard]] bool GetExitLock() const;
374 bool GetExitLock() const;
375 369
376 void SetCurrentProcessBuildID(const CurrentBuildProcessID& id); 370 void SetCurrentProcessBuildID(const CurrentBuildProcessID& id);
377 371 [[nodiscard]] const CurrentBuildProcessID& GetCurrentProcessBuildID() const;
378 const CurrentBuildProcessID& GetCurrentProcessBuildID() const;
379 372
380 /// Register a host thread as an emulated CPU Core. 373 /// Register a host thread as an emulated CPU Core.
381 void RegisterCoreThread(std::size_t id); 374 void RegisterCoreThread(std::size_t id);
@@ -390,7 +383,7 @@ public:
390 void ExitDynarmicProfile(); 383 void ExitDynarmicProfile();
391 384
392 /// Tells if system is running on multicore. 385 /// Tells if system is running on multicore.
393 bool IsMulticore() const; 386 [[nodiscard]] bool IsMulticore() const;
394 387
395private: 388private:
396 System(); 389 System();
@@ -401,7 +394,7 @@ private:
401 * input. 394 * input.
402 * @return ResultStatus code, indicating if the operation succeeded. 395 * @return ResultStatus code, indicating if the operation succeeded.
403 */ 396 */
404 ResultStatus Init(Frontend::EmuWindow& emu_window); 397 [[nodiscard]] ResultStatus Init(Frontend::EmuWindow& emu_window);
405 398
406 struct Impl; 399 struct Impl;
407 std::unique_ptr<Impl> impl; 400 std::unique_ptr<Impl> impl;
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 3a76c785f..14a23c71b 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -240,11 +240,11 @@ int main(int argc, char** argv) {
240 system.CurrentProcess()->GetTitleID(), false, 240 system.CurrentProcess()->GetTitleID(), false,
241 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {}); 241 [](VideoCore::LoadCallbackStage, size_t value, size_t total) {});
242 242
243 system.Run(); 243 void(system.Run());
244 while (emu_window->IsOpen()) { 244 while (emu_window->IsOpen()) {
245 std::this_thread::sleep_for(std::chrono::milliseconds(1)); 245 std::this_thread::sleep_for(std::chrono::milliseconds(1));
246 } 246 }
247 system.Pause(); 247 void(system.Pause());
248 system.Shutdown(); 248 system.Shutdown();
249 249
250 detached_tasks.WaitForAllTasks(); 250 detached_tasks.WaitForAllTasks();
diff --git a/src/yuzu_tester/yuzu.cpp b/src/yuzu_tester/yuzu.cpp
index 5798ce43a..88e4bd1f7 100644
--- a/src/yuzu_tester/yuzu.cpp
+++ b/src/yuzu_tester/yuzu.cpp
@@ -256,11 +256,11 @@ int main(int argc, char** argv) {
256 256
257 system.GPU().Start(); 257 system.GPU().Start();
258 258
259 system.Run(); 259 void(system.Run());
260 while (!finished) { 260 while (!finished) {
261 std::this_thread::sleep_for(std::chrono::milliseconds(1)); 261 std::this_thread::sleep_for(std::chrono::milliseconds(1));
262 } 262 }
263 system.Pause(); 263 void(system.Pause());
264 264
265 detached_tasks.WaitForAllTasks(); 265 detached_tasks.WaitForAllTasks();
266 return return_value; 266 return return_value;