Commit 4817437d authored by Max Kellermann's avatar Max Kellermann

fs/Limits: convert macro to "constexpr"

parent 354b5a93
...@@ -384,7 +384,7 @@ spl_append_song(const char *utf8path, Song *song, Error &error) ...@@ -384,7 +384,7 @@ spl_append_song(const char *utf8path, Song *song, Error &error)
return false; 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); fclose(file);
error.Set(playlist_domain, PLAYLIST_RESULT_TOO_LARGE, error.Set(playlist_domain, PLAYLIST_RESULT_TOO_LARGE,
"Stored playlist is too large"); "Stored playlist is too large");
......
...@@ -34,7 +34,7 @@ Path ReadLink(const Path &path) ...@@ -34,7 +34,7 @@ Path ReadLink(const Path &path)
ssize_t size = readlink(path.c_str(), buffer, MPD_PATH_MAX); ssize_t size = readlink(path.c_str(), buffer, MPD_PATH_MAX);
if (size < 0) if (size < 0)
return Path::Null(); return Path::Null();
if (size >= MPD_PATH_MAX) { if (size_t(size) >= MPD_PATH_MAX) {
errno = ENOMEM; errno = ENOMEM;
return Path::Null(); return Path::Null();
} }
......
...@@ -22,18 +22,17 @@ ...@@ -22,18 +22,17 @@
#include "check.h" #include "check.h"
#include <stddef.h>
#include <limits.h> #include <limits.h>
#if !defined(MPD_PATH_MAX) #if defined(WIN32)
# if defined(WIN32) static constexpr size_t MPD_PATH_MAX = 260;
# define MPD_PATH_MAX 260 #elif defined(MAXPATHLEN)
# elif defined(MAXPATHLEN) static constexpr size_t MPD_PATH_MAX = MAXPATHLEN;
# define MPD_PATH_MAX MAXPATHLEN #elif defined(PATH_MAX)
# elif defined(PATH_MAX) static constexpr size_t MPD_PATH_MAX = PATH_MAX;
# define MPD_PATH_MAX PATH_MAX #else
# else static constexpr size_t MPD_PATH_MAX = 256;
# define MPD_PATH_MAX 256
# endif
#endif #endif
#endif #endif
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
* and assumption that some weird encoding could represent some UTF-8 4 byte * and assumption that some weird encoding could represent some UTF-8 4 byte
* sequences with single 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"); const Domain path_domain("path");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment