From c3039602618972602e12f719b4f56612ee85fe0c Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 6 Mar 2023 09:11:42 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/misc/unique_instance.c | 1 - srcs/opendhcp183/query.cpp | 39 +++++++++++++++----------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/srcs/libs/misc/unique_instance.c b/srcs/libs/misc/unique_instance.c index 6ca88b8..cbaa38e 100644 --- a/srcs/libs/misc/unique_instance.c +++ b/srcs/libs/misc/unique_instance.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include "user_errno.h" #include "misc.h" diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index 69467c9..77c5c9f 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -550,30 +550,27 @@ static int delete_dhcpd_rangeset(const char **pRsp, const char *pRequest) { } } //The input parameter does not exist - do { - PHASH_MAP s; - PHASH_MAP tmp; - char saddr[128]; - char eaddr[128]; - char del_range[256]; - memset(del_range, 0, 256); + PHASH_MAP s; + PHASH_MAP tmp; + char saddr[128]; + char eaddr[128]; + char del_range[256]; + memset(del_range, 0, 256); + HASH_ITER(hh, delMap, s, tmp) HASH_ITER(hh, delMap, s, tmp) { + cJSON *pdel_Item = cJSON_CreateObject(); + IP2String(saddr, ntohl(s->key)); + IP2String(eaddr, ntohl(s->value)); - HASH_ITER(hh, delMap, s, tmp) { - cJSON *pdel_Item = cJSON_CreateObject(); - IP2String(saddr, ntohl(s->key)); - IP2String(eaddr, ntohl(s->value)); + sprintf(del_range, "%s-%s", saddr, eaddr); + cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range); - sprintf(del_range, "%s-%s", saddr, eaddr); - cJSON_AddStringToObject(pdel_Item, "dhcpRange", del_range); + cJSON_AddNumberToObject(pdel_Item, "status", ERR_ITEM_UNEXISTS); + cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_ITEM_UNEXISTS)); + cJSON_AddItemToArray(pdelArray, pdel_Item); - cJSON_AddNumberToObject(pdel_Item, "status", ERR_ITEM_UNEXISTS); - cJSON_AddStringToObject(pdel_Item, "message", getErrorEnumDesc(ERR_ITEM_UNEXISTS)); - cJSON_AddItemToArray(pdelArray, pdel_Item); - - HASH_DEL(delMap, s); - free(s); - } - } while (0); + HASH_DEL(delMap, s); + free(s); + } //Rewrite cfig.dhcpRanges for (int i = 0; i < cfig.rangeCount; i++) {