Skip to content

Commit

Permalink
Merge pull request #4910 from tuffnatty/warnings
Browse files Browse the repository at this point in the history
Address some warnings
  • Loading branch information
pawelsalawa authored Dec 17, 2023
2 parents 721b51e + e2bfa75 commit 3a82b3c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Plugins/ScriptingPython/scriptingpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ PyObject* ScriptingPython::variantToPythonObj(const QVariant& value)
int listSize = list.size();
obj = PyList_New(listSize);
int pos = 0;
for (const QVariant& item : list)
for (const QString& item : list)
{
PyObject* subObj = variantToPythonObj(item);
PyObject* subObj = stringToPythonObj(item);
PyList_SetItem(obj, pos++, subObj);
Py_DECREF(subObj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
**********************************************************************/
#ifdef _WIN32

#define MINGW_HAS_SECURE_API 1 // for strncpy_s and friends in MinGW-w64 < 7.0

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
Expand Down Expand Up @@ -241,11 +243,13 @@ DWORD64
#endif

#ifdef __MINGW32__
#ifndef __GOT_SECURE_LIB__
#define strcpy_s(dst, len, src) strcpy(dst, src)
#define strncpy_s(dst, len, src, maxLen) strncpy(dst, src, len)
#define strcat_s(dst, len, src) strcat(dst, src)
#define _snprintf_s _snprintf
#endif
#endif

static void MyStrCpy(char* szDest, size_t nMaxDestSize, const char* szSrc)
{
Expand Down
30 changes: 16 additions & 14 deletions SQLiteStudio3/coreSQLiteStudio/common/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,34 +385,36 @@ QString center(const QString& str, int length, const QChar& fillChar)
return result.prepend(fillLeft).append(fillRight);
}

QString longest(const QStringList& strList)
const QString& longest(const QStringList& strList)
{
int max = 0;
QString result;
for (const QString str : strList)
qsizetype maxIndex = -1;
for (qsizetype i = 0; i < strList.size(); i++)
{
if (str.size() > max)
int size = strList.at(i).size();
if (size > max)
{
result = str;
max = str.size();
maxIndex = i;
max = size;
}
}
return result;
return strList.at(maxIndex);
}

QString shortest(const QStringList& strList)
const QString& shortest(const QStringList& strList)
{
int max = INT_MAX;
QString result;
for (const QString str : strList)
qsizetype maxIndex = -1;
for (qsizetype i = 0; i < strList.size(); i++)
{
if (str.size() < max)
int size = strList.at(i).size();
if (size < max)
{
result = str;
max = str.size();
maxIndex = i;
max = size;
}
}
return result;
return strList.at(maxIndex);
}

QString longestCommonPart(const QStringList& strList)
Expand Down
4 changes: 2 additions & 2 deletions SQLiteStudio3/coreSQLiteStudio/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ API_EXPORT QString center(const QString& str, int length, const QChar& fillChar)
*
* If there are many values with the same, longest length, then the first one is picked.
*/
API_EXPORT QString longest(const QStringList& strList);
API_EXPORT const QString& longest(const QStringList& strList);

/**
* @brief Picks the shortest string from the list.
Expand All @@ -204,7 +204,7 @@ API_EXPORT QString longest(const QStringList& strList);
*
* If there are many values with the same, shortest length, then the first one is picked.
*/
API_EXPORT QString shortest(const QStringList& strList);
API_EXPORT const QString& shortest(const QStringList& strList);

/**
* @brief Finds the longest common part of all strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void SqliteOrderBy::pullLastCollationAsOuterExpr()
if (!collateExpr)
{
qCritical() << "Could not cast statement to SqliteExpr, even though it's identified as COLLATE expr. The actual contents:"
<< collateExpr->detokenize();
<< stmt->detokenize();
return;
}

Expand Down

0 comments on commit 3a82b3c

Please sign in to comment.