Skip to content
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1374c07
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Oct 30, 2025
6b95abb
fix build issue
santoshcomcast Oct 30, 2025
2f17837
fix build issue
santoshcomcast Oct 30, 2025
2e068a5
addressed review comments
santoshcomcast Nov 5, 2025
6fd6b4f
fix build issue
santoshcomcast Nov 5, 2025
9932c3c
fix build issue
santoshcomcast Nov 5, 2025
cc2121a
fix build issue
santoshcomcast Nov 5, 2025
0d13c48
fix build issue
santoshcomcast Nov 5, 2025
397cf75
fix build issue
santoshcomcast Nov 5, 2025
8433557
fix coverity issue and removed unwanted code.
santoshcomcast Nov 5, 2025
51c8af5
Fix build issue.
santoshcomcast Nov 5, 2025
020d7fc
Addressed review comments.
santoshcomcast Nov 6, 2025
7e8a9f4
Addressed review comments.
santoshcomcast Nov 6, 2025
b1e9412
addressed review comments.
santoshcomcast Nov 10, 2025
661e8ec
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 11, 2025
bbe42f2
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 12, 2025
299bf52
fix build issue
santoshcomcast Nov 12, 2025
5f5a634
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 13, 2025
6553c8f
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 14, 2025
12f0193
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 17, 2025
565dbde
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 17, 2025
17faa45
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 17, 2025
8f60d7e
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 20, 2025
7455db3
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 20, 2025
8e51e51
RDKEMW-8587: consume the config variables using dlsym() in MW.
santoshcomcast Nov 20, 2025
329c312
Merge pull request #179 from rdkcentral/develop
santoshcomcast Nov 26, 2025
1928496
debug. disable dumpconfig and add logs
santoshcomcast Dec 9, 2025
05aa70f
enable debugconfig
santoshcomcast Dec 10, 2025
64a4609
move the debug prints within if condtion for all config dumpconfig
santoshcomcast Dec 10, 2025
9789231
added few more logs, lock_guard in searchconfig
santoshcomcast Dec 10, 2025
dde8258
add delay while every load
santoshcomcast Dec 10, 2025
edb8f55
add count variable for close the opened hal file
santoshcomcast Dec 11, 2025
2864e49
fix build issue.
santoshcomcast Dec 11, 2025
e287d3a
add condition wait for 4 loads complete.
santoshcomcast Dec 11, 2025
bccfc77
disable the dlclose.
santoshcomcast Dec 12, 2025
103ec2a
Force to use FP old config to check crash.
santoshcomcast Dec 12, 2025
76d0910
fix fp Update frontPanelConfig.cpp
santoshcomcast Dec 15, 2025
acd9e70
fix build error
santoshcomcast Dec 15, 2025
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
152 changes: 141 additions & 11 deletions ds/audioOutputPortConfig.cpp
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 ds/audioOutputPortConfig.cpp

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 'ds/audioOutputPortConfig.cpp' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2.1-20161031, 321 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/2.1-20161031.tar.gz, file: ds/audioOutputPortConfig.cpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -34,6 +34,19 @@
#include "dsUtl.h"
#include "stdlib.h"
#include "dslogger.h"
#include <dlfcn.h>
#include "manager.hpp"


#define DEBUG 1 // Using for dumpconfig
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of this macro replace print in all dump function from INT_INFO INT_DEBUG

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The DEBUG macro is hardcoded to 1, which means debug code will always execute in production builds. This can impact performance and produce excessive logging.

Consider using a build-time configuration or removing the macro entirely if debug output is always desired, or setting it to 0 by default.

Suggested change
#define DEBUG 1 // Using for dumpconfig
#ifndef DEBUG
#define DEBUG 0
#endif

Copilot uses AI. Check for mistakes.

typedef struct audioConfigs
{
const dsAudioTypeConfig_t *pKConfigs;
const dsAudioPortConfig_t *pKPorts;
int *pKConfigSize;
int *pKPortSize;
}audioConfigs_t;

namespace device {

Expand Down Expand Up @@ -108,8 +121,89 @@
return supportedTypes;
}

#if 0
Copy link
Contributor

Choose a reason for hiding this comment

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

@santoshcomcast , Can we remove this

Copy link
Author

Choose a reason for hiding this comment

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

done.

bool searchConfigs(void **pConfigVar, const char *searchConfigStr)
{
INT_INFO("%d:%s: Entering function\n", __LINE__, __func__);
INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr);

static int invalidsize = -1;

pthread_mutex_lock(&dsLock);

void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (dllib) {
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}

dlclose(dllib);
}
else {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
}
pthread_mutex_unlock(&dsLock);
INT_INFO("%d:%s: Exit function\n", __LINE__, __func__);
return (*pConfigVar != NULL);
}
#endif
void dumpconfig(audioConfigs_t *config)
Copy link
Contributor

@apatel859 apatel859 Nov 14, 2025

Choose a reason for hiding this comment

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

Enable copilit as reviewr so fix all issue reported by copilot. Also review whole file and make sure null check added as poineted by Yuva

Copy link
Author

Choose a reason for hiding this comment

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

I have addressed all the review comments from you, Yuva, and Copilot, except for the new one related to the deumconfig() API. This function is being called only after performing the necessary validation in the caller function, and then the call is made accordingly.

{
INT_INFO("%d:%s: Entering function\n", __LINE__, __func__);
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of using INT_INFO and creating macro for "#define DEBUG 1 /" use INT_DEBUG and remove macro

Copy link
Author

Choose a reason for hiding this comment

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

I will do change to INT_DEBUG in final review before merge since debug logs are not coming.

INT_INFO("%d:%s: pKConfigs = %p\n", __LINE__, __func__, config->pKConfigs);
INT_INFO("%d:%s: pKPorts = %p\n", __LINE__, __func__, config->pKPorts);
INT_INFO("%d:%s: pKConfigSize = %p\n", __LINE__, __func__, config->pKConfigSize);
INT_INFO("%d:%s: pKPortSize = %p\n", __LINE__, __func__, config->pKPortSize);

INT_INFO("\n\n=========================================================================================================================\n\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

i see many comment from yova regardig null check so go thought all the changes and make sure pointer has null check

Copy link
Author

Choose a reason for hiding this comment

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

Taken care.

if(config->pKConfigs != NULL && *(config->pKConfigSize) != -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add null check for pKConfigs and pKConfigSize since it is pointer variable

Copy link
Author

Choose a reason for hiding this comment

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

Done.

{
for (size_t i = 0; i < *(config->pKConfigSize); i++) {
const dsAudioTypeConfig_t *typeCfg = &(config->pKConfigs[i]);
INT_INFO("%d:%s: typeCfg->typeId = %d\n", __LINE__, __func__, typeCfg->typeId);
INT_INFO("%d:%s: typeCfg->name = %s\n", __LINE__, __func__, typeCfg->name);
INT_INFO("%d:%s: typeCfg->numSupportedEncodings = %zu\n", __LINE__, __func__, typeCfg->numSupportedEncodings);
INT_INFO("%d:%s: typeCfg->numSupportedCompressions = %zu\n", __LINE__, __func__, typeCfg->numSupportedCompressions);
INT_INFO("%d:%s: typeCfg->numSupportedStereoModes = %zu\n", __LINE__, __func__, typeCfg->numSupportedStereoModes);
}
}
else
{
INT_ERROR("%d:%s: kAudioConfigs is NULL and kConfig_size_local is -1\n", __LINE__, __func__);
}
if(config->pKPorts != NULL && *(config->pKPortSize) != -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add null check for pKPortSize since it is pointer variable

Copy link
Author

Choose a reason for hiding this comment

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

Done.

{
for (size_t i = 0; i < *(config->pKPortSize); i++) {
const dsAudioPortConfig_t *port = &(config->pKPorts[i]);
INT_INFO("%d:%s: port->id.type = %d\n", __LINE__, __func__, port->id.type);
INT_INFO("%d:%s: port->id.index = %d\n", __LINE__, __func__, port->id.index);
}
}
else
{
INT_ERROR("%d:%s: kAudioPorts is NULL and kPort_size_local is -1\n", __LINE__, __func__);
}
INT_INFO("\n\n=========================================================================================================================\n\n");
INT_INFO("%d:%s: Exit function\n", __LINE__, __func__);
}


void AudioOutputPortConfig::load()
{
int configSize, portSize;
audioConfigs_t configuration = {0};
const char* searchVaribles[] = {
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The variable name searchVaribles is misspelled. It should be searchVariables.

Suggested change
const char* searchVaribles[] = {
const char* searchVariables[] = {

Copilot uses AI. Check for mistakes.
"kAudioConfigs",
"kAudioPorts",
"kAudioConfigs_size",
"kAudioPorts_size"
};
bool ret = false;

try {
/*
* Load Constants First.
Expand All @@ -133,12 +227,50 @@

}

INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]);
ret = searchConfigs((void **)&configuration.pKConfigs, searchVaribles[0]);
if(ret == true)
{
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]);
ret = searchConfigs((void **)&configuration.pKConfigSize, (char *)searchVaribles[2]);
Copy link
Contributor

Choose a reason for hiding this comment

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

When u call searchConfig API first it should have input variable and second out variable. it means earchVaribles[2] should be first argumenet not second

if(ret == false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need fallbacks to default configs if pKConfigSize, pKPorts and pKPortSize are not present in the library

Copy link
Author

Choose a reason for hiding this comment

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

We can not mix the new and old configs.

{
INT_ERROR("%s is not defined\n", searchVaribles[2]);
}
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]);
ret = searchConfigs((void **)&configuration.pKPorts, searchVaribles[1]);
if(ret == false)
{
INT_ERROR("%s is not defined\n", searchVaribles[1]);
}
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]);
ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]);
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Unnecessary cast to (char *) for parameters that are already const char*. The searchConfigs() function expects const char* for the second parameter, so these casts are redundant.

Suggested change
ret = searchConfigs((void **)&configuration.pKPortSize, (char *)searchVaribles[3]);
ret = searchConfigs((void **)&configuration.pKPortSize, searchVaribles[3]);

Copilot uses AI. Check for mistakes.
if(ret == false)
{
INT_ERROR("%s is not defined\n", searchVaribles[3]);
}
}
else
{
INT_ERROR("Read Old Configs\n");
configuration.pKConfigs = kConfigs;
configSize = dsUTL_DIM(kConfigs);
configuration.pKConfigSize = &configSize;
configuration.pKPorts = kPorts;
Comment on lines +232 to +235
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Local stack variables configSize and portSize may go out of scope while their addresses are still stored in the configuration struct and used later. When the fallback path is taken (lines 226-231), these local variables' addresses are stored and later dereferenced at lines 247 and 268. This results in undefined behavior.

The variables should be declared as static or the configuration struct should store the values directly instead of pointers to local variables.

Suggested change
configuration.pKConfigs = kConfigs;
configSize = dsUTL_DIM(kConfigs);
configuration.pKConfigSize = &configSize;
configuration.pKPorts = kPorts;
configuration.pKConfigs = kConfigs;
static int configSize;
configSize = dsUTL_DIM(kConfigs);
configuration.pKConfigSize = &configSize;
configuration.pKPorts = kPorts;
static int portSize;

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

Added the static in the start of funcation and using same here.

portSize = dsUTL_DIM(kPorts);
configuration.pKPortSize = &portSize;
INT_INFO("configuration.pKConfigs =%p, configuration.pKPorts =%p, *(configuration.pKConfigSize) = %d, *(configuration.pKPortSize) = %d\n", configuration.pKConfigs, configuration.pKPorts, *(configuration.pKConfigSize), *(configuration.pKPortSize));
}
#if DEBUG
dumpconfig(&configuration);
#endif

/*
* Initialize Audio portTypes (encodings, compressions etc.)
* and its port instances (db, level etc)
*/
for (size_t i = 0; i < dsUTL_DIM(kConfigs); i++) {
const dsAudioTypeConfig_t *typeCfg = &kConfigs[i];
* Initialize Audio portTypes (encodings, compressions etc.)
* and its port instances (db, level etc)
*/
for (size_t i = 0; i < *(configuration.pKConfigSize); i++) {
const dsAudioTypeConfig_t *typeCfg = &(configuration.pKConfigs[i]);
AudioOutputPortType &aPortType = AudioOutputPortType::getInstance(typeCfg->typeId);
aPortType.enable();
for (size_t j = 0; j < typeCfg->numSupportedEncodings; j++) {
Expand All @@ -148,20 +280,18 @@
for (size_t j = 0; j < typeCfg->numSupportedCompressions; j++) {
aPortType.addCompression(typeCfg->compressions[j]);
_aCompressions.at(typeCfg->compressions[j]).enable();

}
for (size_t j = 0; j < typeCfg->numSupportedStereoModes; j++) {
aPortType.addStereoMode(typeCfg->stereoModes[j]);
_aStereoModes.at(typeCfg->stereoModes[j]).enable();

}
}

/*
* set up ports based on kPorts[]
*/
for (size_t i = 0; i < dsUTL_DIM(kPorts); i++) {
const dsAudioPortConfig_t *port = &kPorts[i];
* set up ports based on kPorts[]
*/
for (size_t i = 0; i < *(configuration.pKPortSize); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add NULL check here as well.

const dsAudioPortConfig_t *port = &configuration.pKPorts[i];
_aPorts.push_back(AudioOutputPort((port->id.type), port->id.index, i));
_aPortTypes.at(port->id.type).addPort(_aPorts.at(i));
}
Expand Down
99 changes: 91 additions & 8 deletions ds/frontPanelConfig.cpp
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 ds/frontPanelConfig.cpp

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 'ds/frontPanelConfig.cpp' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/2010, 475 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/RDK-DEV-2010.tar.gz, file: ds/frontPanelConfig.cpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -41,9 +41,18 @@
#include "frontPanelSettings.hpp"
#include "illegalArgumentException.hpp"
#include "dslogger.h"
#include "manager.hpp"

using namespace std;

typedef struct fpdConfigs
{
const dsFPDColorConfig_t *pKFPDIndicatorColors;
const dsFPDIndicatorConfig_t *pKIndicators;
int *pKFPDIndicatorColors_size;
int *pKIndicators_size;
}fpdConfigs_t;

namespace device {

/**
Expand Down Expand Up @@ -337,6 +346,27 @@
return rTexts;
}

void dumpconfig(fpdConfigs_t *configuration)
{
// Dump the configuration details
printf("Dumping Front Panel Configuration Details:\n");
printf("Indicator Colors:\n");
for (size_t i = 0; i < *(configuration->pKFPDIndicatorColors_size); i++) {
printf(" Color ID: %d, color: %d\n",
configuration->pKFPDIndicatorColors[i].id,
configuration->pKFPDIndicatorColors[i].color);
}

printf("Indicators:\n");
for (size_t i = 0; i < *(configuration->pKIndicators_size); i++) {
printf(" Indicator ID: %d, Max Brightness: %d, Max Cycle Rate: %d, Levels: %d, Color Mode: %d\n",
configuration->pKIndicators[i].id,
configuration->pKIndicators[i].maxBrightness,
configuration->pKIndicators[i].maxCycleRate,
configuration->pKIndicators[i].levels,
configuration->pKIndicators[i].colorMode);
}
}

/**
* @fn FrontPanelConfig::load()
Expand All @@ -352,18 +382,71 @@
* 1. Create Supported Colors.
* 2. Create Indicators.
*/
int indicatorSize, indicatorColorSize, invalid_size = -1;
fpdConfigs_t configuration = {0};

const char* searchVaribles[] = {
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The variable name searchVaribles is misspelled. It should be searchVariables.

Copilot uses AI. Check for mistakes.
"kFPDIndicatorColors",
"kFPDIndicatorColors_size",
"kIndicators",
"kIndicators_size"
};
bool ret = false;

INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[0]);
ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors, searchVaribles[0]);
if(ret == true)
{
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[1]);
ret = searchConfigs((void **)&configuration.pKFPDIndicatorColors_size, (char *)searchVaribles[1]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need fallbacks here as well ?

if(ret == false)
{
INT_ERROR("%s is not defined\n", searchVaribles[1]);
configuration.pKFPDIndicatorColors_size = &invalid_size;
}
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[2]);
ret = searchConfigs((void **)&configuration.pKIndicators, searchVaribles[2]);
if(ret == false)
{
INT_ERROR("%s is not defined\n", searchVaribles[2]);
}
INT_INFO("%d:%s: Calling searchConfigs( %s)\n", __LINE__, __func__, searchVaribles[3]);
ret = searchConfigs((void **)&configuration.pKIndicators_size, (char *)searchVaribles[3]);
if(ret == false)
{
INT_ERROR("%s is not defined\n", searchVaribles[3]);
configuration.pKIndicators_size = &invalid_size;
}
}
else
{
INT_ERROR("Read Old Configs\n");
configuration.pKFPDIndicatorColors = kIndicatorColors;
indicatorColorSize = dsUTL_DIM(kIndicatorColors);
configuration.pKFPDIndicatorColors_size = &indicatorColorSize;
configuration.pKIndicators = kIndicators;
indicatorSize = dsUTL_DIM(kIndicators);
configuration.pKIndicators_size = &indicatorSize;

INT_INFO("configuration.pKFPDIndicatorColors =%p, *(configuration.pKFPDIndicatorColors_size) = %d\n", configuration.pKFPDIndicatorColors, *(configuration.pKFPDIndicatorColors_size));
INT_INFO("configuration.pKIndicators =%p, *(configuration.pKIndicators_size) = %d\n", configuration.pKIndicators, *(configuration.pKIndicators_size));
}
#if DEBUG
//dumpconfig(&configuration);
#endif

{
for (size_t i = 0; i < dsUTL_DIM(kIndicatorColors); i++) {
_colors.push_back(FrontPanelIndicator::Color(kIndicatorColors[i].id));
for (size_t i = 0; i < *(configuration.pKFPDIndicatorColors_size); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add NULL check here as well.

Copy link
Author

Choose a reason for hiding this comment

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

Done

_colors.push_back(FrontPanelIndicator::Color(configuration.pKFPDIndicatorColors[i].id));
}

for (size_t i = 0; i < dsUTL_DIM(kIndicators); i++) {
for (size_t i = 0; i < *(configuration.pKIndicators_size); i++) {
/* All indicators support a same set of colors */
_indicators.push_back(FrontPanelIndicator(kIndicators[i].id,
kIndicators[i].maxBrightness,
kIndicators[i].maxCycleRate,
kIndicators[i].levels,
kIndicators[i].colorMode));
_indicators.push_back(FrontPanelIndicator(configuration.pKIndicators[i].id,
configuration.pKIndicators[i].maxBrightness,
configuration.pKIndicators[i].maxCycleRate,
configuration.pKIndicators[i].levels,
configuration.pKIndicators[i].colorMode));
}

}
Expand Down
2 changes: 2 additions & 0 deletions ds/include/manager.hpp
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 ds/include/manager.hpp

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 'ds/include/manager.hpp' (Match: rdk/components/generic/devicesettings/rdk/components/generic/devicesettings/b34ed54, 169 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdk/components/generic/devicesettings/+archive/b34ed545b533a0cf4d29d221cc23daad47f32644.tar.gz, file: ds/include/manager.hpp)
*
* Copyright 2016 RDK Management
*
Expand Down Expand Up @@ -156,6 +156,8 @@
*/
namespace device {

// Forward declaration for searchConfigs function
bool searchConfigs(void **pConfigVar, const char *searchConfigStr);

/**
* @class Manager
Expand Down
36 changes: 36 additions & 0 deletions ds/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
#include "exception.hpp"
#include <pthread.h>
#include <unistd.h>
#include <dlfcn.h>
#include "dsHALConfig.h"


static pthread_mutex_t dsLock = PTHREAD_MUTEX_INITIALIZER;


/**
* @file manager.cpp
Expand Down Expand Up @@ -154,6 +160,36 @@ void Manager::load()
printf("%d:%s load completed\n", __LINE__, __FUNCTION__);
}

bool searchConfigs(void **pConfigVar, const char *searchConfigStr)
{
INT_INFO("%d:%s: Entering function\n", __LINE__, __func__);
INT_INFO("%d:%s: searchConfigStr = %s\n", __LINE__, __func__, searchConfigStr);

static int invalidsize = -1;

Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The unused variable invalidsize is declared but never used. It appears to be a leftover from development and should be removed.

Suggested change
static int invalidsize = -1;

Copilot uses AI. Check for mistakes.
pthread_mutex_lock(&dsLock);

void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (dllib) {
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}

dlclose(dllib);
}
else {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
}
Comment on lines 296 to 334
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

The dlopen() handle is not stored and dlclose() is called immediately after dlsym(). This means the loaded library is unloaded while the returned pointers are still being used throughout the application lifecycle. When dlclose() is called, the memory pointed to by the symbols may become invalid, leading to potential crashes or undefined behavior.

Consider either:

  1. Keeping the library handle open for the lifetime of the application (store it globally and never close it)
  2. Using RTLD_NODELETE flag with dlopen() to prevent unloading
Suggested change
pthread_mutex_lock(&dsLock);
void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (dllib) {
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}
dlclose(dllib);
}
else {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
}
static void *dllib = nullptr;
pthread_mutex_lock(&dsLock);
if (!dllib) {
dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (!dllib) {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
pthread_mutex_unlock(&dsLock);
INT_INFO("%d:%s: Exit function\n", __LINE__, __func__);
return false;
}
}
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}
// Do NOT dlclose(dllib); keep the handle open for the lifetime of the process

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

Need to check with team

Comment on lines 296 to 334
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

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

Calling dlopen() multiple times for every configuration variable lookup is inefficient. The searchConfigs() function is called 6 times in videoOutputPortConfig.cpp, 6 times in frontPanelConfig.cpp, 4 times in audioOutputPortConfig.cpp, and 2 times in videoDeviceConfig.cpp. Each call reopens the same library.

Consider opening the library once (e.g., during initialization) and reusing the handle for all dlsym() calls.

Suggested change
pthread_mutex_lock(&dsLock);
void *dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (dllib) {
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}
dlclose(dllib);
}
else {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
}
static void *dllib = nullptr;
pthread_mutex_lock(&dsLock);
if (!dllib) {
dllib = dlopen(RDK_DSHAL_NAME, RTLD_LAZY);
if (!dllib) {
INT_ERROR("%d:%s: Open %s failed\n", __LINE__, __func__, RDK_DSHAL_NAME);
pthread_mutex_unlock(&dsLock);
INT_INFO("%d:%s: Exit function\n", __LINE__, __func__);
return false;
}
}
*pConfigVar = (void *) dlsym(dllib, searchConfigStr);
if (*pConfigVar != NULL) {
INT_INFO("%s is defined and loaded pConfigVar= %p\r\n", searchConfigStr, *pConfigVar);
}
else {
INT_ERROR("%d:%s: %s is not defined\n", __LINE__, __func__, searchConfigStr);
}

Copilot uses AI. Check for mistakes.
pthread_mutex_unlock(&dsLock);
INT_INFO("%d:%s: Exit function\n", __LINE__, __func__);
return (*pConfigVar != NULL);
}


/**
* @fn void Manager::DeInitialize()
* @brief This API is used to deinitialize the device settings module.
Expand Down
Loading
Loading