aboutsummaryrefslogtreecommitdiffstats
path: root/src/protocol
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-17 21:53:19 +0200
committerMax Kellermann <max@duempel.org>2013-10-17 21:53:19 +0200
commit58502b38d3eaf5649c9e09b6af6ea84d726dccd1 (patch)
treeb9bbcf6711b783ceba4aac6259e1cb7c66293ec4 /src/protocol
parentd44880dfa99197a8c1f4b65416470e6ffbe534f6 (diff)
downloadmpd-58502b38d3eaf5649c9e09b6af6ea84d726dccd1.tar.gz
mpd-58502b38d3eaf5649c9e09b6af6ea84d726dccd1.tar.xz
mpd-58502b38d3eaf5649c9e09b6af6ea84d726dccd1.zip
*: use std::numeric_limits
Diffstat (limited to 'src/protocol')
-rw-r--r--src/protocol/ArgParser.cxx23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx
index 6bd53a358..e96aaf1c8 100644
--- a/src/protocol/ArgParser.cxx
+++ b/src/protocol/ArgParser.cxx
@@ -21,7 +21,8 @@
#include "ArgParser.hxx"
#include "Result.hxx"
-#include <glib.h>
+#include <limits>
+
#include <stdlib.h>
bool
@@ -51,13 +52,12 @@ check_int(Client *client, int *value_r, const char *s)
return false;
}
-#if G_MAXLONG > G_MAXINT
- if (value < G_MININT || value > G_MAXINT) {
+ if (value < std::numeric_limits<int>::min() ||
+ value > std::numeric_limits<int>::max()) {
command_error(client, ACK_ERROR_ARG,
"Number too large: %s", s);
return false;
}
-#endif
*value_r = (int)value;
return true;
@@ -81,7 +81,7 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
/* compatibility with older MPD versions: specifying
"-1" makes MPD display the whole list */
*value_r1 = 0;
- *value_r2 = G_MAXUINT;
+ *value_r2 = std::numeric_limits<unsigned>::max();
return true;
}
@@ -91,13 +91,11 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
return false;
}
-#if G_MAXLONG > G_MAXUINT
- if (value > G_MAXUINT) {
+ if (unsigned(value) > std::numeric_limits<unsigned>::max()) {
command_error(client, ACK_ERROR_ARG,
"Number too large: %s", s);
return false;
}
-#endif
*value_r1 = (unsigned)value;
@@ -110,7 +108,7 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
}
if (test == test2)
- value = G_MAXUINT;
+ value = std::numeric_limits<unsigned>::max();
if (value < 0) {
command_error(client, ACK_ERROR_ARG,
@@ -118,13 +116,12 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
return false;
}
-#if G_MAXLONG > G_MAXUINT
- if (value > G_MAXUINT) {
+ if (unsigned(value) > std::numeric_limits<unsigned>::max()) {
command_error(client, ACK_ERROR_ARG,
"Number too large: %s", s);
return false;
}
-#endif
+
*value_r2 = (unsigned)value;
} else {
*value_r2 = (unsigned)value + 1;
@@ -146,7 +143,7 @@ check_unsigned(Client *client, unsigned *value_r, const char *s)
return false;
}
- if (value > G_MAXUINT) {
+ if (value > std::numeric_limits<unsigned>::max()) {
command_error(client, ACK_ERROR_ARG,
"Number too large: %s", s);
return false;