From ac39e8aac2475e5bb230a9143eb489502e0a8793 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 27 Jun 2023 09:28:35 +0200 Subject: [PATCH] [winpr,collections] ListDictionary_Count --- channels/serial/client/serial_main.c | 2 +- winpr/include/winpr/collections.h | 2 +- winpr/libwinpr/utils/collections/ListDictionary.c | 10 ++++------ winpr/libwinpr/utils/test/TestListDictionary.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 027634fb6..c8a9d9a36 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -617,7 +617,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp) if (ListDictionary_Count(serial->IrpThreads) >= MAX_IRP_THREADS) { WLog_Print(serial->log, WLOG_WARN, - "Number of IRP threads threshold reached: %d, keep on anyway", + "Number of IRP threads threshold reached: %" PRIuz ", keep on anyway", ListDictionary_Count(serial->IrpThreads)); WINPR_ASSERT(FALSE); /* unimplemented */ /* TODO: MAX_IRP_THREADS has been thought to avoid a diff --git a/winpr/include/winpr/collections.h b/winpr/include/winpr/collections.h index 45a2835a5..b37afc39a 100644 --- a/winpr/include/winpr/collections.h +++ b/winpr/include/winpr/collections.h @@ -215,7 +215,7 @@ extern "C" #define ListDictionary_KeyObject(_dictionary) (&_dictionary->objectKey) #define ListDictionary_ValueObject(_dictionary) (&_dictionary->objectValue) - WINPR_API int ListDictionary_Count(wListDictionary* listDictionary); + WINPR_API size_t ListDictionary_Count(wListDictionary* listDictionary); WINPR_API void ListDictionary_Lock(wListDictionary* listDictionary); WINPR_API void ListDictionary_Unlock(wListDictionary* listDictionary); diff --git a/winpr/libwinpr/utils/collections/ListDictionary.c b/winpr/libwinpr/utils/collections/ListDictionary.c index 763903937..719331e02 100644 --- a/winpr/libwinpr/utils/collections/ListDictionary.c +++ b/winpr/libwinpr/utils/collections/ListDictionary.c @@ -38,20 +38,18 @@ * Gets the number of key/value pairs contained in the ListDictionary. */ -int ListDictionary_Count(wListDictionary* listDictionary) +size_t ListDictionary_Count(wListDictionary* listDictionary) { - int count = 0; - wListDictionaryItem* item; + size_t count = 0; - if (!listDictionary) - return -1; + WINPR_ASSERT(listDictionary); if (listDictionary->synchronized) EnterCriticalSection(&listDictionary->lock); if (listDictionary->head) { - item = listDictionary->head; + wListDictionaryItem* item = listDictionary->head; while (item) { diff --git a/winpr/libwinpr/utils/test/TestListDictionary.c b/winpr/libwinpr/utils/test/TestListDictionary.c index 89815d20f..fd9e842f2 100644 --- a/winpr/libwinpr/utils/test/TestListDictionary.c +++ b/winpr/libwinpr/utils/test/TestListDictionary.c @@ -13,7 +13,7 @@ static char* val3 = "val3"; int TestListDictionary(int argc, char* argv[]) { - int count; + size_t count; char* value; wListDictionary* list;