-
Notifications
You must be signed in to change notification settings - Fork 126
RDKCOM-5335: RDKBDEV-3195 update AnscEqualString() -> strcmp() #419
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
Conversation
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)
|
please resolve conflicts, AnscEqualString handles NULL cases, can you check and confirm if all the inputs have null check validations before calling strcmp |
| { | ||
| CcspTraceInfo(("%s", LogMsg)); | ||
| } | ||
| } |
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.
| } | |
| } | |
| else | |
| { | |
| CcspTraceInfo(("%s", LogMsg)); | |
| } |
| 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; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } |
| 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; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } |
| 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; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } |
| if(wifiDataTxRateMap[seqCounter].DataTxRateStr != NULL) { | ||
| if (strcmp(token, wifiDataTxRateMap[seqCounter].DataTxRateStr) == 0) | ||
| { | ||
| isRateInvalid = FALSE; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } |
| //WiFi_SetHS2Status(vap_pcfg->vap_index, false, true); | ||
| *pBool = interworking_pcfg->passpoint.enable; |
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.
Align:
| //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; |
| 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; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } |
| 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; | ||
| } | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |
| } | |
| } |
| 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; | ||
| } | ||
| } |
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.
Please remove redundant nesting:
| 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; | |||
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.
| return FALSE; | |
| wifi_util_dbg_print(WIFI_DMCLI,"%s:%d Unable to get Global Config\n", __FUNCTION__,__LINE__); | |
| return FALSE; |
| if(ParamName != NULL) { | ||
| if (strcmp(ParamName, "Enable") == 0) { | ||
| pcfg->ActiveMsmtEnable = bValue; | ||
| push_blaster_config_dml_to_ctrl_queue(); | ||
| return TRUE; | ||
| } | ||
| } |
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.
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) { |
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.
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)) { |
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.
again, redundant check. tmp_regDomain is being worked on 5 lines above.
| isregDomainInvalid = FALSE; | ||
| break; | ||
| } | ||
| if((environment != NULL) && (wifiEnviromentMap[seqCounter].environment != NULL)) { |
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.
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)) |
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.
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) { |
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.
redundant
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.
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.
|
Andre will fix the review comments and bring the changes in a separate PR |
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)