-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace sprintf with snprintf #802
Conversation
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #802 +/- ##
=======================================
Coverage 93.62% 93.62%
=======================================
Files 6 6
Lines 2508 2508
Branches 598 598
=======================================
Hits 2348 2348
Misses 107 107
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Testing this PR with the following snippet without problem #define LIST_BUFFER_SIZE 1024
static char cTaskListBuffer[ LIST_BUFFER_SIZE ] = { 0 };
/* uxMaxBufferSize doesn't have to be configSTATS_BUFFER_MAX_LENGTH when using
* vTaskGetRunTimeStats2 or vTaskList2 introduced in this PR. */
tempChar = 0x5a;
uxMaxBufferSize = configSTATS_BUFFER_MAX_LENGTH;
if( LIST_BUFFER_SIZE > uxMaxBufferSize )
{
memset( &cTaskListBuffer[ uxMaxBufferSize ], tempChar, LIST_BUFFER_SIZE - uxMaxBufferSize );
}
/* Testing the following function one by one. */
vTaskList( cTaskListBuffer );
// vTaskGetRunTimeStats( cTaskListBuffer );
// vTaskGetRunTimeStats2( cTaskListBuffer, uxMaxBufferSize );
// vTaskList2( cTaskListBuffer, uxMaxBufferSize );
/* Ensure the memory after buffer size is not corrupted. */
for( int a = 0; a < ( LIST_BUFFER_SIZE - uxMaxBufferSize ); a++ )
{
configASSERT( ( cTaskListBuffer[ uxMaxBufferSize + a ] == tempChar ) );
} |
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
8d91d01
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
This change necessitates the introduction of 2 new APIs:
These 2 APIs behave exactly as
vTaskList
andvTaskGetRunTimeStats
except the fact that they take the length of thepcWriteBuffer
as the second argument to ensure that we do not write past the buffer.vTaskList
andvTaskGetRunTimeStats
assume that the length of the buffer isconfigSTATS_BUFFER_MAX_LENGTH
which defaults to0xFFFF
. This is done to ensure that the existing applications do not break. New applications should use the new APIs to avoid memory corruption.Test Steps
Tested behavior of these APIs for various buffer sizes on Cortex-M7.
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.