Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 12 additions & 3 deletions source/bulkdata/datamodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ static void *process_rp_thread(void *data)
{
pthread_mutex_lock(&rpMutex);
T2Info("%s: Waiting for event from tr-181 \n", __FUNCTION__);
pthread_cond_wait(&rpCond, &rpMutex);
while(t2_queue_count(rpQueue) == 0 && !stopProcessing)
{
pthread_cond_wait(&rpCond, &rpMutex);
}

T2Debug("%s: Received wake up signal \n", __FUNCTION__);
if(t2_queue_count(rpQueue) > 0)
Expand Down Expand Up @@ -87,7 +90,10 @@ static void *process_tmprp_thread(void *data)
{
pthread_mutex_lock(&tmpRpMutex);
T2Info("%s: Waiting for event from tr-181 \n", __FUNCTION__);
pthread_cond_wait(&tmpRpCond, &tmpRpMutex);
while(t2_queue_count(tmpRpQueue) == 0 && !stopProcessing)
{
pthread_cond_wait(&tmpRpCond, &tmpRpMutex);
}

T2Debug("%s: Received wake up signal \n", __FUNCTION__);
if(t2_queue_count(tmpRpQueue) > 0)
Expand All @@ -113,7 +119,10 @@ static void *process_msg_thread(void *data)
while(!stopProcessing)
{
pthread_mutex_lock(&rpMsgMutex);
pthread_cond_wait(&msg_Cond, &rpMsgMutex);
while(t2_queue_count(rpMsgPkgQueue) == 0 && !stopProcessing)
{
pthread_cond_wait(&msg_Cond, &rpMsgMutex);
}
if(t2_queue_count(rpMsgPkgQueue) > 0)
{
msgpack = (struct __msgpack__ *)t2_queue_pop(rpMsgPkgQueue);
Expand Down
8 changes: 6 additions & 2 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ static void* CollectAndReport(void* data)
pthread_mutex_lock(&profile->reportMutex);
T2Info("waiting for %ld sec of macUploadLatency\n", (long) maxuploadinSec);
profile->maxlatencyTime.tv_sec += maxuploadinSec;
n = pthread_cond_timedwait(&profile->reportcond, &profile->reportMutex, &profile->maxlatencyTime);
do {
n = pthread_cond_timedwait(&profile->reportcond, &profile->reportMutex, &profile->maxlatencyTime);
} while(n != ETIMEDOUT && n != 0);
if(n == ETIMEDOUT)
{
T2Info("TIMEOUT for maxUploadLatency of profile %s\n", profile->name);
Expand Down Expand Up @@ -615,7 +617,9 @@ static void* CollectAndReport(void* data)
pthread_mutex_lock(&profile->reportMutex);
T2Info("waiting for %ld sec of macUploadLatency\n", (long) maxuploadinSec);
profile->maxlatencyTime.tv_sec += maxuploadinSec;
n = pthread_cond_timedwait(&profile->reportcond, &profile->reportMutex, &profile->maxlatencyTime);
do {
n = pthread_cond_timedwait(&profile->reportcond, &profile->reportMutex, &profile->maxlatencyTime);
} while(n != ETIMEDOUT && n != 0);
if(n == ETIMEDOUT)
{
T2Info("TIMEOUT for maxUploadLatency of profile %s\n", profile->name);
Expand Down
23 changes: 21 additions & 2 deletions source/bulkdata/reportprofiles.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/bulkdata/reportprofiles.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/bulkdata/reportprofiles.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/2102, 1477 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/rdk-dev-2102.tar.gz, file: source/bulkdata/reportprofiles.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -946,7 +946,17 @@

// Delete profiles not present in the new profile list
char *profileNameKey = NULL;
int count = hash_map_count(profileHashMap) - 1;
uint32_t hashmap_count = hash_map_count(profileHashMap);
int count;
if (hashmap_count == 0 || hashmap_count == UINT32_MAX)
{
count = -1;
}
else
{
count = (int)(hashmap_count - 1);
}

const char *DirPath = NULL;

if (rprofiletypes == T2_RP)
Expand Down Expand Up @@ -1309,6 +1319,7 @@
return T2ERROR_PROFILE_NOT_FOUND;
}
hash_map_t *profileHashMap;
uint32_t hashmap_count;
int count;
char *profileNameKey = NULL;
int profileIndex;
Expand All @@ -1325,7 +1336,15 @@
}

/* Delete profiles not present in the new profile list */
count = hash_map_count(profileHashMap) - 1;
hashmap_count = hash_map_count(profileHashMap);
if (hashmap_count == 0 || hashmap_count == UINT32_MAX)
{
count = -1;
}
else
{
count = (int)(hashmap_count - 1);
}
while(count >= 0)
{
profile_found_flag = false;
Expand Down
25 changes: 16 additions & 9 deletions source/bulkdata/t2eventreceiver.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/bulkdata/t2eventreceiver.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/bulkdata/t2eventreceiver.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 507 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/bulkdata/t2eventreceiver.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -243,7 +243,18 @@
return NULL;
}
T2Debug("Checking for events in event queue , event count = %d\n", t2_queue_count(eQueue));
if(t2_queue_count(eQueue) > 0)
while(t2_queue_count(eQueue) == 0 && !stopDispatchThread)
{
T2Debug("Event Queue size is 0, Waiting events from T2ER_Push\n");
int ret = pthread_cond_wait(&erCond, &erMutex);
if(ret != 0) // pthread cond wait failed return after unlock
{
T2Error("%s pthread_cond_wait failed with error code: %d\n", __FUNCTION__, ret);
}
T2Debug("Received signal from T2ER_Push\n");
}

if(t2_queue_count(eQueue) > 0)
{
T2Event *event = (T2Event *)t2_queue_pop(eQueue);
if(event == NULL)
Expand Down Expand Up @@ -280,18 +291,11 @@
}
else
{
T2Debug("Event Queue size is 0, Waiting events from T2ER_Push\n");
int ret = pthread_cond_wait(&erCond, &erMutex);
if(ret != 0) // pthread cond wait failed return after unlock
{
T2Error("%s pthread_cond_wait failed with error code: %d\n", __FUNCTION__, ret);
}
if(pthread_mutex_unlock(&erMutex) != 0)
{
T2Error("%s pthread_mutex_unlock for erMutex failed\n", __FUNCTION__);
return NULL;
}
T2Debug("Received signal from T2ER_Push\n");
}
}
T2Debug("%s --out\n", __FUNCTION__);
Expand Down Expand Up @@ -345,7 +349,10 @@
registerForTelemetryEvents(T2ER_PushDataWithDelim);
}

system("touch /tmp/.t2ReadyToReceiveEvents");
if (system("touch /tmp/.t2ReadyToReceiveEvents") != 0)
{
T2Error("Failed to create /tmp/.t2ReadyToReceiveEvents flag file \n");
}
setT2EventReceiveState(T2_STATE_COMPONENT_READY);
T2Info("T2 is now Ready to Recieve Events\n");

Expand Down
14 changes: 7 additions & 7 deletions source/commonlib/telemetry_busmessage_sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ void t2_uninit(void)
T2ERROR t2_event_s(const char* marker, const char* value)
{

int ret;
int ret = -1;
T2ERROR retStatus = T2ERROR_FAILURE ;
EVENT_DEBUG("%s ++in\n", __FUNCTION__);
char* strvalue = NULL;
Expand All @@ -782,13 +782,13 @@ T2ERROR t2_event_s(const char* marker, const char* value)
return T2ERROR_SUCCESS;
}
strvalue = strdup(value);
if( strvalue[strlen(strvalue) - 1] == '\n' )
{
strvalue[strlen(strvalue) - 1] = '\0';
}
ret = report_or_cache_data(strvalue, marker);
if(strvalue != NULL)
{
{
if( strvalue[strlen(strvalue) - 1] == '\n' )
{
strvalue[strlen(strvalue) - 1] = '\0';
}
ret = report_or_cache_data(strvalue, marker);
free(strvalue);
}
if(ret != -1)
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverity issue no longer present as of: undefined

Show issue

Coverity Issue - Uninitialized scalar variable

Using uninitialized value "ret".

High Impact, CWE-457
UNINIT

Expand Down
4 changes: 4 additions & 0 deletions source/dcautil/dca.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,9 @@ static FileDescriptor* getFileDeltaInMemMapAndSearch(const int fd, const off_t s

//create a tmp file for main file fd
char tmp_fdmain[] = "/tmp/dca_tmpfile_fdmainXXXXXX";
mode_t old_umask = umask(0077); // Set secure umask (owner read/write only)
int tmp_fd = mkstemp(tmp_fdmain);
umask(old_umask); // Restore original umask
if (tmp_fd == -1)
{
T2Error("Failed to create temp file: %s\n", strerror(errno));
Expand All @@ -1044,7 +1046,9 @@ static FileDescriptor* getFileDeltaInMemMapAndSearch(const int fd, const off_t s
if (rd != -1 && fstat(rd, &rb) == 0 && rb.st_size > 0)
{
char tmp_fdrotated[] = "/tmp/dca_tmpfile_fdrotatedXXXXXX";
mode_t old_umask = umask(0077); // Set secure umask (owner read/write only)
int tmp_rd = mkstemp(tmp_fdrotated);
umask(old_umask); // Restore original umask
if (tmp_rd == -1)
{
T2Error("Failed to create temp file: %s\n", strerror(errno));
Expand Down
6 changes: 4 additions & 2 deletions source/reportgen/reportgen.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/reportgen/reportgen.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/reportgen/reportgen.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 1284 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/reportgen/reportgen.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -1210,6 +1210,7 @@
unsigned int index = 0;
int params_len = 0;
char *url_params = NULL;
char *temp_params = NULL;

for(; index < http->RequestURIparamList->count; index++)
{
Expand Down Expand Up @@ -1250,13 +1251,14 @@
{
new_params_len += strlen(httpParamVal);
}
url_params = realloc(url_params, new_params_len);
if(url_params == NULL)
temp_params = realloc(url_params, new_params_len);
if(temp_params == NULL)
{
T2Error("Unable to allocate %d bytes of memory at Line %d on %s \n", new_params_len, __LINE__, __FILE__);
curl_free(httpParamVal);
continue;
}
url_params = temp_params;
params_len += snprintf(url_params + params_len, new_params_len - params_len, "%s=%s&", httpParam->HttpName, httpParamVal);

curl_free(httpParamVal);
Expand Down
12 changes: 9 additions & 3 deletions source/scheduler/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,25 @@ void* TimeoutThread(void *arg)
if(tProfile->firstreportint > 0 && tProfile->firstexecution == true )
{
T2Info("Waiting for %d sec for next TIMEOUT for profile as firstreporting interval is given - %s\n", tProfile->firstreportint, tProfile->name);
n = pthread_cond_timedwait(&tProfile->tCond, &tProfile->tMutex, &_ts);
do {
n = pthread_cond_timedwait(&tProfile->tCond, &tProfile->tMutex, &_ts);
} while(n != ETIMEDOUT && n != 0);
}
else
{
if(tProfile->timeOutDuration == UINT_MAX && tProfile->timeRefinSec == 0)
{
T2Info("Waiting for condition as reporting interval is not configured for profile - %s\n", tProfile->name);
n = pthread_cond_wait(&tProfile->tCond, &tProfile->tMutex);
do {
n = pthread_cond_wait(&tProfile->tCond, &tProfile->tMutex);
} while(n != 0 && !tProfile->terminated);
}
else
{
T2Info("Waiting for timeref or reporting interval for the profile - %s is started\n", tProfile->name);
n = pthread_cond_timedwait(&tProfile->tCond, &tProfile->tMutex, &_ts);
do {
n = pthread_cond_timedwait(&tProfile->tCond, &tProfile->tMutex, &_ts);
} while(n != ETIMEDOUT && n != 0);
}
}
if(n == ETIMEDOUT)
Expand Down
14 changes: 12 additions & 2 deletions source/utils/persistence.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,18 @@ T2ERROR getPrivacyModeFromPersistentFolder(char **privMode)
T2Error("Unable to open the file : %s\n", filePath);
return T2ERROR_FAILURE;
}
stat(filePath, &filestat);
fread(data, sizeof(char), filestat.st_size, fp);
if (stat(filePath, &filestat) != 0)
{
T2Error("Unable to stat file : %s\n", filePath);
fclose(fp);
return T2ERROR_FAILURE;
}
if (fread(data, sizeof(char), filestat.st_size, fp) != (size_t)filestat.st_size)
{
T2Error("Failed to read complete data from file : %s\n", filePath);
fclose(fp);
return T2ERROR_FAILURE;
}
*privMode = strdup(data);
if(fclose(fp) != 0)
{
Expand Down
8 changes: 6 additions & 2 deletions source/utils/t2collection.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:

Check failure on line 3 in source/utils/t2collection.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/utils/t2collection.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/1, 456 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/utils/t2collection.c)

Check failure on line 3 in source/utils/t2collection.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/utils/t2collection.c' (Match: rdk/components/generic/telemetry/rdk/components/generic/telemetry/2101, 456 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/telemetry/+archive/rdk-dev-2101.tar.gz, file: source/utils/t2collection.c)
*
* Copyright 2019 RDK Management
*
Expand Down Expand Up @@ -105,12 +105,14 @@
element_t *e, *tmp = NULL;
void *data;
uint32_t i = 0;
uint32_t count;
if(q == NULL)
{
return NULL;
}

if (index > (t2_queue_count(q) - 1))
count = t2_queue_count(q);
if (count == 0 || index >= count)
{
return NULL;
}
Expand Down Expand Up @@ -146,12 +148,14 @@
{
element_t *e;
uint32_t i = 0;
uint32_t count;
if(q == NULL)
{
return NULL;
}

if (index > (t2_queue_count(q) - 1))
count = t2_queue_count(q);
if (count == 0 || index >= count)
{
return NULL;
}
Expand Down
20 changes: 14 additions & 6 deletions source/xconf-client/xconfclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ static char *getTimezone ()
{
fclose(file);
free(jsonDoc);
jsonDoc = NULL;
T2Debug("Failed to read Timezone value from %s file...\n", jsonpath);
continue;
}
Expand Down Expand Up @@ -281,7 +280,6 @@ static char *getTimezone ()
if(zoneValue)
{
free(zoneValue);
zoneValue = NULL ;
}
zoneValue = strdup(zone);
}
Expand Down Expand Up @@ -818,7 +816,10 @@ T2ERROR doHttpGet(char* httpsUrl, char **data)

// Share data with parent
close(sharedPipeFdDataLen[0]);
write(sharedPipeFdDataLen[1], &len, sizeof(size_t));
if (write(sharedPipeFdDataLen[1], &len, sizeof(size_t)) != sizeof(size_t))
{
T2Error("Failed to write data length to pipe\n");
}
close(sharedPipeFdDataLen[1]);

FILE *httpOutput = fopen(HTTP_RESPONSE_FILE, "w+");
Expand Down Expand Up @@ -905,7 +906,10 @@ T2ERROR doHttpGet(char* httpsUrl, char **data)
status_return :

close(sharedPipeFdStatus[0]);
write(sharedPipeFdStatus[1], &ret, sizeof(T2ERROR));
if (write(sharedPipeFdStatus[1], &ret, sizeof(T2ERROR)) != sizeof(T2ERROR))
{
T2Error("Failed to write status to pipe\n");
}
close(sharedPipeFdStatus[1]);
exit(0);

Expand Down Expand Up @@ -1315,7 +1319,9 @@ static void* getUpdatedConfigurationThread(void *data)
_ts.tv_sec = _now.tv_sec + RFC_RETRY_TIMEOUT;

T2Info("Waiting for %d sec before trying getRemoteConfigURL\n", RFC_RETRY_TIMEOUT);
n = pthread_cond_timedwait(&xcCond, &xcMutex, &_ts);
do {
n = pthread_cond_timedwait(&xcCond, &xcMutex, &_ts);
} while(n != ETIMEDOUT && n != 0);
if(n == ETIMEDOUT)
{
T2Info("TIMEDOUT -- trying fetchConfigURLs again\n");
Expand Down Expand Up @@ -1427,7 +1433,9 @@ static void* getUpdatedConfigurationThread(void *data)
clock_gettime(CLOCK_REALTIME, &_now);
_ts.tv_sec = _now.tv_sec + XCONF_RETRY_TIMEOUT;

n = pthread_cond_timedwait(&xcCond, &xcMutex, &_ts);
do {
n = pthread_cond_timedwait(&xcCond, &xcMutex, &_ts);
} while(n != ETIMEDOUT && n != 0);
if(n == ETIMEDOUT)
{
T2Info("TIMEDOUT -- trying fetchConfigurations again\n");
Expand Down
Loading