summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qipaddress.cpp12
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp29
2 files changed, 20 insertions, 21 deletions
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp
index eeb3d79b06..feed38bef6 100644
--- a/src/corelib/io/qipaddress.cpp
+++ b/src/corelib/io/qipaddress.cpp
@@ -60,11 +60,9 @@ static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptL
ptr[1] != '.' && ptr[1] != '\0')
return false;
- const char *endptr;
- bool ok;
- quint64 ll = qstrntoull(ptr, stop - ptr, &endptr, 0, &ok);
+ auto [ll, endptr] = qstrntoull(ptr, stop - ptr, 0);
quint32 x = ll;
- if (!ok || endptr == ptr || ll != x)
+ if (!endptr || endptr == ptr || ll != x)
return false;
if (*endptr == '.' || dotCount == 3) {
@@ -176,15 +174,13 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end
continue;
}
- const char *endptr;
- bool ok;
- quint64 ll = qstrntoull(ptr, stop - ptr, &endptr, 16, &ok);
+ auto [ll, endptr] = qstrntoull(ptr, stop - ptr, 16);
quint16 x = ll;
// Reject malformed fields:
// - failed to parse
// - too many hex digits
- if (!ok || endptr > ptr + 4)
+ if (!endptr || endptr > ptr + 4)
return begin + (ptr - buffer.data());
if (*endptr == '.') {
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 5f3fa32482..be3bf0252d 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -451,32 +451,35 @@ inline bool QStorageIterator::next()
const char *const stop = ptr + len - 1;
// parse the line
- bool ok;
mnt.mnt_freq = 0;
mnt.mnt_passno = 0;
- mnt.mount_id = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ auto r = qstrntoll(ptr, stop - ptr, 10);
+ if (!r.ok())
return false;
+ mnt.mount_id = r.result;
- int parent_id = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- Q_UNUSED(parent_id);
- if (!ok)
+ r = qstrntoll(r.endptr, stop - r.endptr, 10);
+ if (!r.ok())
return false;
+ int parent_id = r.result;
+ Q_UNUSED(parent_id);
- int rdevmajor = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ r = qstrntoll(r.endptr, stop - r.endptr, 10);
+ if (!r.ok())
return false;
- if (*ptr != ':')
+ if (*r.endptr != ':')
return false;
- int rdevminor = qstrntoll(ptr + 1, stop - ptr - 1, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ int rdevmajor = r.result;
+ r = qstrntoll(r.endptr + 1, stop - r.endptr - 1, 10);
+ if (!r.ok())
return false;
- mnt.rdev = makedev(rdevmajor, rdevminor);
+ mnt.rdev = makedev(rdevmajor, r.result);
- if (*ptr != ' ')
+ if (*r.endptr != ' ')
return false;
+ ptr = const_cast<char *>(r.endptr);
mnt.subvolume = ++ptr;
ptr = parseMangledPath(ptr);
if (!ptr)