From 0b4401a4fb363f611353a83aee209ba24d1f3a0f Mon Sep 17 00:00:00 2001 From: MonkeybreadSoftware Date: Wed, 17 Apr 2024 10:27:42 +0200 Subject: [PATCH] lib: silence warnings on comma misuse Building curl with -Wcomma, I see warnings about "possible misuse of comma operator here" and moving fields assignment out of the for() fixes it. Closes #13392 --- lib/cookie.c | 3 ++- lib/ldap.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cookie.c b/lib/cookie.c index c1ed2913c4..837caaab38 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -886,7 +886,8 @@ Curl_cookie_add(struct Curl_easy *data, * Now loop through the fields and init the struct we already have * allocated */ - for(ptr = firstptr, fields = 0; ptr && !badcookie; + fields = 0; + for(ptr = firstptr; ptr && !badcookie; ptr = strtok_r(NULL, "\t", &tok_buf), fields++) { switch(fields) { case 0: diff --git a/lib/ldap.c b/lib/ldap.c index e2546aa59e..a545f87d9d 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -546,7 +546,8 @@ static CURLcode ldap_do(struct Curl_easy *data, bool *done) goto quit; } - for(num = 0, entryIterator = ldap_first_entry(server, ldapmsg); + num = 0; + for(entryIterator = ldap_first_entry(server, ldapmsg); entryIterator; entryIterator = ldap_next_entry(server, entryIterator), num++) { BerElement *ber = NULL;