Skip to content

Commit a219a8b

Browse files
committed
partial Merge bitcoin#29040: refactor: Remove pre-C++20 code, fs::path cleanup
It fixes return reference to const variable under mutex which is not a good idea
1 parent 042e8a4 commit a219a8b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/util/system.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ std::optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) co
420420
return std::nullopt;
421421
}
422422

423-
const fs::path& ArgsManager::GetBlocksDirPath() const
423+
const fs::path ArgsManager::GetBlocksDirPath() const
424424
{
425425
LOCK(cs_args);
426426
fs::path& path = m_cached_blocks_path;
@@ -445,7 +445,7 @@ const fs::path& ArgsManager::GetBlocksDirPath() const
445445
return path;
446446
}
447447

448-
const fs::path& ArgsManager::GetDataDir(bool net_specific) const
448+
const fs::path ArgsManager::GetDataDir(bool net_specific) const
449449
{
450450
LOCK(cs_args);
451451
fs::path& path = net_specific ? m_cached_network_datadir_path : m_cached_datadir_path;

src/util/system.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,23 +288,23 @@ class ArgsManager
288288
*
289289
* @return Blocks path which is network specific
290290
*/
291-
const fs::path& GetBlocksDirPath() const;
291+
const fs::path GetBlocksDirPath() const;
292292

293293
/**
294294
* Get data directory path
295295
*
296296
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
297297
* @post Returned directory path is created unless it is empty
298298
*/
299-
const fs::path& GetDataDirBase() const { return GetDataDir(false); }
299+
const fs::path GetDataDirBase() const { return GetDataDir(false); }
300300

301301
/**
302302
* Get data directory path with appended network identifier
303303
*
304304
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
305305
* @post Returned directory path is created unless it is empty
306306
*/
307-
const fs::path& GetDataDirNet() const { return GetDataDir(true); }
307+
const fs::path GetDataDirNet() const { return GetDataDir(true); }
308308

309309
fs::path GetBackupsDirPath();
310310

@@ -483,7 +483,7 @@ class ArgsManager
483483
* @return Absolute path on success, otherwise an empty path when a non-directory path would be returned
484484
* @post Returned directory path is created unless it is empty
485485
*/
486-
const fs::path& GetDataDir(bool net_specific) const;
486+
const fs::path GetDataDir(bool net_specific) const;
487487

488488
// Helper function for LogArgs().
489489
void logArgsPrefix(

0 commit comments

Comments
 (0)