From 11a0a0b6975a62aa28d6623770b60f9dbcbd7063 Mon Sep 17 00:00:00 2001 From: Scott Gilbertson Date: Tue, 16 Jan 2024 07:54:12 -0500 Subject: [PATCH] Fixes per pull request comments: fix %p-1 missing slash, use static_cast, fix int/unsigned mismatches --- rtgui/batchqueue.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index e7de30d30..2811e3445 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -57,7 +57,7 @@ namespace // local helper functions // or negative. The caller performs any required range-checking. int decodePathIndex(unsigned int& ix, Glib::ustring& templateText, size_t numPathElements) { - int pathIndex = (int)numPathElements; // a value that means input was invalid + int pathIndex = static_cast(numPathElements); // a value that means input was invalid bool fromStart = false; if (ix < templateText.size()) { if (templateText[ix] == '-') { @@ -447,7 +447,7 @@ Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring &filenam timeval tv; gettimeofday(&tv, nullptr); char mseconds[11]; - snprintf(mseconds, sizeof(mseconds), "%d", (int)(tv.tv_usec / 1000)); + snprintf(mseconds, sizeof(mseconds), "%d", static_cast((tv.tv_usec / 1000))); time_t rawtime; struct tm *timeinfo; char stringTimestamp [80]; @@ -937,11 +937,11 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam if (n < 0) { n = 0; // if too many elements specified, return all available elements } - if (n < (int)da.size()) { + if (n < static_cast(da.size())) { if (n == 0) { appendAbsolutePathPrefix(path, origFileName); } - for (unsigned int i = (unsigned int)n; i < da.size(); i++) { + for (unsigned int i = static_cast(n); i < da.size(); i++) { path += da[i] + PATH_SEPARATOR; } } @@ -954,10 +954,10 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam // insert path elements from the start of the path up to the given index ix++; int n = decodePathIndex(ix, options.savePathTemplate, da.size()); - if (n > 0) { + if (n >= 0) { appendAbsolutePathPrefix(path, origFileName); } - for (unsigned int i=0; (int)i <= n && i < da.size(); i++) { + for (unsigned int i=0; static_cast(i) <= n && i < da.size(); i++) { path += da[i] + PATH_SEPARATOR; } // If the next template character is a separator, skip it, because path already has one @@ -968,8 +968,8 @@ Glib::ustring BatchQueue::calcAutoFileNameBase (const Glib::ustring& origFileNam } else if (options.savePathTemplate[ix] == 'd') { // insert a single directory name from the file's path ix++; - unsigned int n = decodePathIndex(ix, options.savePathTemplate, da.size()); - if (n >= 0 && n < da.size()) { + int n = decodePathIndex(ix, options.savePathTemplate, da.size()); + if (n >= 0 && n < static_cast(da.size())) { path += da[n]; } } else if (options.savePathTemplate[ix] == 'f') {