aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-22 21:01:05 +0100
committerMax Kellermann <max@duempel.org>2014-01-22 21:11:04 +0100
commitbfb483898f53b2c505ba2e6a6885402a86bf131e (patch)
tree59d94075a42189460bc18b8213f9f67d40a93914 /src/db/upnp
parentf363788d768adcd8d582593105060fd5a4dfa538 (diff)
downloadmpd-bfb483898f53b2c505ba2e6a6885402a86bf131e.tar.gz
mpd-bfb483898f53b2c505ba2e6a6885402a86bf131e.tar.xz
mpd-bfb483898f53b2c505ba2e6a6885402a86bf131e.zip
db/upnp: use ParseUnsigned() instead of atoi()
Diffstat (limited to 'src/db/upnp')
-rw-r--r--src/db/upnp/ContentDirectoryService.cxx26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/db/upnp/ContentDirectoryService.cxx b/src/db/upnp/ContentDirectoryService.cxx
index 31c16cabe..62f39c7d0 100644
--- a/src/db/upnp/ContentDirectoryService.cxx
+++ b/src/db/upnp/ContentDirectoryService.cxx
@@ -25,6 +25,7 @@
#include "Directory.hxx"
#include "Util.hxx"
#include "Action.hxx"
+#include "util/NumberParser.hxx"
#include "util/Error.hxx"
#include <string.h>
@@ -107,25 +108,18 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
DirBResFree cleaner(&response);
- int didread = -1;
const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned");
- if (value != nullptr)
- didread = atoi(value);
-
- if (count == 0) {
- // TODO: what's this?
- error.Set(upnp_domain, "got -1 or 0 entries");
- return false;
- }
+ didreadp = value != nullptr
+ ? ParseUnsigned(value)
+ : 0;
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
if (value != nullptr)
- totalp = atoi(value);
+ totalp = ParseUnsigned(value);
if (!ReadResultTag(dirbuf, response, error))
return false;
- didreadp = didread;
return true;
}
@@ -191,13 +185,13 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
DirBResFree cleaner(&response);
- int count = -1;
const char *value =
ixmlwrap::getFirstElementValue(response, "NumberReturned");
- if (value != nullptr)
- count = atoi(value);
+ const unsigned count = value != nullptr
+ ? ParseUnsigned(value)
+ : 0;
- if (count == -1 || count == 0) {
+ if (count == 0) {
// TODO: what's this?
error.Set(upnp_domain, "got -1 or 0 entries");
return false;
@@ -207,7 +201,7 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
if (value != nullptr)
- total = atoi(value);
+ total = ParseUnsigned(value);
if (!ReadResultTag(dirbuf, response, error))
return false;