Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
4945e4c
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
8c0f9ee
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
c071798
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
c3b302b
Update rrdJsonParser.h
Abhinavpv28 May 3, 2026
dbe0d2c
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
b60dc49
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
942ea5f
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
c2a4b50
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
0b5b202
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
53ddee2
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
cf41c44
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
538d0b5
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
0ee897a
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
d426626
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
35e0fae
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
5b48bf6
Update rrdExecuteScript.h
Abhinavpv28 May 3, 2026
63df92c
Update rrdJsonParser.h
Abhinavpv28 May 3, 2026
5edb6dd
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
9ed06dd
Update rrdEventProcess.c
Abhinavpv28 May 3, 2026
1c0cf82
Add GTest test cases for split_issue_type, persist_suffix_to_file, an…
Copilot May 3, 2026
32c5fd5
Remove build artifacts and add .gitignore
Copilot May 3, 2026
e4afa18
Remove build-generated device.properties from tracking
Copilot May 3, 2026
447298c
Update rrdJsonParser.c
Abhinavpv28 May 3, 2026
1f7555f
Move suffix file clearing after upload success
Abhinavpv28 May 4, 2026
ca6e2b1
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
3010e95
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
768421c
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
2cf9e9e
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
73a9022
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
1a656c9
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
66dab90
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
ee73b5f
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
a92b176
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
7ebde8e
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
4bbca62
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
b96eb55
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
be09209
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
edb1a3e
Improve error handling in persist_suffix_to_file
Abhinavpv28 May 4, 2026
c619616
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
a194be8
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
ab3aacc
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
40187fa
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
362f1ae
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
8bc8315
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
9887ec7
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
1afb92b
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
33a0011
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
0fa6173
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
23b7ad3
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
23f2c67
Delete .gitignore
Abhinavpv28 May 4, 2026
c7b743a
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
e30155e
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
d3c7fe9
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
441b8e8
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
cfb9158
Replace hardcoded file path with constant
Abhinavpv28 May 4, 2026
0dc2348
Update rrdJsonParser.h
Abhinavpv28 May 4, 2026
833c2e7
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
af163dc
Update read_suffix_from_file_to_buf function signature
Abhinavpv28 May 4, 2026
d52de13
Update rrdJsonParser.h
Abhinavpv28 May 4, 2026
748c701
Update rrdEventProcess.c
Abhinavpv28 May 4, 2026
774137b
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
1dc5b48
Update rrdCommon.h
Abhinavpv28 May 4, 2026
47ee214
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
f702177
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
70b33bf
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
20d6786
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
003b5ef
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
7d722c0
Potential fix for pull request finding
Abhinavpv28 May 4, 2026
0c1fbf0
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
39dedf5
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
8900d98
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
1d06c26
Update rrdCommon.h
Abhinavpv28 May 4, 2026
788335e
Add fcntl.h include for file control operations
Abhinavpv28 May 4, 2026
d9ca844
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
7c7dde7
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
929196e
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
3a3c937
Update rrdJsonParser.c
Abhinavpv28 May 4, 2026
85a6c29
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
05c6b2c
Update rrdUnitTestRunner.cpp
Abhinavpv28 May 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/rrdCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ extern "C"

#define BUF_LEN_128 128
#define APPEND_SUFFIX "_apnd"
#define RRD_SUFFIX_PATH "/tmp/rrd_suffix.txt"
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.

Comment thread
Abhinavpv28 marked this conversation as resolved.
/* Enum for Messages Queue*/
typedef enum {
Expand Down
29 changes: 25 additions & 4 deletions src/rrdEventProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,17 @@ void processIssueTypeEvent(data_buf *rbuf)
cmdBuff = (data_buf *)malloc(sizeof(data_buf));
if (cmdBuff)
{
dataMsgLen = strlen(cmdMap[index]) + 1;
char base[BUF_LEN_128] = {0};
char local_suffix[BUF_LEN_128] = {0};
split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix));
Comment thread
Abhinavpv28 marked this conversation as resolved.
if (base[0] == '\0')
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Invalid IssueType [%s] - empty base after split, skipping\n", __FUNCTION__, __LINE__, cmdMap[index]);
free(cmdBuff);
cmdBuff = NULL;
Comment on lines +85 to +89
continue;
}
dataMsgLen = strlen(base) + 1;
RRD_data_buff_init(cmdBuff, EVENT_MSG, RRD_DEEPSLEEP_INVALID_DEFAULT); /* Setting Deafult Values*/
cmdBuff->inDynamic = rbuf->inDynamic;
if(cmdBuff->inDynamic)
Comment thread
Abhinavpv28 marked this conversation as resolved.
Expand All @@ -88,9 +98,20 @@ void processIssueTypeEvent(data_buf *rbuf)
}
cmdBuff->appendMode = rbuf->appendMode;
cmdBuff->mdata = (char *)calloc(1, dataMsgLen);
/* Suffix is now persisted via file, no struct field needed */
if (cmdBuff->mdata)
{
Comment thread
Abhinavpv28 marked this conversation as resolved.
strncpy((char *)cmdBuff->mdata, cmdMap[index], dataMsgLen);
strncpy((char *)cmdBuff->mdata, base, dataMsgLen);
/* Only persist suffix if input contains an underscore (i.e., is not just the base name) */
if (strchr(cmdMap[index], '_') && local_suffix[0] != '\0')
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Persisting suffix: '%s' from input: '%s' (index=%d)\n", __FUNCTION__, __LINE__, local_suffix, cmdMap[index], index);
persist_suffix_to_file(RRD_SUFFIX_PATH,local_suffix);
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
else
{
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: [DEBUG] Not persisting suffix for input: '%s' (index=%d)\n", __FUNCTION__, __LINE__, cmdMap[index], index);
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
processIssueType(cmdBuff);
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
}
else
Expand Down Expand Up @@ -628,7 +649,7 @@ static void freeParsedJson(cJSON *jsonParsed)
/*
* @function removeSpecialCharacterfromIssueTypeList
* @brief Removes special characters from the issue type list, retaining only alphanumeric
* characters, commas, and periods.
* characters, commas, periods, underscores and hyphens
* @param char *str - The string from which special characters will be removed.
* @return void
*/
Expand All @@ -639,7 +660,7 @@ static void removeSpecialCharacterfromIssueTypeList(char *str)

while (str[source] != '\0')
{
if (isalnum(str[source]) || str[source] == ',' || str[source] == '.')
if (isalnum((unsigned char)str[source]) || str[source] == ',' || str[source] == '.' || str[source] == '_'|| str[source] == '-')
{
str[destination] = str[source];
++destination;
Expand Down
167 changes: 166 additions & 1 deletion src/rrdJsonParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <sys/stat.h>
#include <sys/types.h>
Comment thread
Abhinavpv28 marked this conversation as resolved.
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
Comment thread
Abhinavpv28 marked this conversation as resolved.

/*
* @function removeSpecialChar
Expand All @@ -46,6 +48,143 @@ void removeSpecialChar(char *str)
}
}

void persist_suffix_to_file(const char *filename, const char *suffix)
{
int fd;
if (!filename)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: persist_suffix_to_file called with NULL filename\n", __FUNCTION__, __LINE__);
return;
}
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, 0600);
if (fd < 0)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Failed to open '%s' for writing: %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
return;
Comment thread
Abhinavpv28 marked this conversation as resolved.
}
struct stat st;
if (fstat(fd, &st) != 0)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: fstat failed on '%s': %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
close(fd);
return;
}
if (!S_ISREG(st.st_mode))
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: '%s' is not a regular file!\n", __FUNCTION__, __LINE__, filename);
close(fd);
return;
}
FILE *fp = fdopen(fd, "w");
if (!fp)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: fdopen failed on '%s': %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
close(fd);
return;
}
if (suffix)
{
if (fputs(suffix, fp) == EOF)
{
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: failed to write suffix to file '%s': %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
}
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
fclose(fp); // This also closes the underlying fd
}

void read_suffix_from_file_to_buf(const char *filename, char *buf, size_t buflen)
{
if (!buf || buflen == 0 || !filename) {
return;
}
int fd = open(filename, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd < 0) {
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Failed to open '%s' for reading: %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
buf[0] = '\0';
Comment thread
Abhinavpv28 marked this conversation as resolved.
return;
Comment thread
Abhinavpv28 marked this conversation as resolved.
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
struct stat st;
if (fstat(fd, &st) != 0) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: fstat failed on '%s': %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
close(fd);
buf[0] = '\0';
return;
}
if (!S_ISREG(st.st_mode)) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: '%s' is not a regular file!\n", __FUNCTION__, __LINE__, filename);
close(fd);
buf[0] = '\0';
return;
}
FILE *fp = fdopen(fd, "r");
if (!fp) {
RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: fdopen failed on '%s': %s\n", __FUNCTION__, __LINE__, filename, strerror(errno));
close(fd);
buf[0] = '\0';
return;
}
if (fgets(buf, buflen, fp) == NULL) {
buf[0] = '\0';
fclose(fp);
return;
}
fclose(fp);
size_t len = strlen(buf);
if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0';
}

/*
* @function split_issue_type
* @brief Utility to split base and suffix from issue type string.
* Example: Input: Device.DeviceTime_Search-b6877385-9463-45fc-b19d-a24d77fd0790
* Output: base = Device.DeviceTime, suffix = _Search-b6877385-9463-45fc-b19d-a24d77fd0790
* @param const char *input - The input string to split.
* @param char *base - Buffer to store the base part (before the first underscore).
* @param size_t base_len - Size of the base buffer.
* @param char *suffix - Buffer to store the suffix part (from the first underscore onwards).
* @param size_t suffix_len - Size of the suffix buffer.
* @return void
*/
void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len) {
if (base && base_len > 0)
{
base[0] = '\0';
}
if (suffix && suffix_len > 0)
{
suffix[0] = '\0';
}

if (!input || !base || !suffix)
{
return;
}

if (base_len == 0 || suffix_len == 0)
{
return;
}
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: split_issue_type called with input='%s'\n", __FUNCTION__, __LINE__, input);
const char *underscore = strchr(input, '_');
if (underscore)
{
size_t b_len = underscore - input;
if (b_len >= base_len) b_len = base_len - 1;
strncpy(base, input, b_len);
base[b_len] = '\0';
strncpy(suffix, underscore, suffix_len - 1);
suffix[suffix_len - 1] = '\0';
}
else
Comment thread
Abhinavpv28 marked this conversation as resolved.
{
strncpy(base, input, base_len - 1);
base[base_len - 1] = '\0';
suffix[0] = '\0';
Comment thread
Abhinavpv28 marked this conversation as resolved.
}
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: split_issue_type result: base='%s', suffix='%s'\n", __FUNCTION__, __LINE__, base, suffix);
}


/*
* @function getParamcount
* @brief Calculates the total number of nodes (elements) in the input string, excluding delimiters.
Expand Down Expand Up @@ -516,6 +655,7 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Memory allocation failed for rfcbuf\n",__FUNCTION__,__LINE__);
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
persist_suffix_to_file(RRD_SUFFIX_PATH,""); // Clear the suffix file on early exit
return;
Comment thread
Abhinavpv28 marked this conversation as resolved.
Comment thread
Abhinavpv28 marked this conversation as resolved.
}

Expand All @@ -536,6 +676,7 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
free(rfcbuf); // free duplicated rfc data
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
persist_suffix_to_file(RRD_SUFFIX_PATH,""); // Clear the suffix file on early exit
return;
}
else
Expand Down Expand Up @@ -576,7 +717,29 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
else
{
RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Continue uploading Debug Report for %s from %s... \n",__FUNCTION__,__LINE__,buff->mdata,outdir);
status = uploadDebugoutput(outdir,buff->mdata);
// Use the persisted suffix from file for upload
char suffix[128] = {0};
read_suffix_from_file_to_buf(RRD_SUFFIX_PATH , suffix, sizeof(suffix));
char tarName[512] = {0};
int tar_name_len = 0;
if (suffix[0] != '\0') {
tar_name_len = snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, suffix);
}
else
{
tar_name_len = snprintf(tarName, sizeof(tarName), "%s", buff->mdata);
}
if ((tar_name_len < 0) || ((size_t)tar_name_len >= sizeof(tarName)))
Comment thread
Abhinavpv28 marked this conversation as resolved.
{
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: Failed to build upload file name for %s. snprintf result:%d, buffer size:%zu\n", __FUNCTION__,__LINE__,buff->mdata,tar_name_len,sizeof(tarName));
status = -1;
}
else
{
RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName);
status = uploadDebugoutput(outdir, tarName);
}

if(status != 0)
{
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: RRD Upload Script Execution Failed!!! status:%d\n",__FUNCTION__,__LINE__,status);
Expand All @@ -589,13 +752,15 @@ void checkIssueNodeInfo(issueNodeData *issuestructNode, cJSON *jsoncfg, data_buf
free(rfcbuf); // free duplicated rfc data
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
persist_suffix_to_file(RRD_SUFFIX_PATH,""); // Clear the suffix file after upload
}
else
{
RDK_LOG(RDK_LOG_ERROR,LOG_REMDEBUG,"[%s:%d]: No Command excuted as RRD Failed to change directory:%s\n",__FUNCTION__,__LINE__,outdir);
free(rfcbuf); // free duplicated rfc data
free(buff->mdata); // free rfc data
free(buff->jsonPath); // free rrd path info
persist_suffix_to_file(RRD_SUFFIX_PATH,""); // Clear the suffix file
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/rrdJsonParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ issueData* getIssueCommandInfo(issueNodeData *issuestructNode, cJSON *jsoncfg,ch
bool processAllDebugCommand(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf);
bool processAllDeepSleepAwkMetricsCommands(cJSON *jsoncfg, issueNodeData *issuestructNode, char *rfcbuf);


void persist_suffix_to_file(const char *filename, const char *suffix);
void read_suffix_from_file_to_buf(const char *filename, char *buf, size_t buflen);
void split_issue_type(const char *input, char *base, size_t base_len, char *suffix, size_t suffix_len);

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading