PengZheng commented on PR #591:
URL: https://github.com/apache/celix/pull/591#issuecomment-1657680871
> Any idea if a goto / cleanup combination always gives issues or is it also
possible this goes unnoticed during compilation and testing?
Goto/cleanup combination is not always an issue.
For exmaple, there is actually nothing wrong with the following:
```C
celix_autofree char* buf = malloc(4);
if(error) {
goto exit;
}
// omitted
return 0;
exit:
return 1;
```
The caveat is that declaration of auto variables should NEVER appear AFTER
`goto` statement.
It is just a rule of thumb that we shall avoid mixed usage of GOTOs and auto
variables to ease code review.
Both clang-based static analysis and our unit tests can catch this issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]