FreeRTOS / FreeRTOS-Kernel

FreeRTOS kernel files only, submoduled into https://github.com/FreeRTOS/FreeRTOS and various other repos.
https://www.FreeRTOS.org
MIT License
2.76k stars 1.12k forks source link

Fix xStreamBufferCreateStatic() API for buffer size <= 4 #793

Closed kar-rahul-aws closed 1 year ago

kar-rahul-aws commented 1 year ago

Description

This PR addresses the bug in xStreamBufferCreateStatic() API when xBufferSizeBytes is less than sbBYTES_TO_STORE_MESSAGE_LENGTH . Static creation of StreamBuffer of BufferSize <= sbBYTES_TO_STORE_MESSAGE_LENGTH can be allowed , in case it is not a MessageBuffer.

Test Steps

Executing this code

void pvTask1( void *pvParameters )
{
   ( void ) pvParameters;

    StreamBufferHandle_t xStreamBuffer;
    uint8_t ucBufferStrorage;
    StaticStreamBuffer_t xStaticStreamBuffer;
    xStreamBuffer = xStreamBufferCreateStatic( 1, 1, &ucBufferStrorage, &xStaticStreamBuffer );

    configASSERT( xStreamBuffer != NULL );
 }

Before applying the patch : StreamBuffer creation fails and assert occurs at

configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );

After applying the patch : StreamBuffer creation is successful .

Checklist:

Related Issue

792

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (2f94b18) 94.35% compared to head (d4b6b11) 94.35%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #793 +/- ## ======================================= Coverage 94.35% 94.35% ======================================= Files 6 6 Lines 2446 2446 Branches 598 598 ======================================= Hits 2308 2308 Misses 85 85 Partials 53 53 ``` | [Flag](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/793/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/793/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | `94.35% <100.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/793?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS) | Coverage Δ | | |---|---|---| | [stream\_buffer.c](https://app.codecov.io/gh/FreeRTOS/FreeRTOS-Kernel/pull/793?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=FreeRTOS#diff-c3RyZWFtX2J1ZmZlci5j) | `96.96% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.