Skip to content

Conversation

@Sukanya673
Copy link
Contributor

Reason for change:
The libc strcmp() function is likely to be much more optimized than the legacy AnscEqualString(). Test Procedure: Sanity
Risks: None.
Signed-off-by: Andre McCurdy [email protected]
(cherry picked from commit 8874e6e)

Reason for change:
The libc strcmp() function is likely to be much more optimized than the legacy AnscEqualString().
Test Procedure: Sanity
Risks: None.
Signed-off-by: Andre McCurdy <[email protected]>
(cherry picked from commit 8874e6e)
@Sukanya673 Sukanya673 requested a review from a team as a code owner June 23, 2025 09:52
@narendradandu
Copy link
Contributor

please resolve conflicts, AnscEqualString handles NULL cases, can you check and confirm if all the inputs have null check validations before calling strcmp

@CLAassistant
Copy link

CLAassistant commented Aug 14, 2025

CLA assistant check
All committers have signed the CLA.

@Sukanya673 Sukanya673 marked this pull request as draft August 14, 2025 16:12
@Sukanya673 Sukanya673 marked this pull request as ready for review September 22, 2025 06:50
{
CcspTraceInfo(("%s", LogMsg));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}
else
{
CcspTraceInfo(("%s", LogMsg));
}

Comment on lines +1294 to +1302
if(wifiFreqBandMap[seqCounter].wifiFreqBandStr != NULL) {
if (strcmp(pFreqBandStr, wifiFreqBandMap[seqCounter].wifiFreqBandStr) == 0)
{
*pFreqBandEnum = wifiFreqBandMap[seqCounter].halWifiFreqBand;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingFrequencyBand : %d\n", __FUNCTION__, pFreqBandStr, *pFreqBandEnum);
isBandInvalid = FALSE;
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if(wifiFreqBandMap[seqCounter].wifiFreqBandStr != NULL) {
if (strcmp(pFreqBandStr, wifiFreqBandMap[seqCounter].wifiFreqBandStr) == 0)
{
*pFreqBandEnum = wifiFreqBandMap[seqCounter].halWifiFreqBand;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingFrequencyBand : %d\n", __FUNCTION__, pFreqBandStr, *pFreqBandEnum);
isBandInvalid = FALSE;
break;
}
}
if((wifiFreqBandMap[seqCounter].wifiFreqBandStr != NULL) && (strcmp(pFreqBandStr, wifiFreqBandMap[seqCounter].wifiFreqBandStr) == 0))
{
*pFreqBandEnum = wifiFreqBandMap[seqCounter].halWifiFreqBand;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingFrequencyBand : %d\n", __FUNCTION__, pFreqBandStr, *pFreqBandEnum);
isBandInvalid = FALSE;
break;
}

Comment on lines +1210 to +1218
if((environment != NULL) && (wifiEnviromentMap[seqCounter].environment != NULL)) {
if (strcmp(environment, wifiEnviromentMap[seqCounter].environment) == 0)
{
*operatingEnvironment = wifiEnviromentMap[seqCounter].operatingEnvironment;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingEnvironment : %d\n", __FUNCTION__, pRegDomain, *operatingEnvironment);
isregDomainInvalid = FALSE;
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if((environment != NULL) && (wifiEnviromentMap[seqCounter].environment != NULL)) {
if (strcmp(environment, wifiEnviromentMap[seqCounter].environment) == 0)
{
*operatingEnvironment = wifiEnviromentMap[seqCounter].operatingEnvironment;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingEnvironment : %d\n", __FUNCTION__, pRegDomain, *operatingEnvironment);
isregDomainInvalid = FALSE;
break;
}
}
if (((environment != NULL) && (wifiEnviromentMap[seqCounter].environment != NULL)) && (strcmp(environment, wifiEnviromentMap[seqCounter].environment) == 0))
{
*operatingEnvironment = wifiEnviromentMap[seqCounter].operatingEnvironment;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s OperatingEnvironment : %d\n", __FUNCTION__, pRegDomain, *operatingEnvironment);
isregDomainInvalid = FALSE;
break;
}

Comment on lines +1197 to +1205
if((tmp_regDomain != NULL) && (wifiCountryMapMembers[seqCounter].countryStr != NULL)) {
if (strcmp(tmp_regDomain, wifiCountryMapMembers[seqCounter].countryStr) == 0)
{
*countryCode = wifiCountryMapMembers[seqCounter].countryCode;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s Countrycode : %d\n", __FUNCTION__, pRegDomain, *countryCode);
isregDomainInvalid = FALSE;
break;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if((tmp_regDomain != NULL) && (wifiCountryMapMembers[seqCounter].countryStr != NULL)) {
if (strcmp(tmp_regDomain, wifiCountryMapMembers[seqCounter].countryStr) == 0)
{
*countryCode = wifiCountryMapMembers[seqCounter].countryCode;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s Countrycode : %d\n", __FUNCTION__, pRegDomain, *countryCode);
isregDomainInvalid = FALSE;
break;
}
}
if (((tmp_regDomain != NULL) && (wifiCountryMapMembers[seqCounter].countryStr != NULL)) && (strcmp(tmp_regDomain, wifiCountryMapMembers[seqCounter].countryStr) == 0))
{
*countryCode = wifiCountryMapMembers[seqCounter].countryCode;
ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s input : %s Countrycode : %d\n", __FUNCTION__, pRegDomain, *countryCode);
isregDomainInvalid = FALSE;
break;
}

Comment on lines +911 to +916
if(wifiDataTxRateMap[seqCounter].DataTxRateStr != NULL) {
if (strcmp(token, wifiDataTxRateMap[seqCounter].DataTxRateStr) == 0)
{
isRateInvalid = FALSE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if(wifiDataTxRateMap[seqCounter].DataTxRateStr != NULL) {
if (strcmp(token, wifiDataTxRateMap[seqCounter].DataTxRateStr) == 0)
{
isRateInvalid = FALSE;
}
}
if ((wifiDataTxRateMap[seqCounter].DataTxRateStr != NULL) && (strcmp(token, wifiDataTxRateMap[seqCounter].DataTxRateStr) == 0))
{
isRateInvalid = FALSE;
}

Comment on lines +20754 to +20755
//WiFi_SetHS2Status(vap_pcfg->vap_index, false, true);
*pBool = interworking_pcfg->passpoint.enable;
Copy link
Contributor

Choose a reason for hiding this comment

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

Align:

Suggested change
//WiFi_SetHS2Status(vap_pcfg->vap_index, false, true);
*pBool = interworking_pcfg->passpoint.enable;
//WiFi_SetHS2Status(vap_pcfg->vap_index, false, true);
*pBool = interworking_pcfg->passpoint.enable;

Comment on lines +20944 to +20966
if(ParamName != NULL) {
if (strcmp(ParamName, "Enable") == 0) {
if(bValue == vapInfo->u.bss_info.interworking.passpoint.enable){
CcspTraceWarning(("Passpoint value Already configured. Return Success\n"));
return TRUE;
}

retPsmGet = PSM_Get_Record_Value2(bus_handle,g_Subsystem, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.WiFi-Passpoint.Enable", NULL, &strValue);
if ((retPsmGet != CCSP_SUCCESS) || (false == _ansc_atoi(strValue)) || (FALSE == _ansc_atoi(strValue))){
((CCSP_MESSAGE_BUS_INFO *)bus_handle)->freefunc(strValue);
CcspTraceWarning(("Cannot Enable Passpoint. RFC Disabled\n"));
return FALSE;
}

if(false == vapInfo->u.bss_info.interworking.interworking.interworkingEnabled){
CcspTraceWarning(("Cannot Enable Passpoint. Interworking Disabled\n"));
return FALSE;
}
vapInfo->u.bss_info.interworking.passpoint.enable = bValue;
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if(ParamName != NULL) {
if (strcmp(ParamName, "Enable") == 0) {
if(bValue == vapInfo->u.bss_info.interworking.passpoint.enable){
CcspTraceWarning(("Passpoint value Already configured. Return Success\n"));
return TRUE;
}
retPsmGet = PSM_Get_Record_Value2(bus_handle,g_Subsystem, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.WiFi-Passpoint.Enable", NULL, &strValue);
if ((retPsmGet != CCSP_SUCCESS) || (false == _ansc_atoi(strValue)) || (FALSE == _ansc_atoi(strValue))){
((CCSP_MESSAGE_BUS_INFO *)bus_handle)->freefunc(strValue);
CcspTraceWarning(("Cannot Enable Passpoint. RFC Disabled\n"));
return FALSE;
}
if(false == vapInfo->u.bss_info.interworking.interworking.interworkingEnabled){
CcspTraceWarning(("Cannot Enable Passpoint. Interworking Disabled\n"));
return FALSE;
}
vapInfo->u.bss_info.interworking.passpoint.enable = bValue;
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}
}
if ((ParamName != NULL) && (strcmp(ParamName, "Enable") == 0))
{
if(bValue == vapInfo->u.bss_info.interworking.passpoint.enable){
CcspTraceWarning(("Passpoint value Already configured. Return Success\n"));
return TRUE;
}
retPsmGet = PSM_Get_Record_Value2(bus_handle,g_Subsystem, "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.WiFi-Passpoint.Enable", NULL, &strValue);
if ((retPsmGet != CCSP_SUCCESS) || (false == _ansc_atoi(strValue)) || (FALSE == _ansc_atoi(strValue))){
((CCSP_MESSAGE_BUS_INFO *)bus_handle)->freefunc(strValue);
CcspTraceWarning(("Cannot Enable Passpoint. RFC Disabled\n"));
return FALSE;
}
if(false == vapInfo->u.bss_info.interworking.interworking.interworkingEnabled){
CcspTraceWarning(("Cannot Enable Passpoint. Interworking Disabled\n"));
return FALSE;
}
vapInfo->u.bss_info.interworking.passpoint.enable = bValue;
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}

Comment on lines +21029 to +21045
if(Parameters != NULL) {
if (strcmp(ParamName, "Parameters") == 0)
{
if (strcmp((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters, pString) == 0){
return TRUE;
}else {
cJSON *p_root = cJSON_Parse(pString);
if(p_root == NULL) {
wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Invalid json for vap %s\n", __FUNCTION__,__LINE__,pcfg->vap_name);
return FALSE;
}
AnscCopyString((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters,pString);
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if(Parameters != NULL) {
if (strcmp(ParamName, "Parameters") == 0)
{
if (strcmp((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters, pString) == 0){
return TRUE;
}else {
cJSON *p_root = cJSON_Parse(pString);
if(p_root == NULL) {
wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Invalid json for vap %s\n", __FUNCTION__,__LINE__,pcfg->vap_name);
return FALSE;
}
AnscCopyString((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters,pString);
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}
}
}
if ((Parameters != NULL) && (strcmp(ParamName, "Parameters") == 0))
{
if (strcmp((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters, pString) == 0){
return TRUE;
} else {
cJSON *p_root = cJSON_Parse(pString);
if(p_root == NULL) {
wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Invalid json for vap %s\n", __FUNCTION__,__LINE__,pcfg->vap_name);
return FALSE;
}
AnscCopyString((char*)vapInfo->u.bss_info.interworking.passpoint.hs2Parameters,pString);
set_dml_cache_vap_config_changed(instance_number - 1);
return TRUE;
}
}

Comment on lines +21151 to +21166
if(ParamName != NULL) {
if (strcmp(ParamName, "Enable") == 0) {
if (global_wifi_config->global_parameters.mgt_frame_rate_limit_enable == bValue) {
return TRUE;
}
wifi_util_dbg_print(WIFI_DMCLI, "%s:%d: RateLimit Enable: %d\n", __func__, __LINE__,
bValue);
global_wifi_config->global_parameters.mgt_frame_rate_limit_enable = bValue;

if (push_global_config_dml_cache_to_one_wifidb() != RETURN_OK) {
wifi_util_error_print(WIFI_DMCLI,
"%s:%d: Failed to push RateLimit Enable value to onewifi db\n", __func__, __LINE__);
}
return TRUE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove redundant nesting:

Suggested change
if(ParamName != NULL) {
if (strcmp(ParamName, "Enable") == 0) {
if (global_wifi_config->global_parameters.mgt_frame_rate_limit_enable == bValue) {
return TRUE;
}
wifi_util_dbg_print(WIFI_DMCLI, "%s:%d: RateLimit Enable: %d\n", __func__, __LINE__,
bValue);
global_wifi_config->global_parameters.mgt_frame_rate_limit_enable = bValue;
if (push_global_config_dml_cache_to_one_wifidb() != RETURN_OK) {
wifi_util_error_print(WIFI_DMCLI,
"%s:%d: Failed to push RateLimit Enable value to onewifi db\n", __func__, __LINE__);
}
return TRUE;
}
}
if ((ParamName != NULL) && (strcmp(ParamName, "Enable") == 0))
{
if (global_wifi_config->global_parameters.mgt_frame_rate_limit_enable == bValue) {
return TRUE;
}
wifi_util_dbg_print(WIFI_DMCLI, "%s:%d: RateLimit Enable: %d\n", __func__, __LINE__, bValue);
global_wifi_config->global_parameters.mgt_frame_rate_limit_enable = bValue;
if (push_global_config_dml_cache_to_one_wifidb() != RETURN_OK) {
wifi_util_error_print(WIFI_DMCLI,
"%s:%d: Failed to push RateLimit Enable value to onewifi db\n", __func__, __LINE__);
}
return TRUE;
}

@@ -20978,7 +21271,10 @@ BOOL MgtFrameRateLimit_SetParamUlongValue(ANSC_HANDLE hInsContext, char *ParamNa
return FALSE;
}

if (AnscEqualString(ParamName, "RateLimit", TRUE)) {
if(ParamName == NULL) {
return FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return FALSE;
wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Global Config\n", __FUNCTION__,__LINE__);
return FALSE;

Comment on lines +634 to +640
if(ParamName != NULL) {
if (strcmp(ParamName, "Enable") == 0) {
pcfg->ActiveMsmtEnable = bValue;
push_blaster_config_dml_to_ctrl_queue();
return TRUE;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

or it would be nicer to check ParamName != NULL in the first if in the function, just as you did it in other cases here.

//ccspWifiDbgPrint(CCSP_WIFI_TRACE, "%s Token : %s txRate : %d\n", __FUNCTION__, token, *pTxRate);
isRateInvalid = FALSE;
}
if(wifiDataTxRateMap[seqCounter].DataTxRateStr != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this null check is redundant here. This string is filled by the OneWifi, so extreme defensive programming is not needed. imho.

isregDomainInvalid = FALSE;
break;
}
if((tmp_regDomain != NULL) && (wifiCountryMapMembers[seqCounter].countryStr != NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

again, redundant check. tmp_regDomain is being worked on 5 lines above.

isregDomainInvalid = FALSE;
break;
}
if((environment != NULL) && (wifiEnviromentMap[seqCounter].environment != NULL)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

redundant check(s)

isWifiStdInvalid = FALSE;
}
else if (AnscEqualString(token, wifiStdDmlMap[seqCounter].wifiStdName, TRUE))
else if ((wifiStdDmlMap[seqCounter].wifiStdName != NULL) && (strcmp(token, wifiStdDmlMap[seqCounter].wifiStdName) == 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

unless this is warranted, please stick to pure replacement of function. anscequalstring->strcmp.
ANy performance improvement one might notice can be easily reversed by making redundant checks.

isBandInvalid = FALSE;
break;
}
if(wifiFreqBandMap[seqCounter].wifiFreqBandStr != NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

redundant

Copy link
Contributor

Choose a reason for hiding this comment

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

please move this file to separate review, and split it in a patch series - at list 2, so that diff is shorter. Ideally < 500-800 changed lines per review.

@pradeeptakdas
Copy link
Contributor

Andre will fix the review comments and bring the changes in a separate PR

@github-actions github-actions bot locked and limited conversation to collaborators Oct 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants