INI_FIND_ITEM just break instead of return

storage_pool
YuQing 2020-12-29 16:21:00 +08:00
parent 89c68e11db
commit 7d5a540a2f
2 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,7 @@
Version 1.46 2020-12-28 Version 1.46 2020-12-29
* add function get_time_item_from_conf_ex * add function get_time_item_from_conf_ex
* INI_FIND_ITEM just break instead of return
Version 1.45 2020-12-24 Version 1.45 2020-12-24
* add function uniq_skiplist_find_node_ex * add function uniq_skiplist_find_node_ex

View File

@ -2781,8 +2781,8 @@ void iniFreeContext(IniContext *pContext)
iniFreeDynamicContent(pContext); iniFreeDynamicContent(pContext);
} }
#define INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, \ #define INI_FIND_ITEM(szSectionName, szItemName, \
targetItem, pItem, return_val) \ pContext, pSection, targetItem, pItem) \
do { \ do { \
if (szSectionName == NULL || *szSectionName == '\0') \ if (szSectionName == NULL || *szSectionName == '\0') \
{ \ { \
@ -2794,13 +2794,15 @@ do { \
szSectionName, strlen(szSectionName)); \ szSectionName, strlen(szSectionName)); \
if (pSection == NULL) \ if (pSection == NULL) \
{ \ { \
return return_val; \ pItem = NULL; \
break; \
} \ } \
} \ } \
\ \
if (pSection->count <= 0) \ if (pSection->count <= 0) \
{ \ { \
return return_val; \ pItem = NULL; \
break; \
} \ } \
\ \
snprintf(targetItem.name, sizeof(targetItem.name), "%s", szItemName); \ snprintf(targetItem.name, sizeof(targetItem.name), "%s", szItemName); \
@ -2818,15 +2820,15 @@ char *iniGetStrValueEx(const char *szSectionName, const char *szItemName,
IniItem *pItem; IniItem *pItem;
IniItem *pItemEnd; IniItem *pItemEnd;
INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, INI_FIND_ITEM(szSectionName, szItemName, pContext,
targetItem, pFound, NULL); pSection, targetItem, pFound);
if (pFound == NULL) if (pFound == NULL)
{ {
if (RETRY_FETCH_GLOBAL(szSectionName, bRetryGlobal)) if (RETRY_FETCH_GLOBAL(szSectionName, bRetryGlobal))
{ {
szSectionName = NULL; szSectionName = NULL;
INI_FIND_ITEM(szSectionName, szItemName, pContext, INI_FIND_ITEM(szSectionName, szItemName, pContext,
pSection, targetItem, pFound, NULL); pSection, targetItem, pFound);
if (pFound == NULL) if (pFound == NULL)
{ {
return NULL; return NULL;
@ -3060,7 +3062,7 @@ int iniGetValues(const char *szSectionName, const char *szItemName, \
return count; return count;
} }
IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, \ IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName,
IniContext *pContext, int *nTargetCount) IniContext *pContext, int *nTargetCount)
{ {
IniItem targetItem; IniItem targetItem;
@ -3071,8 +3073,8 @@ IniItem *iniGetValuesEx(const char *szSectionName, const char *szItemName, \
IniItem *pItemStart; IniItem *pItemStart;
*nTargetCount = 0; *nTargetCount = 0;
INI_FIND_ITEM(szSectionName, szItemName, pContext, pSection, \ INI_FIND_ITEM(szSectionName, szItemName, pContext,
targetItem, pFound, NULL); pSection, targetItem, pFound);
if (pFound == NULL) if (pFound == NULL)
{ {
return NULL; return NULL;