diff options
-rw-r--r-- | src/LocateUri.hxx | 2 | ||||
-rw-r--r-- | src/LogInit.cxx | 4 | ||||
-rw-r--r-- | src/Mapper.cxx | 12 | ||||
-rw-r--r-- | src/android/Context.cxx | 2 | ||||
-rw-r--r-- | src/android/Environment.cxx | 6 | ||||
-rw-r--r-- | src/config/Block.cxx | 2 | ||||
-rw-r--r-- | src/config/ConfigGlobal.cxx | 2 | ||||
-rw-r--r-- | src/config/ConfigGlobal.hxx | 2 | ||||
-rw-r--r-- | src/config/ConfigPath.cxx | 6 | ||||
-rw-r--r-- | src/db/plugins/simple/SimpleDatabasePlugin.cxx | 2 | ||||
-rw-r--r-- | src/db/update/InotifyUpdate.cxx | 2 | ||||
-rw-r--r-- | src/decoder/DecoderThread.cxx | 2 | ||||
-rw-r--r-- | src/event/ServerSocket.cxx | 2 | ||||
-rw-r--r-- | src/fs/AllocatedPath.hxx | 20 | ||||
-rw-r--r-- | src/fs/FileSystem.cxx | 6 | ||||
-rw-r--r-- | src/fs/StandardDirectory.cxx | 28 | ||||
-rw-r--r-- | src/input/plugins/CdioParanoiaInputPlugin.cxx | 2 | ||||
-rw-r--r-- | src/java/File.cxx | 2 | ||||
-rw-r--r-- | src/output/plugins/RecorderOutputPlugin.cxx | 4 | ||||
-rw-r--r-- | src/storage/CompositeStorage.cxx | 2 | ||||
-rw-r--r-- | src/storage/StorageInterface.cxx | 2 | ||||
-rw-r--r-- | src/storage/StorageInterface.hxx | 2 | ||||
-rw-r--r-- | src/storage/plugins/LocalStorage.cxx | 2 | ||||
-rw-r--r-- | src/unix/Daemon.cxx | 4 |
24 files changed, 58 insertions, 62 deletions
diff --git a/src/LocateUri.hxx b/src/LocateUri.hxx index aa216f35e..71c018061 100644 --- a/src/LocateUri.hxx +++ b/src/LocateUri.hxx @@ -67,7 +67,7 @@ struct LocatedUri { AllocatedPath path; LocatedUri(Type _type, const char *_uri, - AllocatedPath &&_path=AllocatedPath::Null()) + AllocatedPath &&_path=nullptr) :type(_type), canonical_uri(_uri), path(std::move(_path)) {} }; diff --git a/src/LogInit.cxx b/src/LogInit.cxx index 5660f5576..054c37c72 100644 --- a/src/LogInit.cxx +++ b/src/LogInit.cxx @@ -46,7 +46,7 @@ static constexpr Domain log_domain("log"); #ifndef ANDROID static int out_fd = -1; -static AllocatedPath out_path = AllocatedPath::Null(); +static AllocatedPath out_path = nullptr; static void redirect_logs(int fd) { @@ -169,7 +169,7 @@ log_deinit(void) { #ifndef ANDROID close_log_files(); - out_path = AllocatedPath::Null(); + out_path = nullptr; #endif } diff --git a/src/Mapper.cxx b/src/Mapper.cxx index 959e6836e..089469ea3 100644 --- a/src/Mapper.cxx +++ b/src/Mapper.cxx @@ -39,7 +39,7 @@ * The absolute path of the playlist directory encoded in the * filesystem character set. */ -static AllocatedPath playlist_dir_fs = AllocatedPath::Null(); +static AllocatedPath playlist_dir_fs = nullptr; static void mapper_set_playlist_dir(AllocatedPath &&path) @@ -72,15 +72,15 @@ map_uri_fs(const char *uri) noexcept assert(*uri != '/'); if (instance->storage == nullptr) - return AllocatedPath::Null(); + return nullptr; const auto music_dir_fs = instance->storage->MapFS(""); if (music_dir_fs.IsNull()) - return AllocatedPath::Null(); + return nullptr; const auto uri_fs = AllocatedPath::FromUTF8(uri); if (uri_fs.IsNull()) - return AllocatedPath::Null(); + return nullptr; return AllocatedPath::Build(music_dir_fs, uri_fs); } @@ -118,7 +118,7 @@ AllocatedPath map_spl_utf8_to_fs(const char *name) noexcept { if (playlist_dir_fs.IsNull()) - return AllocatedPath::Null(); + return nullptr; std::string filename_utf8 = name; filename_utf8.append(PLAYLIST_FILE_SUFFIX); @@ -126,7 +126,7 @@ map_spl_utf8_to_fs(const char *name) noexcept const auto filename_fs = AllocatedPath::FromUTF8(filename_utf8.c_str()); if (filename_fs.IsNull()) - return AllocatedPath::Null(); + return nullptr; return AllocatedPath::Build(playlist_dir_fs, filename_fs); } diff --git a/src/android/Context.cxx b/src/android/Context.cxx index 8964286f4..4d81180fb 100644 --- a/src/android/Context.cxx +++ b/src/android/Context.cxx @@ -36,7 +36,7 @@ Context::GetCacheDir(JNIEnv *env) const jobject file = env->CallObjectMethod(Get(), method); if (file == nullptr) { env->ExceptionClear(); - return AllocatedPath::Null(); + return nullptr; } return Java::File::ToAbsolutePath(env, file); diff --git a/src/android/Environment.cxx b/src/android/Environment.cxx index 415c0447f..93aadd7e4 100644 --- a/src/android/Environment.cxx +++ b/src/android/Environment.cxx @@ -60,7 +60,7 @@ Environment::getExternalStorageDirectory() env->CallStaticObjectMethod(cls, getExternalStorageDirectory_method); if (file == nullptr) - return AllocatedPath::Null(); + return nullptr; return Java::File::ToAbsolutePath(env, file); } @@ -70,7 +70,7 @@ Environment::getExternalStoragePublicDirectory(const char *type) { if (getExternalStoragePublicDirectory_method == nullptr) /* needs API level 8 */ - return AllocatedPath::Null(); + return nullptr; JNIEnv *env = Java::GetEnv(); @@ -79,7 +79,7 @@ Environment::getExternalStoragePublicDirectory(const char *type) Environment::getExternalStoragePublicDirectory_method, type2.Get()); if (file == nullptr) - return AllocatedPath::Null(); + return nullptr; return Java::File::ToAbsolutePath(env, file); } diff --git a/src/config/Block.cxx b/src/config/Block.cxx index 51f4321db..86ad226c6 100644 --- a/src/config/Block.cxx +++ b/src/config/Block.cxx @@ -118,7 +118,7 @@ ConfigBlock::GetPath(const char *name, const char *default_value) const s = bp->value.c_str(); } else { if (default_value == nullptr) - return AllocatedPath::Null(); + return nullptr; s = default_value; } diff --git a/src/config/ConfigGlobal.cxx b/src/config/ConfigGlobal.cxx index b1d631a3e..621e59307 100644 --- a/src/config/ConfigGlobal.cxx +++ b/src/config/ConfigGlobal.cxx @@ -125,7 +125,7 @@ config_get_path(ConfigOption option) { const auto *param = config_get_param(option); if (param == nullptr) - return AllocatedPath::Null(); + return nullptr; return param->GetPath(); } diff --git a/src/config/ConfigGlobal.hxx b/src/config/ConfigGlobal.hxx index 89a4b7cad..a44cfe3f8 100644 --- a/src/config/ConfigGlobal.hxx +++ b/src/config/ConfigGlobal.hxx @@ -71,7 +71,7 @@ config_get_string(enum ConfigOption option, /** * Returns an optional configuration variable which contains an * absolute path. If there is a tilde prefix, it is expanded. - * Returns AllocatedPath::Null() if the value is not present. + * Returns nullptr if the value is not present. * * Throws #std::runtime_error on error. */ diff --git a/src/config/ConfigPath.cxx b/src/config/ConfigPath.cxx index 204b626f6..2e75a4b59 100644 --- a/src/config/ConfigPath.cxx +++ b/src/config/ConfigPath.cxx @@ -86,7 +86,7 @@ ParsePath(const char *path) if (*path == '\0') return GetConfiguredHome(); - AllocatedPath home = AllocatedPath::Null(); + AllocatedPath home = nullptr; if (*path == '/') { home = GetConfiguredHome(); @@ -107,11 +107,11 @@ ParsePath(const char *path) } if (home.IsNull()) - return AllocatedPath::Null(); + return nullptr; AllocatedPath path2 = AllocatedPath::FromUTF8Throw(path); if (path2.IsNull()) - return AllocatedPath::Null(); + return nullptr; return AllocatedPath::Build(home, path2); } else if (!PathTraitsUTF8::IsAbsolute(path)) { diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 55e2f694c..772b4d826 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -79,7 +79,7 @@ inline SimpleDatabase::SimpleDatabase(AllocatedPath &&_path, #ifdef ENABLE_ZLIB compress(_compress), #endif - cache_path(AllocatedPath::Null()), + cache_path(nullptr), prefixed_light_song(nullptr) { } diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx index bd82f3e7a..e1a1e9dbd 100644 --- a/src/db/update/InotifyUpdate.cxx +++ b/src/db/update/InotifyUpdate.cxx @@ -135,7 +135,7 @@ AllocatedPath WatchDirectory::GetUriFS() const noexcept { if (parent == nullptr) - return AllocatedPath::Null(); + return nullptr; const auto uri = parent->GetUriFS(); if (uri.IsNull()) diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 715db8e88..1f08cc1ff 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -499,7 +499,7 @@ try { const char *const uri_utf8 = song.GetRealURI(); Path path_fs = nullptr; - AllocatedPath path_buffer = AllocatedPath::Null(); + AllocatedPath path_buffer = nullptr; if (PathTraitsUTF8::IsAbsolute(uri_utf8)) { path_buffer = AllocatedPath::FromUTF8Throw(uri_utf8); path_fs = path_buffer; diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index b9a1c82bc..f9ec3104b 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -71,7 +71,7 @@ public: :SocketMonitor(_loop), parent(_parent), serial(_serial), #ifdef HAVE_UN - path(AllocatedPath::Null()), + path(nullptr), #endif address(std::forward<A>(_address)) { diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index be26ffd78..c7e68ee45 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -43,7 +43,6 @@ class AllocatedPath { string value; - AllocatedPath(std::nullptr_t):value() {} explicit AllocatedPath(const_pointer_type _value):value(_value) {} AllocatedPath(const_pointer_type _begin, const_pointer_type _end) @@ -57,6 +56,14 @@ class AllocatedPath { } public: /** + * Construct a "nulled" instance. Its IsNull() method will + * return true. Such an object must not be used. + * + * @see IsNull() + */ + AllocatedPath(std::nullptr_t):value() {} + + /** * Copy an #AllocatedPath object. */ AllocatedPath(const AllocatedPath &) = default; @@ -70,17 +77,6 @@ public: ~AllocatedPath(); - /** - * Return a "nulled" instance. Its IsNull() method will - * return true. Such an object must not be used. - * - * @see IsNull() - */ - gcc_const - static AllocatedPath Null() noexcept { - return AllocatedPath(nullptr); - } - gcc_pure operator Path() const noexcept { return Path::FromFS(c_str()); diff --git a/src/fs/FileSystem.cxx b/src/fs/FileSystem.cxx index 54543d2c7..3d425d190 100644 --- a/src/fs/FileSystem.cxx +++ b/src/fs/FileSystem.cxx @@ -45,15 +45,15 @@ ReadLink(Path path) #ifdef _WIN32 (void)path; errno = EINVAL; - return AllocatedPath::Null(); + return nullptr; #else char buffer[MPD_PATH_MAX]; ssize_t size = readlink(path.c_str(), buffer, MPD_PATH_MAX); if (size < 0) - return AllocatedPath::Null(); + return nullptr; if (size_t(size) >= MPD_PATH_MAX) { errno = ENOMEM; - return AllocatedPath::Null(); + return nullptr; } buffer[size] = '\0'; return AllocatedPath::FromFS(buffer); diff --git a/src/fs/StandardDirectory.cxx b/src/fs/StandardDirectory.cxx index a74fc5fcb..67845e39b 100644 --- a/src/fs/StandardDirectory.cxx +++ b/src/fs/StandardDirectory.cxx @@ -109,7 +109,7 @@ SafePathFromFS(PathTraitsFS::const_pointer_type dir) { if (IsValidPathString(dir) && IsValidDir(dir)) return AllocatedPath::FromFS(dir); - return AllocatedPath::Null(); + return nullptr; } #endif @@ -120,7 +120,7 @@ static AllocatedPath GetStandardDir(int folder_id) auto ret = SHGetFolderPath(nullptr, folder_id | CSIDL_FLAG_DONT_VERIFY, nullptr, SHGFP_TYPE_CURRENT, dir.data()); if (FAILED(ret)) - return AllocatedPath::Null(); + return nullptr; return SafePathFromFS(dir.data()); } #endif @@ -185,7 +185,7 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir) // build the result path const char *path = line; - auto result = AllocatedPath::Null(); + AllocatedPath result = nullptr; if (home_relative) { auto home = GetHomeDir(); if (home.IsNull()) @@ -205,7 +205,7 @@ ParseConfigLine(char *line, const char *dir_name, AllocatedPath &result_dir) static AllocatedPath GetUserDir(const char *name) noexcept try { - auto result = AllocatedPath::Null(); + AllocatedPath result = nullptr; auto config_dir = GetUserConfigDir(); if (config_dir.IsNull()) return result; @@ -218,7 +218,7 @@ try { return result; return result; } catch (const std::exception &e) { - return AllocatedPath::Null(); + return nullptr; } #endif @@ -242,9 +242,9 @@ GetUserConfigDir() noexcept return fallback; } - return AllocatedPath::Null(); + return nullptr; #else - return AllocatedPath::Null(); + return nullptr; #endif } @@ -258,7 +258,7 @@ GetUserMusicDir() noexcept #elif defined(ANDROID) return Environment::getExternalStoragePublicDirectory("Music"); #else - return AllocatedPath::Null(); + return nullptr; #endif } @@ -279,11 +279,11 @@ GetUserCacheDir() noexcept return fallback; } - return AllocatedPath::Null(); + return nullptr; #elif defined(ANDROID) return context->GetCacheDir(Java::GetEnv()); #else - return AllocatedPath::Null(); + return nullptr; #endif } @@ -303,11 +303,11 @@ GetAppBaseDir() noexcept // Check for error if (ret == 0) - return AllocatedPath::Null(); + return nullptr; // Check for truncation if (ret == app.size() && GetLastError() == ERROR_INSUFFICIENT_BUFFER) - return AllocatedPath::Null(); + return nullptr; auto app_path = AllocatedPath::FromFS(app.data()); return app_path.GetDirectoryName().GetDirectoryName(); @@ -326,7 +326,7 @@ GetHomeDir() noexcept if (pw.ReadByUid(getuid())) return SafePathFromFS(pw->pw_dir); #endif - return AllocatedPath::Null(); + return nullptr; } AllocatedPath @@ -340,7 +340,7 @@ GetHomeDir(const char *user_name) noexcept if (pw.ReadByName(user_name)) return SafePathFromFS(pw->pw_dir); #endif - return AllocatedPath::Null(); + return nullptr; } #endif diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index d7d93909a..d81577bb7 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -175,7 +175,7 @@ cdio_detect_device(void) char **devices = cdio_get_devices_with_cap(nullptr, CDIO_FS_AUDIO, false); if (devices == nullptr) - return AllocatedPath::Null(); + return nullptr; AllocatedPath path = AllocatedPath::FromFS(devices[0]); cdio_free_device_list(devices); diff --git a/src/java/File.cxx b/src/java/File.cxx index 7cd447bfc..d79e861ab 100644 --- a/src/java/File.cxx +++ b/src/java/File.cxx @@ -57,7 +57,7 @@ Java::File::ToAbsolutePath(JNIEnv *env, jobject _file) const jstring path = getAbsolutePath(env, file); if (path == nullptr) { env->ExceptionClear(); - return AllocatedPath::Null(); + return nullptr; } Java::String path2(env, path); diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx index e7c3842b6..2e58fafea 100644 --- a/src/output/plugins/RecorderOutputPlugin.cxx +++ b/src/output/plugins/RecorderOutputPlugin.cxx @@ -50,7 +50,7 @@ class RecorderOutput final : AudioOutput { /** * The destination file name. */ - AllocatedPath path = AllocatedPath::Null(); + AllocatedPath path = nullptr; /** * A string that will be used with FormatTag() to build the @@ -298,7 +298,7 @@ RecorderOutput::SendTag(const Tag &tag) AtScopeExit(p) { free(p); }; - AllocatedPath new_path = AllocatedPath::Null(); + AllocatedPath new_path = nullptr; try { new_path = ParsePath(p); diff --git a/src/storage/CompositeStorage.cxx b/src/storage/CompositeStorage.cxx index 84ee67fc6..545124d4b 100644 --- a/src/storage/CompositeStorage.cxx +++ b/src/storage/CompositeStorage.cxx @@ -316,7 +316,7 @@ CompositeStorage::MapFS(const char *uri) const noexcept auto f = FindStorage(uri); if (f.directory->storage == nullptr) - return AllocatedPath::Null(); + return nullptr; return f.directory->storage->MapFS(f.uri); } diff --git a/src/storage/StorageInterface.cxx b/src/storage/StorageInterface.cxx index a0e8ab460..9e0e91cbd 100644 --- a/src/storage/StorageInterface.cxx +++ b/src/storage/StorageInterface.cxx @@ -25,7 +25,7 @@ AllocatedPath Storage::MapFS(gcc_unused const char *uri_utf8) const noexcept { - return AllocatedPath::Null(); + return nullptr; } AllocatedPath diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx index 74a972363..2b356987e 100644 --- a/src/storage/StorageInterface.hxx +++ b/src/storage/StorageInterface.hxx @@ -66,7 +66,7 @@ public: /** * Map the given relative URI to a local file path. Returns - * AllocatedPath::Null() on error or if this storage does not + * nullptr on error or if this storage does not * support local files. */ gcc_pure diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx index 35ac1826c..405c7e659 100644 --- a/src/storage/plugins/LocalStorage.cxx +++ b/src/storage/plugins/LocalStorage.cxx @@ -124,7 +124,7 @@ LocalStorage::MapFS(const char *uri_utf8) const noexcept try { return MapFSOrThrow(uri_utf8); } catch (...) { - return AllocatedPath::Null(); + return nullptr; } } diff --git a/src/unix/Daemon.cxx b/src/unix/Daemon.cxx index fd4539310..826836849 100644 --- a/src/unix/Daemon.cxx +++ b/src/unix/Daemon.cxx @@ -54,7 +54,7 @@ static uid_t user_uid = (uid_t)-1; static gid_t user_gid = (gid_t)-1; /** the absolute path of the pidfile */ -static AllocatedPath pidfile = AllocatedPath::Null(); +static AllocatedPath pidfile = nullptr; /* whether "group" conf. option was given */ static bool had_group = false; @@ -251,7 +251,7 @@ daemonize_finish(void) { if (!pidfile.IsNull()) { unlink(pidfile.c_str()); - pidfile = AllocatedPath::Null(); + pidfile = nullptr; } free(user_name); |