db/upnp: use ParseUnsigned() instead of atoi()
This commit is contained in:
parent
f363788d76
commit
bfb483898f
@ -25,6 +25,7 @@
|
|||||||
#include "Directory.hxx"
|
#include "Directory.hxx"
|
||||||
#include "Util.hxx"
|
#include "Util.hxx"
|
||||||
#include "Action.hxx"
|
#include "Action.hxx"
|
||||||
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -107,25 +108,18 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
|
|||||||
|
|
||||||
DirBResFree cleaner(&response);
|
DirBResFree cleaner(&response);
|
||||||
|
|
||||||
int didread = -1;
|
|
||||||
const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned");
|
const char *value = ixmlwrap::getFirstElementValue(response, "NumberReturned");
|
||||||
if (value != nullptr)
|
didreadp = value != nullptr
|
||||||
didread = atoi(value);
|
? ParseUnsigned(value)
|
||||||
|
: 0;
|
||||||
if (count == 0) {
|
|
||||||
// TODO: what's this?
|
|
||||||
error.Set(upnp_domain, "got -1 or 0 entries");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
|
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
|
||||||
if (value != nullptr)
|
if (value != nullptr)
|
||||||
totalp = atoi(value);
|
totalp = ParseUnsigned(value);
|
||||||
|
|
||||||
if (!ReadResultTag(dirbuf, response, error))
|
if (!ReadResultTag(dirbuf, response, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
didreadp = didread;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,13 +185,13 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
|
|||||||
|
|
||||||
DirBResFree cleaner(&response);
|
DirBResFree cleaner(&response);
|
||||||
|
|
||||||
int count = -1;
|
|
||||||
const char *value =
|
const char *value =
|
||||||
ixmlwrap::getFirstElementValue(response, "NumberReturned");
|
ixmlwrap::getFirstElementValue(response, "NumberReturned");
|
||||||
if (value != nullptr)
|
const unsigned count = value != nullptr
|
||||||
count = atoi(value);
|
? ParseUnsigned(value)
|
||||||
|
: 0;
|
||||||
|
|
||||||
if (count == -1 || count == 0) {
|
if (count == 0) {
|
||||||
// TODO: what's this?
|
// TODO: what's this?
|
||||||
error.Set(upnp_domain, "got -1 or 0 entries");
|
error.Set(upnp_domain, "got -1 or 0 entries");
|
||||||
return false;
|
return false;
|
||||||
@ -207,7 +201,7 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
|
|||||||
|
|
||||||
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
|
value = ixmlwrap::getFirstElementValue(response, "TotalMatches");
|
||||||
if (value != nullptr)
|
if (value != nullptr)
|
||||||
total = atoi(value);
|
total = ParseUnsigned(value);
|
||||||
|
|
||||||
if (!ReadResultTag(dirbuf, response, error))
|
if (!ReadResultTag(dirbuf, response, error))
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user