Skip to content

Commit

Permalink
Fix #335: signed/unsigned nit. Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Jun 12, 2022
1 parent c47ac63 commit b9a711a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/lib/Catena_CommandStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,14 @@ McciCatena::cCommandStream::parseAndDispatch()
pBuffer = this->m_buffer;
pEndBuffer = pBuffer + this->m_nRead;

// loop through command line, finding arguments and stuffing
// into argv.
//
// argc is an int for consistency with years of history;
// but gcc complains about the comparison if we don't compare
// as unsigned.
for (argc = 0;
argc < sizeof(this->m_argv)/sizeof(this->m_argv[0]) - 1;
unsigned(argc) < sizeof(this->m_argv)/sizeof(this->m_argv[0]) - 1;
++argc)
{
uint8_t c;
Expand All @@ -213,8 +219,10 @@ McciCatena::cCommandStream::parseAndDispatch()
if (pBuffer != pEndBuffer)
return -1;

// make sure argv[] is nullptr-terminated.
this->m_argv[argc] = nullptr;

// invoke command, return result.
return this->dispatch(argc, this->m_argv);
}

Expand Down

0 comments on commit b9a711a

Please sign in to comment.