From f06c41e729dd0d6f57a161cc75d0872cd7fcc621 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 18 Aug 2022 11:04:40 +0200 Subject: [PATCH] QDir: fix non-idiomatic indexed loop counting Counting backwards from two may be clever, and less to type, but it raised this code reader's eyebrows, so use the formulation everyone understands instead. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-103525 Change-Id: I9416539e552e78e4777a744405b0773a9df1f6d0 Reviewed-by: Mate Barany Reviewed-by: Sona Kurazyan --- src/corelib/io/qdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 694f0ef87d..fa2746798a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -677,7 +677,7 @@ static int drivePrefixLength(const QString &path) } else if (path.startsWith("//"_L1)) { // UNC path; use its //server/share part as "drive" - it's as sane a // thing as we can do. - for (int i = 2; i-- > 0; ) { // Scan two "path fragments": + for (int i = 0 ; i < 2 ; ++i) { // Scan two "path fragments": while (drive < size && path.at(drive).unicode() == '/') drive++; if (drive >= size) {