-
Notifications
You must be signed in to change notification settings - Fork 28
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
Fix #67, Use size_t
for 'size' variables
#68
Fix #67, Use size_t
for 'size' variables
#68
Conversation
@@ -296,11 +296,11 @@ | |||
/* Verify load/dump memory parameters */ | |||
/* */ | |||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |||
bool MM_VerifyLoadDumpParams(cpuaddr Address, MM_MemType_t MemType, uint32 SizeInBytes, uint8 VerifyType) | |||
bool MM_VerifyLoadDumpParams(cpuaddr Address, MM_MemType_t MemType, size_t SizeInBytes, uint8 VerifyType) |
Check notice
Code scanning / CodeQL
Long function without assertion
@@ -296,11 +296,11 @@ | |||
/* Verify load/dump memory parameters */ | |||
/* */ | |||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |||
bool MM_VerifyLoadDumpParams(cpuaddr Address, MM_MemType_t MemType, uint32 SizeInBytes, uint8 VerifyType) | |||
bool MM_VerifyLoadDumpParams(cpuaddr Address, MM_MemType_t MemType, size_t SizeInBytes, uint8 VerifyType) |
Check notice
Code scanning / CodeQL
Function too long
@@ -134,11 +134,11 @@ | |||
/* Verify peek and poke command parameters */ | |||
/* */ | |||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |||
bool MM_VerifyPeekPokeParams(cpuaddr Address, MM_MemType_t MemType, uint8 SizeInBits) | |||
bool MM_VerifyPeekPokeParams(cpuaddr Address, MM_MemType_t MemType, size_t SizeInBits) |
Check notice
Code scanning / CodeQL
Function too long
@@ -134,11 +134,11 @@ | |||
/* Verify peek and poke command parameters */ | |||
/* */ | |||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |||
bool MM_VerifyPeekPokeParams(cpuaddr Address, MM_MemType_t MemType, uint8 SizeInBits) | |||
bool MM_VerifyPeekPokeParams(cpuaddr Address, MM_MemType_t MemType, size_t SizeInBits) |
Check notice
Code scanning / CodeQL
Long function without assertion
fe0963c
to
5da3798
Compare
5da3798
to
a0a0677
Compare
@@ -103,9 +103,9 @@ bool MM_PeekMem(const MM_PeekCmd_t *CmdPtr, cpuaddr SrcAddress) | |||
uint16 WordValue = 0; | |||
uint32 DWordValue = 0; | |||
int32 PSP_Status = 0; | |||
uint32 BytesProcessed = 0; | |||
size_t BytesProcessed = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on line 168, this gets assigned to MM_AppData.HkPacket.BytesProcessed
. What do you think about changing the prototype of MM_AppData.HkPacket.BytesProcessed
(BytesProcessed of MM_HkPacket_t in file mm_msg.h) to align with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Justin - great addition.
I ran through and checked - that member only ever gets assigned to other size_t
's or uint
's.
dea9c72
to
ac73642
Compare
ac73642
to
3b93ea3
Compare
3b93ea3
to
2c0f6e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
@@ -102,8 +101,7 @@ typedef struct | |||
{ | |||
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ | |||
|
|||
uint8 DataSize; /**< \brief Size of the data to be written */ | |||
uint8 Padding1[3]; /**< \brief Structure padding */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Padding omission looks appropriate given the new variable, DataSize.
@@ -87,8 +87,7 @@ typedef struct | |||
{ | |||
CFE_MSG_CommandHeader_t CmdHeader; /**< \brief Command header */ | |||
|
|||
uint8 DataSize; /**< \brief Size of the data to be read */ | |||
uint8 Padding[3]; /**< \brief Structure padding */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Padding omission looks appropriate given the new variable, DataSize.
Checklist
Describe the contribution
size_t
type #67size_t
(mostly local variables).size_t
as well for consistency.uint8,
uint16
and mostlyuint32
).4 functions had parameters converted to
size_t:
MM_Verify32Aligned()
-uint32 Size
MM_Verify16Aligned()
-uint32 Size
MM_VerifyLoadDumpParams()
-uint32 SizeInBytes
MM_VerifyPeekPokeParams()
-uint8 SizeInBits
Even if using
size_t
is unnecessary in some cases (and wastes some space), it is more expressive and more compliant with the relevant coding standards.Testing performed
GitHub CI actions all passing successfully.
Expected behavior changes
No change to behavior other than type changes outlined above.
Contributor Info
Avi Weiss @thnkslprpt