Datamodel markers should ignore marker value as zero#253
Datamodel markers should ignore marker value as zero#253dharshini555 wants to merge 3 commits intodevelopfrom
Conversation
Signed-off-by: PriyaDharshini_Kathiravan <PriyaDharshini_Kathiravan@comcast.com>
There was a problem hiding this comment.
Pull request overview
This PR implements functionality to ignore datamodel marker values when they equal "0", aligning with legacy behavior for absolute/split markers. This prevents reporting of markers with zero values in telemetry reports.
Changes:
- Modified the
checkForEmptyStringfunction to treat "0" as an empty/invalid value that should be ignored - Added debug logging to indicate when marker values are empty, zero, or NULL
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
source/reportgen/reportgen.c
Outdated
| // Consider "NULL" string value as qualified for empty string | ||
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || !strncmp(valueString, "NULL", 4)) | ||
| // If the string has zero value it should be ignored | ||
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || !strncmp(valueString, "0", 1) || !strncmp(valueString, "NULL", 4)) |
There was a problem hiding this comment.
The check !strncmp(valueString, "0", 1) will match any string starting with "0", not just the string "0". This means valid values like "01", "012345", "0.5", or "0x1A" would also be incorrectly treated as empty. Consider using strcmp(valueString, "0") == 0 or strlen(valueString) == 1 && valueString[0] == '0' to match only the exact string "0".
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || !strncmp(valueString, "0", 1) || !strncmp(valueString, "NULL", 4)) | |
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || strcmp(valueString, "0") == 0 || !strncmp(valueString, "NULL", 4)) |
source/reportgen/reportgen.c
Outdated
| // Consider "NULL" string value as qualified for empty string | ||
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || !strncmp(valueString, "NULL", 4)) | ||
| // If the string has zero value it should be ignored | ||
| if(strlen(valueString) < 1 || !strncmp(valueString, " ", 1) || !strncmp(valueString, "0", 1) || !strncmp(valueString, "NULL", 4)) |
There was a problem hiding this comment.
The test CheckForEmptyString in source/test/reportgen/reportgenTest.cpp needs to be updated to include test cases for the new "0" check. Currently, the test covers NULL, empty string, space, and "NULL" literal, but doesn't test the newly added "0" behavior to verify it works as intended.
Signed-off-by: PriyaDharshini_Kathiravan <PriyaDharshini_Kathiravan@comcast.com>
No description provided.