Draft
Conversation
| static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TIME_INVALID_MID = {.MsgId = CFE_SB_MSGID_RESERVED, .CommandCode = 0}; | ||
| static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TIME_CMD_INVALID_CC = { | ||
| .MsgId = CFE_SB_MSGID_WRAP_VALUE(CFE_TIME_CMD_MID), .CommandCode = 0x7F}; | ||
| static const UT_TaskPipeDispatchId_t UT_TPID_CFE_TIME_SET_PRINT_CC = { |
Check notice
Code scanning / CodeQL
Variable scope too large
| break; | ||
|
|
||
| case CFE_TIME_SET_PRINT_CC: | ||
| if (CFE_TIME_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_TIME_SetPrintCmd_t))) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| * See description in header file for argument/return detail | ||
| * | ||
| *-----------------------------------------------------------------*/ | ||
| int32 CFE_TIME_SetPrintFormat(CFE_TIME_PrintTimestamp_Enum_t PrintTimestamp, const char *PrintFormat) |
Check notice
Code scanning / CodeQL
Long function without assertion
Comment on lines
+1078
to
+1093
| while (PctF[0] != '\0') { | ||
| if (PctF[0] == '%') | ||
| { | ||
| switch (PctF[1]) | ||
| { | ||
| case 'f': | ||
| CFE_TIME_Global.PrintFormatMillis = PctF; | ||
| break; | ||
| case '\0': | ||
| break; | ||
| default: | ||
| PctF++; /* skip forward two chars */ | ||
| } | ||
| } | ||
| PctF++; | ||
| } |
Check warning
Code scanning / CodeQL
Unbounded loop
Comment on lines
+581
to
+640
| switch (CFE_TIME_Global.PrintTimestamp) | ||
| { | ||
| case CFE_TIME_PrintTimestamp_DateTime: | ||
| gmtime_r(&sec, &tm); | ||
|
|
||
| /* | ||
| ** `PrintFormatMillis` points at the `%f` in PrintFormat, if there is a `%f`. | ||
| */ | ||
| if (CFE_TIME_Global.PrintFormatMillis) | ||
| { | ||
| /* ...blot out the `%f`, temporarily. */ | ||
| CFE_TIME_Global.PrintFormatMillis[0] = '\0'; | ||
| } | ||
|
|
||
| TimeSz = strftime(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE, CFE_TIME_Global.PrintFormat, &tm); | ||
|
|
||
| if (TimeSz == 0) | ||
| { | ||
| return CFE_TIME_FORMAT_TOO_LONG; | ||
| } | ||
|
|
||
| OutChrs += TimeSz; | ||
|
|
||
| if (CFE_TIME_Global.PrintFormatMillis) | ||
| { | ||
| /* unblot */ | ||
| CFE_TIME_Global.PrintFormatMillis[0] = '%'; | ||
|
|
||
| if (OutChrs + 6 > CFE_TIME_PRINTED_STRING_SIZE) | ||
| { | ||
| return CFE_TIME_FORMAT_TOO_LONG; | ||
| } | ||
|
|
||
| OutChrs += snprintf(PrintBuffer + OutChrs, CFE_TIME_PRINTED_STRING_SIZE - OutChrs, "%05d", mic); | ||
|
|
||
| /* it's likely the `%f` is last in the format string, check if there's any remainder...*/ | ||
| if (CFE_TIME_Global.PrintFormatMillis[2]) | ||
| { | ||
| TimeSz = strftime(PrintBuffer + OutChrs, CFE_TIME_PRINTED_STRING_SIZE, CFE_TIME_Global.PrintFormatMillis + 2, &tm); | ||
|
|
||
| if (TimeSz == 0) | ||
| { | ||
| return CFE_TIME_FORMAT_TOO_LONG; | ||
| } | ||
|
|
||
| OutChrs += TimeSz; | ||
| } | ||
| } | ||
| PrintBuffer[OutChrs] = '\0'; | ||
| break; | ||
|
|
||
| case CFE_TIME_PrintTimestamp_SecsSinceStart: | ||
| OutChrs += snprintf(PrintBuffer, CFE_TIME_PRINTED_STRING_SIZE, "%ld.%06d", (long int)sec, mic); | ||
| PrintBuffer[OutChrs] = '\0'; | ||
| break; | ||
|
|
||
| default: | ||
| PrintBuffer[0] = '\0'; | ||
| break; | ||
| } |
Check notice
Code scanning / CodeQL
Long switch case
| *-----------------------------------------------------------------*/ | ||
| int32 CFE_TIME_SetPrintFormat(CFE_TIME_PrintTimestamp_Enum_t PrintTimestamp, const char *PrintFormat) | ||
| { | ||
| if (PrintTimestamp < 0 || PrintTimestamp > CFE_TIME_PrintTimestamp_None) |
Check warning
Code scanning / CodeQL
Comparison result is always the same
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Joe, for your consideration, another pass at the "%f" and strftime code. This simplifies it a bit (but only supports one "%f" in the format string.)