QBenchmarkPerfEvents: help Coverity understand the code

Coverity thinks that r may be negative and not -1 and warns that the
cast to quint64 may overflow.

Change the check for `== -1` to `< 0` to help Coverity (and other
readers of the code) understand that this cannot happen.

Amends c63420a117fe67107466d806890e901d091cb1d5.

Pick-to: 6.9 6.8 6.5 6.2 5.15
Coverity-Id: 474172
Change-Id: I7615e0ef152e1e6e9cbc6dec1b8ecd4f8879521c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2025-02-17 13:54:01 +01:00
parent 01fc6aeaff
commit 24a26ed3a3

View File

@ -546,7 +546,7 @@ static quint64 rawReadValue(int fd)
while (nread < sizeof results) {
char *ptr = reinterpret_cast<char *>(&results);
qint64 r = qt_safe_read(fd, ptr + nread, sizeof results - nread);
if (r == -1) {
if (r < 0) {
perror("QBenchmarkPerfEventsMeasurer::readValue: reading the results");
exit(1);
}