-
Notifications
You must be signed in to change notification settings - Fork 8
Testing purpose #22
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
base: feature/RDKCOM-1035
Are you sure you want to change the base?
Testing purpose #22
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||
| #include <stdio.h> | ||||||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| void reverseString(char *str) { | ||||||||||||||||||||||||||||||
| int start = 0; | ||||||||||||||||||||||||||||||
| int end = strlen(str) - 1; | ||||||||||||||||||||||||||||||
| char temp; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| while (start < end) { | ||||||||||||||||||||||||||||||
| temp = str[start]; | ||||||||||||||||||||||||||||||
| str[start] = str[end]; | ||||||||||||||||||||||||||||||
| str[end] = temp; | ||||||||||||||||||||||||||||||
| start++; | ||||||||||||||||||||||||||||||
| end--; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| printf("string reversed : %s\n",str); | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| printf("string reversed : %s\n",str); |
Copilot
AI
Mar 4, 2026
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.
fgets return value is not checked. If stdin is closed or an error occurs, str contents are undefined and strcspn/reverseString will operate on uninitialized data. Handle a NULL return from fgets (e.g., print an error and return non-zero) before using str.
| fgets(str, sizeof(str), stdin); | |
| if (fgets(str, sizeof(str), stdin) == NULL) { | |
| fprintf(stderr, "Error reading input.\n"); | |
| return 1; | |
| } |
Copilot
AI
Mar 4, 2026
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.
This file adds an interactive standalone main() program under source/test, but it is not referenced by source/test/Makefile.am (the unit test build enumerates sources explicitly). If this is intended as a unit test, convert it into a gtest test and add it to PsmSsp_gtest_bin_SOURCES; otherwise consider removing it or relocating it outside the test tree to avoid dead/accidental test artifacts in the repo.
| int main() { | |
| char str[100]; | |
| printf("Enter a string: "); | |
| fgets(str, sizeof(str), stdin); | |
| // Remove newline if present | |
| str[strcspn(str, "\n")] = 0; | |
| reverseString(str); | |
| printf("Reversed string: %s\n", str); | |
| return 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.
reverseStringhas external linkage but appears intended for use only within this file. Mark itstaticto avoid exporting an unnecessary symbol from the test binary (and potential link conflicts if another test adds the same helper name).