aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 22:03:58 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 22:08:56 +0200
commit4817437d31ab5f3c9969b8cc228e2f1826a0fbc2 (patch)
tree63ccba6966ce55e4eec40e354e0560b406eb9483 /src
parent354b5a9365638068e746ca8b008171cbfe804c8a (diff)
downloadmpd-4817437d31ab5f3c9969b8cc228e2f1826a0fbc2.tar.gz
mpd-4817437d31ab5f3c9969b8cc228e2f1826a0fbc2.tar.xz
mpd-4817437d31ab5f3c9969b8cc228e2f1826a0fbc2.zip
fs/Limits: convert macro to "constexpr"
Diffstat (limited to 'src')
-rw-r--r--src/PlaylistFile.cxx2
-rw-r--r--src/fs/FileSystem.cxx2
-rw-r--r--src/fs/Limits.hxx19
-rw-r--r--src/fs/Path.cxx2
4 files changed, 12 insertions, 13 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx
index a82acc1f8..19085f496 100644
--- a/src/PlaylistFile.cxx
+++ b/src/PlaylistFile.cxx
@@ -384,7 +384,7 @@ spl_append_song(const char *utf8path, Song *song, Error &error)
return false;
}
- if (st.st_size / (MPD_PATH_MAX + 1) >= (off_t)playlist_max_length) {
+ if (st.st_size / off_t(MPD_PATH_MAX + 1) >= (off_t)playlist_max_length) {
fclose(file);
error.Set(playlist_domain, PLAYLIST_RESULT_TOO_LARGE,
"Stored playlist is too large");
diff --git a/src/fs/FileSystem.cxx b/src/fs/FileSystem.cxx
index 31271cf95..7f740e3af 100644
--- a/src/fs/FileSystem.cxx
+++ b/src/fs/FileSystem.cxx
@@ -34,7 +34,7 @@ Path ReadLink(const Path &path)
ssize_t size = readlink(path.c_str(), buffer, MPD_PATH_MAX);
if (size < 0)
return Path::Null();
- if (size >= MPD_PATH_MAX) {
+ if (size_t(size) >= MPD_PATH_MAX) {
errno = ENOMEM;
return Path::Null();
}
diff --git a/src/fs/Limits.hxx b/src/fs/Limits.hxx
index bf75f5135..480b08851 100644
--- a/src/fs/Limits.hxx
+++ b/src/fs/Limits.hxx
@@ -22,18 +22,17 @@
#include "check.h"
+#include <stddef.h>
#include <limits.h>
-#if !defined(MPD_PATH_MAX)
-# if defined(WIN32)
-# define MPD_PATH_MAX 260
-# elif defined(MAXPATHLEN)
-# define MPD_PATH_MAX MAXPATHLEN
-# elif defined(PATH_MAX)
-# define MPD_PATH_MAX PATH_MAX
-# else
-# define MPD_PATH_MAX 256
-# endif
+#if defined(WIN32)
+static constexpr size_t MPD_PATH_MAX = 260;
+#elif defined(MAXPATHLEN)
+static constexpr size_t MPD_PATH_MAX = MAXPATHLEN;
+#elif defined(PATH_MAX)
+static constexpr size_t MPD_PATH_MAX = PATH_MAX;
+#else
+static constexpr size_t MPD_PATH_MAX = 256;
#endif
#endif
diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx
index 08e18762a..1c41be3b4 100644
--- a/src/fs/Path.cxx
+++ b/src/fs/Path.cxx
@@ -45,7 +45,7 @@
* and assumption that some weird encoding could represent some UTF-8 4 byte
* sequences with single byte.
*/
-#define MPD_PATH_MAX_UTF8 ((MPD_PATH_MAX - 1) * 4 + 1)
+static constexpr size_t MPD_PATH_MAX_UTF8 = (MPD_PATH_MAX - 1) * 4 + 1;
const Domain path_domain("path");