Fixes for more cppcheck complaints. Mostly cosmetic
This commit is contained in:
parent
8aae2cfc11
commit
846dd0e45d
@ -119,8 +119,7 @@ int save_screenshot(FAR const char *filename)
|
||||
{
|
||||
struct tiff_info_s info;
|
||||
FAR uint8_t *strip;
|
||||
int x;
|
||||
int y;
|
||||
int row;
|
||||
int ret;
|
||||
char tempf1[64];
|
||||
char tempf2[64];
|
||||
@ -188,15 +187,15 @@ int save_screenshot(FAR const char *filename)
|
||||
|
||||
strip = malloc(size.w * 3);
|
||||
|
||||
for (int y = 0; y < size.h; y++)
|
||||
for (row = 0; row < size.h; row++)
|
||||
{
|
||||
struct nxgl_rect_s rect = {{0, y}, {size.w - 1, y}};
|
||||
struct nxgl_rect_s rect = {{0, row}, {size.w - 1, row}};
|
||||
nx_getrectangle(window, &rect, 0, strip, 0);
|
||||
|
||||
ret = tiff_addstrip(&info, strip);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("tiff_addstrip() #%d failed: %d\n", y, ret);
|
||||
printf("tiff_addstrip() #%d failed: %d\n", row, ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +190,9 @@ struct Var *Auto_local(struct Auto *this, int l)
|
||||
|
||||
int Auto_funcReturn(struct Auto *this, struct Pc *pc)
|
||||
{
|
||||
int i, retFrame, retException;
|
||||
int retException;
|
||||
int retFrame;
|
||||
int i;
|
||||
|
||||
if (this->stackPointer == 0)
|
||||
{
|
||||
@ -236,8 +238,11 @@ int Auto_gosubReturn(struct Auto *this, struct Pc *pc)
|
||||
|
||||
void Auto_frameToError(struct Auto *this, struct Program *program, struct Value *v)
|
||||
{
|
||||
int i = this->stackPointer, framePointer, frameSize, retFrame;
|
||||
struct Pc p;
|
||||
int framePointer;
|
||||
int frameSize,;
|
||||
int retFrame;
|
||||
int i = this->stackPointer;
|
||||
|
||||
framePointer = this->framePointer;
|
||||
frameSize = this->frameSize;
|
||||
@ -251,10 +256,7 @@ void Auto_frameToError(struct Auto *this, struct Program *program, struct Value
|
||||
if (i)
|
||||
{
|
||||
retFrame = framePointer + frameSize - 1;
|
||||
i = framePointer;
|
||||
p = this->slot[retFrame].retFrame.pc;
|
||||
frameSize = this->slot[retFrame].retFrame.frameSize;
|
||||
framePointer = this->slot[retFrame].retFrame.framePointer;
|
||||
Value_errorSuffix(v, _("Proc Called"));
|
||||
Program_PCtoError(program, &p, v);
|
||||
}
|
||||
|
@ -1121,6 +1121,5 @@ void Program_xref(struct Program *this, int chn)
|
||||
FS_putChars(chn, _("Goto Referenced in line\n"));
|
||||
Xref_print(goto_, printLine, this, chn);
|
||||
Xref_destroy(goto_);
|
||||
nl = 1;
|
||||
}
|
||||
}
|
||||
|
@ -3851,7 +3851,8 @@ static int yy_get_next_buffer (void)
|
||||
{
|
||||
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
|
||||
register char *source = (yytext_ptr);
|
||||
register int number_to_move, i;
|
||||
register int number_to_move;
|
||||
register int i;
|
||||
int ret_val;
|
||||
|
||||
if ((yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1])
|
||||
@ -3896,7 +3897,7 @@ static int yy_get_next_buffer (void)
|
||||
yy_size_t num_to_read =
|
||||
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
|
||||
|
||||
while ( num_to_read <= 0 )
|
||||
while (num_to_read < 1)
|
||||
{ /* Not enough room in the buffer - grow it. */
|
||||
|
||||
/* just a shorter name for the current buffer */
|
||||
@ -3909,7 +3910,7 @@ static int yy_get_next_buffer (void)
|
||||
{
|
||||
yy_size_t new_size = b->yy_buf_size * 2;
|
||||
|
||||
if ( new_size <= 0 )
|
||||
if (new_size < 1)
|
||||
b->yy_buf_size += b->yy_buf_size / 8;
|
||||
else
|
||||
b->yy_buf_size *= 2;
|
||||
@ -4348,8 +4349,7 @@ static void yyensure_buffer_stack (void)
|
||||
*/
|
||||
num_to_alloc = 1;
|
||||
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
|
||||
(num_to_alloc * sizeof(struct yy_buffer_state*)
|
||||
);
|
||||
(num_to_alloc * sizeof(struct yy_buffer_state*));
|
||||
if (! (yy_buffer_stack))
|
||||
YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
|
||||
|
||||
@ -4368,8 +4368,7 @@ static void yyensure_buffer_stack (void)
|
||||
num_to_alloc = (yy_buffer_stack_max) + grow_size;
|
||||
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
|
||||
((yy_buffer_stack),
|
||||
num_to_alloc * sizeof(struct yy_buffer_state*)
|
||||
);
|
||||
num_to_alloc * sizeof(struct yy_buffer_state*));
|
||||
if (! (yy_buffer_stack))
|
||||
YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()");
|
||||
|
||||
|
@ -136,7 +136,8 @@ eMBFuncWriteMultipleHoldingRegister( uint8_t * pucFrame, uint16_t * usLen )
|
||||
eMBRegHoldingCB(&pucFrame[MB_PDU_FUNC_WRITE_MUL_VALUES_OFF],
|
||||
usRegAddress, usRegCount, MB_REG_WRITE);
|
||||
|
||||
/* If an error occured convert it into a Modbus exception. */
|
||||
/* If an error occurred convert it into a Modbus exception. */
|
||||
|
||||
if (eRegStatus != MB_ENOERR)
|
||||
{
|
||||
eStatus = prveMBError2Exception(eRegStatus);
|
||||
@ -147,6 +148,7 @@ eMBFuncWriteMultipleHoldingRegister( uint8_t * pucFrame, uint16_t * usLen )
|
||||
* address and the quantity of registers. We reuse the
|
||||
* old values in the buffer because they are still valid.
|
||||
*/
|
||||
|
||||
*usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF;
|
||||
}
|
||||
}
|
||||
@ -183,11 +185,12 @@ eMBFuncReadHoldingRegister( uint8_t * pucFrame, uint16_t * usLen )
|
||||
usRegAddress++;
|
||||
|
||||
usRegCount = (uint16_t)(pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF] << 8);
|
||||
usRegCount = ( uint16_t )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] );
|
||||
usRegCount |= (uint16_t)(pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1]);
|
||||
|
||||
/* Check if the number of registers to read is valid. If not
|
||||
* return Modbus illegal data value exception.
|
||||
*/
|
||||
|
||||
if ((usRegCount >= 1) && (usRegCount <= MB_PDU_FUNC_READ_REGCNT_MAX))
|
||||
{
|
||||
/* Set the current PDU data pointer to the beginning. */
|
||||
|
@ -135,6 +135,7 @@ eMBInit( eMBMode eMode, uint8_t ucSlaveAddress, uint8_t ucPort, speed_t ulBaudRa
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
|
||||
/* check preconditions */
|
||||
|
||||
if ((ucSlaveAddress == MB_ADDRESS_BROADCAST) ||
|
||||
(ucSlaveAddress < MB_ADDRESS_MIN) || (ucSlaveAddress > MB_ADDRESS_MAX))
|
||||
{
|
||||
@ -405,7 +406,7 @@ eMBPoll( void )
|
||||
vMBPortTimersDelay(CONFIG_MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS);
|
||||
}
|
||||
#endif
|
||||
eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength );
|
||||
(void)peMBFrameSendCur(ucMBAddress, ucMBFrame, usLength);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -89,6 +89,7 @@ eMBRTUInit( uint8_t ucSlaveAddress, uint8_t ucPort, speed_t ulBaudRate, eMBParit
|
||||
ENTER_CRITICAL_SECTION();
|
||||
|
||||
/* Modbus RTU uses 8 Databits. */
|
||||
|
||||
if (xMBPortSerialInit(ucPort, ulBaudRate, 8, eParity) != true)
|
||||
{
|
||||
eStatus = MB_EPORTERR;
|
||||
@ -152,29 +153,31 @@ eMBRTUStop( void )
|
||||
eMBErrorCode
|
||||
eMBRTUReceive(uint8_t * pucRcvAddress, uint8_t ** pucFrame, uint16_t * pusLength)
|
||||
{
|
||||
bool xFrameReceived = false;
|
||||
eMBErrorCode eStatus = MB_ENOERR;
|
||||
|
||||
ENTER_CRITICAL_SECTION();
|
||||
ASSERT(usRcvBufferPos < MB_SER_PDU_SIZE_MAX);
|
||||
|
||||
/* Length and CRC check */
|
||||
|
||||
if ((usRcvBufferPos >= MB_SER_PDU_SIZE_MIN)
|
||||
&& (usMBCRC16((uint8_t *) ucRTUBuf, usRcvBufferPos) == 0))
|
||||
{
|
||||
/* Save the address field. All frames are passed to the upper layed
|
||||
* and the decision if a frame is used is done there.
|
||||
*/
|
||||
|
||||
*pucRcvAddress = ucRTUBuf[MB_SER_PDU_ADDR_OFF];
|
||||
|
||||
/* Total length of Modbus-PDU is Modbus-Serial-Line-PDU minus
|
||||
* size of address field and CRC checksum.
|
||||
*/
|
||||
|
||||
*pusLength = (uint16_t)(usRcvBufferPos - MB_SER_PDU_PDU_OFF - MB_SER_PDU_SIZE_CRC);
|
||||
|
||||
/* Return the start of the Modbus PDU to the caller. */
|
||||
|
||||
*pucFrame = (uint8_t *) & ucRTUBuf[MB_SER_PDU_PDU_OFF];
|
||||
xFrameReceived = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user