Skip to content

Commit ca84c9c

Browse files
committed
Formatting fix for fullCL check
1 parent ddeee15 commit ca84c9c

3 files changed

Lines changed: 36 additions & 21 deletions

File tree

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#include <stdio.h>
13-
#include <stdlib.h>
12+
#include <cstdio>
13+
#include <cstdlib>
1414
#include <uv.h>
1515
#include <curl/curl.h>
1616
#include <string>

CCDB/src/CCDBDownloader.cxx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
#include <curl/curl.h>
1515
#include <unordered_map>
16-
#include <stdio.h>
17-
#include <stdlib.h>
16+
#include <cstdio>
17+
#include <cstdlib>
1818
#include <uv.h>
1919
#include <string>
2020
#include <thread>
@@ -112,7 +112,7 @@ void closeHandles(uv_handle_t* handle, void* arg)
112112

113113
void onUVClose(uv_handle_t* handle)
114114
{
115-
if (handle != NULL) {
115+
if (handle != nullptr) {
116116
delete handle;
117117
}
118118
}
@@ -188,10 +188,12 @@ void CCDBDownloader::curlPerform(uv_poll_t* handle, int status, int events)
188188
{
189189
int running_handles;
190190
int flags = 0;
191-
if (events & UV_READABLE)
191+
if (events & UV_READABLE) {
192192
flags |= CURL_CSELECT_IN;
193-
if (events & UV_WRITABLE)
193+
}
194+
if (events & UV_WRITABLE) {
194195
flags |= CURL_CSELECT_OUT;
196+
}
195197

196198
auto context = (CCDBDownloader::curl_context_t*)handle->data;
197199

@@ -214,10 +216,12 @@ int CCDBDownloader::handleSocket(CURL* easy, curl_socket_t s, int action, void*
214216
curl_context = socketp ? (CCDBDownloader::curl_context_t*)socketp : CD->createCurlContext(s);
215217
curl_multi_assign(socketData->curlm, s, (void*)curl_context);
216218

217-
if (action != CURL_POLL_IN)
219+
if (action != CURL_POLL_IN) {
218220
events |= UV_WRITABLE;
219-
if (action != CURL_POLL_OUT)
221+
}
222+
if (action != CURL_POLL_OUT) {
220223
events |= UV_READABLE;
224+
}
221225

222226
if (CD->socketTimerMap.find(s) != CD->socketTimerMap.end()) {
223227
uv_timer_stop(CD->socketTimerMap[s]);
@@ -232,7 +236,7 @@ int CCDBDownloader::handleSocket(CURL* easy, curl_socket_t s, int action, void*
232236
}
233237
uv_poll_stop(&((CCDBDownloader::curl_context_t*)socketp)->poll_handle);
234238
CD->destroyCurlContext((CCDBDownloader::curl_context_t*)socketp);
235-
curl_multi_assign(socketData->curlm, s, NULL);
239+
curl_multi_assign(socketData->curlm, s, nullptr);
236240
}
237241
break;
238242
default:
@@ -359,8 +363,9 @@ int CCDBDownloader::startTimeout(CURLM* multi, long timeout_ms, void* userp)
359363
if (timeout_ms < 0) {
360364
uv_timer_stop(timeout);
361365
} else {
362-
if (timeout_ms == 0)
366+
if (timeout_ms == 0) {
363367
timeout_ms = 1; // Calling curlTimeout when timeout = 0 could create an infinite loop
368+
}
364369
uv_timer_start(timeout, curlTimeout, timeout_ms, 0);
365370
}
366371
return 0;

CCDB/test/testCcdbApiDownloader.cxx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ BOOST_AUTO_TEST_CASE(blocking_batch_test)
9797
auto curlCodes = downloader.batchBlockingPerform(handleVector);
9898
for (CURLcode code : curlCodes) {
9999
BOOST_CHECK(code == CURLE_OK);
100-
if (code != CURLE_OK)
100+
if (code != CURLE_OK) {
101101
std::cout << "CURL Code: " << code << "\n";
102+
}
102103
}
103104

104105
for (CURL* handle : handleVector) {
105106
long httpCode;
106107
curl_easy_getinfo(handle, CURLINFO_HTTP_CODE, &httpCode);
107108
BOOST_CHECK(httpCode == 200);
108-
if (httpCode != 200)
109+
if (httpCode != 200) {
109110
std::cout << "HTTP Code: " << httpCode << "\n";
111+
}
110112
curl_easy_cleanup(handle);
111113
}
112114

@@ -134,21 +136,24 @@ BOOST_AUTO_TEST_CASE(asynch_batch_test)
134136

135137
bool flag = false;
136138
auto curlCodes = downloader.batchAsynchPerform(handleVector, &flag);
137-
while (!flag)
139+
while (!flag) {
138140
sleep(1);
141+
}
139142

140143
for (CURLcode code : (*curlCodes)) {
141144
BOOST_CHECK(code == CURLE_OK);
142-
if (code != CURLE_OK)
145+
if (code != CURLE_OK) {
143146
std::cout << "CURL Code: " << code << "\n";
147+
}
144148
}
145149

146150
for (CURL* handle : handleVector) {
147151
long httpCode;
148152
curl_easy_getinfo(handle, CURLINFO_HTTP_CODE, &httpCode);
149153
BOOST_CHECK(httpCode == 200);
150-
if (httpCode != 200)
154+
if (httpCode != 200) {
151155
std::cout << "HTTP Code: " << httpCode << "\n";
156+
}
152157
curl_easy_cleanup(handle);
153158
}
154159

@@ -191,16 +196,18 @@ BOOST_AUTO_TEST_CASE(test_with_break)
191196
auto curlCodes2 = downloader.batchBlockingPerform(handleVector2);
192197
for (CURLcode code : curlCodes2) {
193198
BOOST_CHECK(code == CURLE_OK);
194-
if (code != CURLE_OK)
199+
if (code != CURLE_OK) {
195200
std::cout << "CURL Code: " << code << "\n";
201+
}
196202
}
197203

198204
for (CURL* handle : handleVector2) {
199205
long httpCode;
200206
curl_easy_getinfo(handle, CURLINFO_HTTP_CODE, &httpCode);
201207
BOOST_CHECK(httpCode == 200);
202-
if (httpCode != 200)
208+
if (httpCode != 200) {
203209
std::cout << "HTTP Code: " << httpCode << "\n";
210+
}
204211
curl_easy_cleanup(handle);
205212
}
206213

@@ -236,23 +243,26 @@ BOOST_AUTO_TEST_CASE(asynch_batch_callback)
236243

237244
bool flag = false;
238245
auto curlCodes = downloader.asynchBatchPerformWithCallback(handleVector, &flag, testCallback, &testValue);
239-
while (!flag)
246+
while (!flag) {
240247
sleep(1);
248+
}
241249

242250
BOOST_CHECK(testValue == 46);
243251

244252
for (CURLcode code : (*curlCodes)) {
245253
BOOST_CHECK(code == CURLE_OK);
246-
if (code != CURLE_OK)
254+
if (code != CURLE_OK) {
247255
std::cout << "CURL Code: " << code << "\n";
256+
}
248257
}
249258

250259
for (CURL* handle : handleVector) {
251260
long httpCode;
252261
curl_easy_getinfo(handle, CURLINFO_HTTP_CODE, &httpCode);
253262
BOOST_CHECK(httpCode == 200);
254-
if (httpCode != 200)
263+
if (httpCode != 200) {
255264
std::cout << "HTTP Code: " << httpCode << "\n";
265+
}
256266
curl_easy_cleanup(handle);
257267
}
258268

0 commit comments

Comments
 (0)