Skip to content

Commit 4a300f5

Browse files
committed
[LINT] error 737
Loss of sign in promotion from Type to Type. Signed-off-by: Jocelyn Legault <jocelynlegault@gmail.com>
1 parent d54ec78 commit 4a300f5

8 files changed

Lines changed: 44 additions & 38 deletions

PythonScript/src/ConsoleDialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ void ConsoleDialog::clearText()
584584

585585
void ConsoleDialog::onStyleNeeded(SCNotification* notification)
586586
{
587-
int startPos = callScintilla(SCI_GETENDSTYLED);
588-
int startLine = callScintilla(SCI_LINEFROMPOSITION, startPos);
589-
int endPos = notification->position;
590-
int endLine = callScintilla(SCI_LINEFROMPOSITION, endPos);
587+
idx_t startPos = (idx_t)callScintilla(SCI_GETENDSTYLED);
588+
idx_t startLine = (idx_t)callScintilla(SCI_LINEFROMPOSITION, startPos);
589+
idx_t endPos = (idx_t)notification->position;
590+
idx_t endLine = (idx_t)callScintilla(SCI_LINEFROMPOSITION, endPos);
591591

592592

593593
LineDetails lineDetails;
594-
for(int lineNumber = startLine; lineNumber <= endLine; ++lineNumber)
594+
for(idx_t lineNumber = startLine; lineNumber <= endLine; ++lineNumber)
595595
{
596596
lineDetails.lineLength = (size_t)callScintilla(SCI_GETLINE, lineNumber);
597597

@@ -605,7 +605,7 @@ void ConsoleDialog::onStyleNeeded(SCNotification* notification)
605605

606606
if (parseLine(&lineDetails))
607607
{
608-
startPos = callScintilla(SCI_POSITIONFROMLINE, lineNumber);
608+
startPos = (idx_t)callScintilla(SCI_POSITIONFROMLINE, lineNumber);
609609

610610
// Check that it's not just a file called '<console>'
611611
if (strncmp(lineDetails.line + lineDetails.filenameStart, "<console>", lineDetails.filenameEnd - lineDetails.filenameStart))

PythonScript/src/CreateWrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def getStyledTextBody(v, out):
173173
out.write('\t}\n')
174174
out.write('\tsrc.chrg.cpMin = start;\n')
175175
out.write('\tsrc.chrg.cpMax = end;\n')
176-
out.write('\tsrc.lpstrText = new char[((end-start) * 2) + 2];\n')
176+
out.write('\tsrc.lpstrText = new char[size_t(((end-start) * 2) + 2)];\n')
177177
out.write('\tcallScintilla({0}, 0, reinterpret_cast<LPARAM>(&src));\n'.format(symbolName(v)))
178178
out.write('\tboost::python::list styles;\n')
179179
out.write("\tPythonCompatibleStrBuffer result((end-start) + 1);\n")

PythonScript/src/MenuManager.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,17 @@ HMENU MenuManager::getOurMenu()
252252
int iMenuItems = GetMenuItemCount(hPluginMenu);
253253
for ( int i = 0; i < iMenuItems; i++ )
254254
{
255-
//lint -e650
256-
// Thanks MS for having a function that returns a UNIT potentially returning -1 >:-(
257-
// How that makes sense is beyond me.
258255
HMENU hSubMenu = ::GetSubMenu(hPluginMenu, i);
259256
// does our About menu command exist here?
257+
// Thanks MS for having a function that returns a UNIT potentially returning -1 >:-(
258+
// How that makes sense is beyond me.
259+
//lint -e{650,737}
260260
if ( ::GetMenuState(hSubMenu, (UINT)m_funcItems[0]._cmdID, MF_BYCOMMAND) != -1 )
261261
{
262262
// this is our "Python Script" sub-menu
263263
m_pythonPluginMenu = hSubMenu;
264264
break;
265265
}
266-
//lint +e650
267266
}
268267
}
269268

PythonScript/src/NotepadPlusWrapper.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,25 +228,25 @@ void NotepadPlusWrapper::setCurrentLangType(LangType lang)
228228

229229
boost::python::list NotepadPlusWrapper::getFiles()
230230
{
231-
int count;
231+
idx_t count;
232232
int bufferID;
233233

234234
boost::python::list files;
235235

236236
for(int view = 0; view <= 1; view++)
237237
{
238-
count = callNotepad(NPPM_GETNBOPENFILES, 0, view);
238+
count = (idx_t)callNotepad(NPPM_GETNBOPENFILES, 0, view);
239239

240240
TCHAR **fileNames = (TCHAR **)new TCHAR*[count];
241-
for (int i = 0 ; i < count ; i++)
241+
for (idx_t i = 0 ; i < count ; i++)
242242
{
243243
fileNames[i] = new TCHAR[MAX_PATH];
244244
}
245245

246246
if (callNotepad(view ? NPPM_GETOPENFILENAMESSECOND : NPPM_GETOPENFILENAMESPRIMARY,
247247
reinterpret_cast<WPARAM>(fileNames), static_cast<LPARAM>(count)))
248248
{
249-
for(int pos = 0; pos < count; pos++)
249+
for(idx_t pos = 0; pos < count; pos++)
250250
{
251251
bufferID = callNotepad(NPPM_GETBUFFERIDFROMPOS, pos, view);
252252
if (bufferID)
@@ -261,7 +261,7 @@ boost::python::list NotepadPlusWrapper::getFiles()
261261
}
262262
}
263263

264-
for (int i = 0 ; i < count ; i++)
264+
for (idx_t i = 0 ; i < count ; i++)
265265
{
266266
delete [] fileNames[i];
267267
}
@@ -278,19 +278,19 @@ boost::python::list NotepadPlusWrapper::getSessionFiles(const char *sessionFilen
278278
{
279279
boost::python::list result;
280280

281-
int count = callNotepad(NPPM_GETNBSESSIONFILES, 0, reinterpret_cast<LPARAM>(sessionFilename));
281+
idx_t count = (idx_t)callNotepad(NPPM_GETNBSESSIONFILES, 0, reinterpret_cast<LPARAM>(sessionFilename));
282282
if (count > 0)
283283
{
284284
TCHAR **fileNames = (TCHAR **)new TCHAR*[count];
285-
for (int pos = 0 ; pos < count ; pos++)
285+
for (idx_t pos = 0 ; pos < count ; pos++)
286286
{
287287
fileNames[pos] = new TCHAR[MAX_PATH];
288288
}
289289

290290
if (callNotepad(NPPM_GETSESSIONFILES, 0, reinterpret_cast<LPARAM>(fileNames)))
291291
{
292292

293-
for(int pos = 0; pos < count; pos++)
293+
for(idx_t pos = 0; pos < count; pos++)
294294
{
295295
#ifdef UNICODE
296296
std::shared_ptr<char> mbFilename = WcharMbcsConverter::tchar2char(fileNames[pos]);
@@ -301,6 +301,13 @@ boost::python::list NotepadPlusWrapper::getSessionFiles(const char *sessionFilen
301301
}
302302

303303
}
304+
305+
for (idx_t i = 0 ; i < count ; i++)
306+
{
307+
delete [] fileNames[i];
308+
}
309+
310+
delete [] fileNames;
304311
}
305312

306313
return result;
@@ -750,8 +757,8 @@ void NotepadPlusWrapper::clearAllCallbacks()
750757
void NotepadPlusWrapper::activateBufferID(int bufferID)
751758
{
752759
Py_BEGIN_ALLOW_THREADS
753-
int index = callNotepad(NPPM_GETPOSFROMBUFFERID, bufferID);
754-
int view = (index & 0xC0000000) >> 30;
760+
idx_t index = (idx_t)callNotepad(NPPM_GETPOSFROMBUFFERID, bufferID);
761+
UINT view = (index & 0xC0000000) >> 30;
755762
index = index & 0x3FFFFFFF;
756763

757764
callNotepad(NPPM_ACTIVATEDOC, view, index);

PythonScript/src/ProcessExecute.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ DWORD WINAPI ProcessExecute::pipeReader(void *args)
311311
}
312312
else
313313
{
314-
int handleIndex = WaitForSingleObject(pipeReaderArgs->stopEvent, 100);
314+
DWORD handleIndex = WaitForSingleObject(pipeReaderArgs->stopEvent, 100);
315315
if (WAIT_OBJECT_0 == handleIndex)
316316
{
317317
processFinished = TRUE;
@@ -372,16 +372,16 @@ void ProcessExecute::spoolFile(std::fstream* file, boost::python::object pyStdou
372372
file->seekg(0);
373373
char infoBuffer[30];
374374
char *buffer = NULL;
375-
int bufferSize = 0;
376-
int bytesToRead;
375+
size_t bufferSize = 0;
376+
size_t bytesToRead;
377377

378378
while (!file->eof())
379379
{
380380
file->getline(infoBuffer, 30, '\n');
381381
if (file->eof())
382382
break;
383383

384-
bytesToRead = atoi(infoBuffer + STREAM_NAME_LENGTH);
384+
bytesToRead = strtoul(infoBuffer + STREAM_NAME_LENGTH, NULL, 0);
385385
if (bufferSize < bytesToRead || !buffer)
386386
{
387387
if (buffer)

PythonScript/src/ScintillaWrapper.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ void ScintillaWrapper::rereplace(boost::python::object searchExp, boost::python:
558558
void ScintillaWrapper::pymlreplace(boost::python::object searchExp, boost::python::object replaceStr, boost::python::object count, boost::python::object flags, boost::python::object startPosition, boost::python::object endPosition)
559559
{
560560
boost::python::str contents;
561-
int currentOffset = 0;
561+
idx_t currentOffset = 0;
562562

563563
if (startPosition.is_none() && endPosition.is_none())
564564
{
@@ -586,9 +586,9 @@ void ScintillaWrapper::pymlreplace(boost::python::object searchExp, boost::pytho
586586
range.chrg.cpMax = GetLength();
587587
}
588588

589-
currentOffset = range.chrg.cpMin;
589+
currentOffset = (idx_t)range.chrg.cpMin;
590590

591-
range.lpstrText = new char[(range.chrg.cpMax - range.chrg.cpMin) + 1];
591+
range.lpstrText = new char[size_t((range.chrg.cpMax - range.chrg.cpMin) + 1)];
592592
callScintilla(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&range));
593593
contents = boost::python::str(const_cast<const char *>(range.lpstrText));
594594
delete[] range.lpstrText;
@@ -704,12 +704,12 @@ void ScintillaWrapper::pyreplace(boost::python::object searchExp, boost::python:
704704
long lineCount = GetLineCount();
705705
boost::python::object re = re_module.attr("compile")(searchExp, flags);
706706

707-
int bufferLength = 0;
707+
size_t bufferLength = 0;
708708
Sci_TextRange range;
709709
range.chrg.cpMin = 0;
710710
range.lpstrText = NULL;
711711
boost::python::tuple result;
712-
int currentStartPosition;
712+
idx_t currentStartPosition;
713713
int infiniteLoopCheck = 0;
714714
int previousLine = -1;
715715
for(int line = start; line < lineCount && (ignoreCount || iCount > 0) && (-1 == end || line <= end); ++line)
@@ -739,11 +739,11 @@ void ScintillaWrapper::pyreplace(boost::python::object searchExp, boost::python:
739739
range.chrg.cpMin = PositionFromLine(line);
740740
range.chrg.cpMax = GetLineEndPosition(line);
741741

742-
if (bufferLength < ((range.chrg.cpMax - range.chrg.cpMin) + 1))
742+
if (bufferLength < (size_t)((range.chrg.cpMax - range.chrg.cpMin) + 1))
743743
{
744744
if (range.lpstrText)
745745
delete [] range.lpstrText;
746-
bufferLength = (range.chrg.cpMax - range.chrg.cpMin) + 1;
746+
bufferLength = (size_t)((range.chrg.cpMax - range.chrg.cpMin) + 1);
747747
range.lpstrText = new char[bufferLength + 1];
748748
}
749749

@@ -758,12 +758,12 @@ void ScintillaWrapper::pyreplace(boost::python::object searchExp, boost::python:
758758
size_t resultLength = _len(result[0]);
759759
if (includeLineEndings)
760760
{
761-
currentStartPosition = PositionFromLine(line);
761+
currentStartPosition = (idx_t)PositionFromLine(line);
762762
replaceWholeLine(line, result[0]);
763763
}
764764
else
765765
{
766-
currentStartPosition = range.chrg.cpMin;
766+
currentStartPosition = (idx_t)range.chrg.cpMin;
767767
replaceLine(line, result[0]);
768768
}
769769

@@ -973,7 +973,7 @@ boost::python::str ScintillaWrapper::getWord(boost::python::object position, boo
973973
Sci_TextRange tr;
974974
tr.chrg.cpMin = startPos;
975975
tr.chrg.cpMax = endPos;
976-
tr.lpstrText = new char[(endPos - startPos) + 1];
976+
tr.lpstrText = new char[size_t((endPos - startPos) + 1)];
977977
callScintilla(SCI_GETTEXTRANGE, 0, reinterpret_cast<LPARAM>(&tr));
978978
boost::python::str retVal(const_cast<const char *>(tr.lpstrText));
979979
delete[] tr.lpstrText;

PythonScript/src/ScintillaWrapperGenerated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ boost::python::tuple ScintillaWrapper::GetStyledText(int start, int end)
145145
}
146146
src.chrg.cpMin = start;
147147
src.chrg.cpMax = end;
148-
src.lpstrText = new char[((end-start) * 2) + 2];
148+
src.lpstrText = new char[size_t(((end-start) * 2) + 2)];
149149
callScintilla(SCI_GETSTYLEDTEXT, 0, reinterpret_cast<LPARAM>(&src));
150150
boost::python::list styles;
151151
PythonCompatibleStrBuffer result((end-start) + 1);

PythonScript/src/WcharMbcsConverter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ std::shared_ptr<wchar_t> WcharMbcsConverter::char2wchar(const char* mbStr)
2727

2828
std::shared_ptr<wchar_t> wideCharStr;
2929

30-
int len = ::MultiByteToWideChar(CP_UTF8, 0, mbStr, -1, NULL, 0);
30+
size_t len = (size_t)MultiByteToWideChar(CP_UTF8, 0, mbStr, -1, NULL, 0);
3131

3232

3333
if (len > 0)
@@ -50,7 +50,7 @@ std::shared_ptr<char> WcharMbcsConverter::wchar2char(const wchar_t* wcStr)
5050

5151
std::shared_ptr<char> multiByteStr;
5252

53-
int len = WideCharToMultiByte(CP_UTF8, 0, wcStr, -1, NULL, 0, NULL, NULL);
53+
size_t len = (size_t)WideCharToMultiByte(CP_UTF8, 0, wcStr, -1, NULL, 0, NULL, NULL);
5454

5555
if (len > 0)
5656
{

0 commit comments

Comments
 (0)