1
0
Fork 0
In MR #585 the initialization of HBcons has been protected from dereferencing stream if it's NULL.
However, the logic is now twisted enough to provoke a maybe-uninitialized warning in GCC 13.
While this is strictly a false positive since the generated code would never dereference HBcons if stream == NULL
this patch refines the code to be easier to read for compilers and humans alike by returning early if stream == NULL.
This commit is contained in:
Stefan Tauner 2025-07-29 15:12:44 +02:00 committed by GitHub
parent c804f7de47
commit b6e9107a9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -76,11 +76,13 @@ static CO_ReturnError_t CO_HBconsumer_initEntry(CO_HBconsumer_t* HBcons, uint8_t
static ODR_t
OD_write_1016(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) {
CO_HBconsumer_t* HBcons;
if (stream != NULL) {
HBcons = stream->object;
}
if ((stream == NULL) || (buf == NULL) || (stream->subIndex < 1U)
if (stream == NULL) {
return ODR_DEV_INCOMPAT;
}
HBcons = stream->object;
if ((buf == NULL) || (stream->subIndex < 1U)
|| (stream->subIndex > HBcons->numberOfMonitoredNodes) || (count != sizeof(uint32_t))
|| (countWritten == NULL)) {
return ODR_DEV_INCOMPAT;