Skip to content

Commit 15d9a9b

Browse files
authored
Merge pull request #81 from DMTF/CompilerWarnings
Remove compiler warnings even on -pedantic
2 parents 97d4200 + 5b8e2d6 commit 15d9a9b

File tree

8 files changed

+90
-86
lines changed

8 files changed

+90
-86
lines changed

examples/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void printRedfishEvent(redfishPayload* event, enumeratorAuthentication* auth, co
213213

214214
(void)context;
215215

216-
printf("%s: Called!\n", __FUNCTION__);
216+
printf("%s: Called!\n", __func__);
217217
if(auth == NULL)
218218
{
219219
printf("No authentication provided\n");

examples/testAsync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void printRedfishEvent(redfishPayload* event, enumeratorAuthentication* auth, co
185185

186186
(void)context;
187187

188-
printf("%s: Called!\n", __FUNCTION__);
188+
printf("%s: Called!\n", __func__);
189189
if(auth == NULL)
190190
{
191191
printf("No authentication provided\n");

src/asyncEvent.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void terminateAsyncEventThread(redfishService* service)
119119
addTerminationToQueue(service);
120120
if(service->eventThread == getThreadId())
121121
{
122-
REDFISH_DEBUG_INFO_PRINT("%s: Event thread self cleanup...\n", __FUNCTION__);
122+
REDFISH_DEBUG_INFO_PRINT("%s: Event thread self cleanup...\n", __func__);
123123
#ifndef _MSC_VER
124124
//Need to set this thread detached and make it clean itself up
125125
pthread_detach(pthread_self());
@@ -240,7 +240,7 @@ static threadRet WINAPI eventActorTask(void* args)
240240
switch(wi->type)
241241
{
242242
default:
243-
REDFISH_DEBUG_ERR_PRINT("%s: Unknown work item type %d!\n", __FUNCTION__, wi->type);
243+
REDFISH_DEBUG_ERR_PRINT("%s: Unknown work item type %d!\n", __func__, wi->type);
244244
case WorkItemTermination:
245245
term = true;
246246
break;
@@ -249,7 +249,7 @@ static threadRet WINAPI eventActorTask(void* args)
249249
wi->registration = NULL;//This is cleaned up, or not as appropirate in the prior call...
250250
break;
251251
case WorkItemEvent:
252-
REDFISH_DEBUG_ERR_PRINT("%s: Got new event %p (registrations = %p)\n", __FUNCTION__, wi->event, registrations);
252+
REDFISH_DEBUG_ERR_PRINT("%s: Got new event %p (registrations = %p)\n", __func__, wi->event, registrations);
253253
current = registrations;
254254
while(current)
255255
{
@@ -268,7 +268,7 @@ static threadRet WINAPI eventActorTask(void* args)
268268
break;
269269
}
270270
}
271-
REDFISH_DEBUG_WARNING_PRINT("%s: Exiting...\n", __FUNCTION__);
271+
REDFISH_DEBUG_WARNING_PRINT("%s: Exiting...\n", __func__);
272272
current = registrations;
273273
while(current)
274274
{
@@ -358,7 +358,11 @@ static threadRet WINAPI sseThread(void* args)
358358
curl_easy_setopt(curl, CURLOPT_URL, uri);
359359
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
360360
res = curl_easy_perform(curl);
361-
REDFISH_DEBUG_ERR_PRINT("%s: Thread is done %d\n", __FUNCTION__, res);
361+
if(res != CURLE_OK)
362+
{
363+
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __func__, res);
364+
}
365+
REDFISH_DEBUG_ERR_PRINT("%s: Thread is done\n", __func__);
362366
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
363367
curl_slist_free_all(headers);
364368
if(httpCode > 400)
@@ -466,7 +470,7 @@ static threadRet WINAPI tcpThread(void* args)
466470
if(SSL_accept(ssl) <= 0)
467471
{
468472
err = ERR_get_error();
469-
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete TLS handshake %u %s\n", __FUNCTION__, err, ERR_error_string(err, NULL));
473+
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete TLS handshake %u %s\n", __func__, err, ERR_error_string(err, NULL));
470474
SSL_free(ssl);
471475
close(tmpSock);
472476
continue;
@@ -478,11 +482,11 @@ static threadRet WINAPI tcpThread(void* args)
478482
while((unsigned int)buffPos < sizeof(buffer)-1)
479483
{
480484
readCount = SSL_read(ssl, buffer+buffPos, 2047-buffPos);
481-
//REDFISH_DEBUG_INFO_PRINT("%s: SSL_read returned %d bytes\n", __FUNCTION__, readCount);
482-
//REDFISH_DEBUG_INFO_PRINT("%s: Current Buffer is %s\n", __FUNCTION__, buffer);
485+
//REDFISH_DEBUG_INFO_PRINT("%s: SSL_read returned %d bytes\n", __func__, readCount);
486+
//REDFISH_DEBUG_INFO_PRINT("%s: Current Buffer is %s\n", __func__, buffer);
483487
if(readCount < 0)
484488
{
485-
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete SSL read %u %s\n", __FUNCTION__, err, ERR_error_string(err, NULL));
489+
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete SSL read %u %s\n", __func__, err, ERR_error_string(err, NULL));
486490
SSL_free(ssl);
487491
close(tmpSock);
488492
tmpSock = -1;
@@ -799,7 +803,7 @@ static size_t getRedfishEventInfoFromRawHttp(const char* buffer, redfishService*
799803
const char* bodyStart;
800804
redfishPayload* payload;
801805

802-
//REDFISH_DEBUG_DEBUG_PRINT("%s: Got Payload: %s\n", __FUNCTION__, buffer);
806+
//REDFISH_DEBUG_DEBUG_PRINT("%s: Got Payload: %s\n", __func__, buffer);
803807

804808
if(strncmp(buffer, "POST", 4) != 0)
805809
{
@@ -925,7 +929,7 @@ static SSL_CTX* createSSLContext()
925929
ctx = SSL_CTX_new(method);
926930
if(!ctx)
927931
{
928-
REDFISH_DEBUG_ERR_PRINT("%s: Unable to create SSL context\n", __FUNCTION__);
932+
REDFISH_DEBUG_ERR_PRINT("%s: Unable to create SSL context\n", __func__);
929933
return NULL;
930934
}
931935
SSL_CTX_set_ecdh_auto(ctx, 1);

src/asyncRaw.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ asyncHttpRequest* createRequest(const char* url, httpMethod method, size_t bodys
4242

4343
void addRequestHeader(asyncHttpRequest* request, const char* name, const char* value)
4444
{
45-
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __FUNCTION__, name, value, request->headers);
45+
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __func__, name, value, request->headers);
4646
addHeader(&request->headers, name, value);
4747
}
4848

@@ -134,7 +134,7 @@ void terminateAsyncThread(redfishService* service)
134134
queuePush(service->queue, workItem);
135135
if(service->asyncThread == getThreadId())
136136
{
137-
REDFISH_DEBUG_INFO_PRINT("%s: Async thread self cleanup...\n", __FUNCTION__);
137+
REDFISH_DEBUG_INFO_PRINT("%s: Async thread self cleanup...\n", __func__);
138138
#ifndef _MSC_VER
139139
//Need to set this thread detached and make it clean itself up
140140
pthread_detach(pthread_self());
@@ -143,7 +143,7 @@ void terminateAsyncThread(redfishService* service)
143143
}
144144
else
145145
{
146-
REDFISH_DEBUG_INFO_PRINT("%s: Async thread other thread cleanup...\n", __FUNCTION__);
146+
REDFISH_DEBUG_INFO_PRINT("%s: Async thread other thread cleanup...\n", __func__);
147147
#ifdef _MSC_VER
148148
WaitForSingleObject(service->asyncThread, INFINITE);
149149
#else
@@ -355,7 +355,7 @@ threadRet rawAsyncWorkThread(void* data)
355355
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirect);
356356
if(redirect)
357357
{
358-
REDFISH_DEBUG_INFO_PRINT("%s: Redirect from %s to %s\n", __FUNCTION__, workItem->request->url, redirect);
358+
REDFISH_DEBUG_INFO_PRINT("%s: Redirect from %s to %s\n", __func__, workItem->request->url, redirect);
359359
if(response)
360360
{
361361
safeFree(readChunk.memory);
@@ -379,7 +379,7 @@ threadRet rawAsyncWorkThread(void* data)
379379
{
380380
if(res != CURLE_OK)
381381
{
382-
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __FUNCTION__, res);
382+
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __func__, res);
383383
response->connectError = 1;
384384
response->httpResponseCode = 0xFFFF;
385385
response->body = NULL;
@@ -397,7 +397,7 @@ threadRet rawAsyncWorkThread(void* data)
397397

398398
response->connectError = 0;
399399
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->httpResponseCode);
400-
REDFISH_DEBUG_NOTICE_PRINT("%s: Got response for url %s with code %ld\n", __FUNCTION__, workItem->request->url, response->httpResponseCode);
400+
REDFISH_DEBUG_NOTICE_PRINT("%s: Got response for url %s with code %ld\n", __func__, workItem->request->url, response->httpResponseCode);
401401
response->body = readChunk.memory;
402402
response->bodySize = readChunk.size;
403403
}
@@ -438,7 +438,7 @@ static void freeHeaders(httpHeader* headers)
438438
{
439439
httpHeader* node;
440440
httpHeader* tmp;
441-
REDFISH_DEBUG_NOTICE_PRINT("%s: Freeing %p\n", __FUNCTION__, headers);
441+
REDFISH_DEBUG_NOTICE_PRINT("%s: Freeing %p\n", __func__, headers);
442442
if(headers)
443443
{
444444
node = headers;
@@ -516,7 +516,7 @@ static size_t asyncHeaderCallback(char* buffer, size_t size, size_t nitems, void
516516
//Replace \r\n with NULL terminator...
517517
save[0] = 0;
518518
}
519-
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __FUNCTION__, name, value, response->headers);
519+
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __func__, name, value, response->headers);
520520
addHeader(&(response->headers), name, value);
521521
free(tmp);
522522

src/entities/resource.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ static redfishHealth _getResourceHealth(redfishPayload* payload, const char* sub
1717

1818
redfishHealth getResourceHealth(redfishPayload* payload)
1919
{
20-
return _getResourceHealth(payload, "Health", __FUNCTION__);
20+
return _getResourceHealth(payload, "Health", __func__);
2121
}
2222

2323
redfishHealth getResourceRollupHealth(redfishPayload* payload)
2424
{
25-
return _getResourceHealth(payload, "HealthRollup", __FUNCTION__);
25+
return _getResourceHealth(payload, "HealthRollup", __func__);
2626
}
2727

2828
/** A struct to help map the string enum values produced by a redfish service to more C friendly enum values **/
@@ -57,20 +57,20 @@ redfishState getResourceState(redfishPayload* payload)
5757

5858
if(payload == NULL)
5959
{
60-
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __FUNCTION__);
60+
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __func__);
6161
return RedfishStateError;
6262
}
6363
status = getPayloadByNodeNameNoNetwork(payload, "Status");
6464
if(status == NULL)
6565
{
66-
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Status resource from payload...\n", __FUNCTION__);
66+
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Status resource from payload...\n", __func__);
6767
return RedfishStateError;
6868
}
6969
state = getPayloadByNodeNameNoNetwork(status, "State");
7070
cleanupPayload(status);
7171
if(state == NULL)
7272
{
73-
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain State resource from payload...\n", __FUNCTION__);
73+
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain State resource from payload...\n", __func__);
7474
return RedfishStateError;
7575
}
7676
stateStr = getPayloadStringValue(state);
@@ -87,7 +87,7 @@ redfishState getResourceState(redfishPayload* payload)
8787
return stateMapping[i].state;
8888
}
8989
}
90-
REDFISH_DEBUG_WARNING_PRINT("%s: Got unknown state string %s...\n", __FUNCTION__, stateStr);
90+
REDFISH_DEBUG_WARNING_PRINT("%s: Got unknown state string %s...\n", __func__, stateStr);
9191
free(stateStr);
9292
return RedfishStateUnknown;
9393
}
@@ -99,13 +99,13 @@ char* getResourceName(redfishPayload* payload)
9999

100100
if(payload == NULL)
101101
{
102-
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __FUNCTION__);
102+
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __func__);
103103
return NULL;
104104
}
105105
name = getPayloadByNodeNameNoNetwork(payload, "Name");
106106
if(name == NULL)
107107
{
108-
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Name resource from payload...\n", __FUNCTION__);
108+
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Name resource from payload...\n", __func__);
109109
return NULL;
110110
}
111111
ret = getPayloadStringValue(name);

src/payload.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ redfishPayload* createRedfishPayloadFromString(const char* value, redfishService
4242
json_t* jValue = json_loads(value, 0, &err);
4343
if(jValue == NULL)
4444
{
45-
REDFISH_DEBUG_ERR_PRINT("%s: Unable to parse json! %s %s\n", __FUNCTION__, err.text);
45+
REDFISH_DEBUG_ERR_PRINT("%s: Unable to parse json! %s %s\n", __func__, err.text);
4646
return NULL;
4747
}
4848
return createRedfishPayload(jValue, service);
@@ -56,7 +56,7 @@ redfishPayload* createRedfishPayloadFromString(const char* value, redfishService
5656
redfishPayload* createRedfishPayloadFromContent(const char* content, size_t contentLength, const char* contentType, redfishService* service)
5757
{
5858
redfishPayload* ret;
59-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. content = %p, contentLength = %lu, contentType = %s, service = %p\n", __FUNCTION__, content, contentLength, contentType, service);
59+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. content = %p, contentLength = %lu, contentType = %s, service = %p\n", __func__, content, contentLength, contentType, service);
6060
if(contentType == NULL || strncasecmp(contentType, "application/json", 16) == 0)
6161
{
6262
return createRedfishPayloadFromString(content, service);
@@ -89,7 +89,7 @@ redfishPayload* createRedfishPayloadFromContent(const char* content, size_t cont
8989
redfishPayload* copyRedfishPayload(const redfishPayload* original)
9090
{
9191
redfishPayload* ret;
92-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. original = %p\n", __FUNCTION__, original);
92+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. original = %p\n", __func__, original);
9393

9494
if(original == NULL)
9595
{
@@ -722,7 +722,7 @@ bool getPayloadByNodeNameAsync(redfishPayload* payload, const char* nodeName, re
722722
}
723723
if(value == NULL)
724724
{
725-
REDFISH_DEBUG_ERR_PRINT("%s: Payload contains no element named %s\n", __FUNCTION__, nodeName);
725+
REDFISH_DEBUG_ERR_PRINT("%s: Payload contains no element named %s\n", __func__, nodeName);
726726
return false;
727727
}
728728
}
@@ -809,7 +809,7 @@ void gotNextRedPath(bool success, unsigned short httpCode, redfishPayload* paylo
809809
redpathAsyncContext* myContext = (redpathAsyncContext*)context;
810810
bool ret;
811811

812-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __FUNCTION__, success, httpCode, payload, context);
812+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __func__, success, httpCode, payload, context);
813813

814814
if(success == false || httpCode >= 400 || myContext->redpath->next == NULL)
815815
{
@@ -839,7 +839,7 @@ bool getPayloadForPathAsync(redfishPayload* payload, redPathNode* redpath, redfi
839839
redpathAsyncContext* myContext;
840840
bool ret;
841841

842-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, redpath = %p\n", __FUNCTION__, payload, redpath);
842+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, redpath = %p\n", __func__, payload, redpath);
843843

844844
if(!payload || !redpath)
845845
{
@@ -1001,11 +1001,11 @@ static bool getSimpleOpResult(json_t* json, const char* propName, RedPathOp op,
10011001
long long intVal, intPropVal;
10021002
bool ret;
10031003

1004-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. json = %p, propName = %s, op = %u, value = %s\n", __FUNCTION__, json, propName, op, value);
1004+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. json = %p, propName = %s, op = %u, value = %s\n", __func__, json, propName, op, value);
10051005

10061006
if(json == NULL)
10071007
{
1008-
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. Null JSON\n", __FUNCTION__);
1008+
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. Null JSON\n", __func__);
10091009
return false;
10101010
}
10111011

@@ -1045,7 +1045,7 @@ static bool getSimpleOpResult(json_t* json, const char* propName, RedPathOp op,
10451045
ret = false;
10461046
break;
10471047
}
1048-
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. %u\n", __FUNCTION__, ret);
1048+
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. %u\n", __func__, ret);
10491049
return ret;
10501050
}
10511051

@@ -1112,7 +1112,7 @@ static void opGotPayloadByNodeNameAsync(bool success, unsigned short httpCode, r
11121112
redpathAsyncOpContext* myContext = (redpathAsyncOpContext*)context;
11131113
bool ret = false;
11141114

1115-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __FUNCTION__, success, httpCode, payload, context);
1115+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __func__, success, httpCode, payload, context);
11161116

11171117
if(success == false || httpCode >= 400 || payload == NULL)
11181118
{
@@ -1142,7 +1142,7 @@ static bool getOpResultAsync(redfishPayload* payload, const char* propName, RedP
11421142
bool ret;
11431143
redpathAsyncOpContext* myContext;
11441144

1145-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __FUNCTION__, payload, propName, value, context);
1145+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __func__, payload, propName, value, context);
11461146

11471147
if(isPayloadCollection(payload))
11481148
{
@@ -1266,7 +1266,7 @@ static void opGotResultAsync(bool success, unsigned short httpCode, redfishPaylo
12661266
{
12671267
redpathAsyncOpContext* myContext = (redpathAsyncOpContext*)context;
12681268

1269-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __FUNCTION__, success, httpCode, payload, context);
1269+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __func__, success, httpCode, payload, context);
12701270

12711271
if(success == true && httpCode < 300 && payload != NULL)
12721272
{
@@ -1289,7 +1289,7 @@ static void opGotPayloadByIndexAsync(bool success, unsigned short httpCode, redf
12891289
redpathAsyncOpContext* myContext = (redpathAsyncOpContext*)context;
12901290
bool ret;
12911291

1292-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __FUNCTION__, success, httpCode, payload, context);
1292+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. success = %u, httpCode = %u, payload = %p, context = %p\n", __func__, success, httpCode, payload, context);
12931293

12941294
if(success == true && httpCode < 300 && payload != NULL)
12951295
{
@@ -1320,9 +1320,9 @@ static bool collectionEvalOpAsync(redfishPayload* payload, const char* propName,
13201320
redfishPayload* members;
13211321
redfishPayload* tmp;
13221322

1323-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __FUNCTION__, payload, propName, value, context);
1323+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __func__, payload, propName, value, context);
13241324

1325-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __FUNCTION__, payload, propName, value, context);
1325+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __func__, payload, propName, value, context);
13261326

13271327
max = getCollectionSize(payload);
13281328
if(max == 0)
@@ -1463,7 +1463,7 @@ static bool arrayEvalOpAsync(redfishPayload* payload, const char* propName, RedP
14631463
redpathAsyncOpContext* myContext;
14641464
redfishPayload* tmp;
14651465

1466-
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __FUNCTION__, payload, propName, value, context);
1466+
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. payload = %p, propName = %s, value = %s, context = %p\n", __func__, payload, propName, value, context);
14671467

14681468
max = json_array_size(payload->json);
14691469
if(max == 0)

0 commit comments

Comments
 (0)