Skip to content

Commit

Permalink
Merge pull request #81 from DMTF/CompilerWarnings
Browse files Browse the repository at this point in the history
Remove compiler warnings even on -pedantic
  • Loading branch information
mraineri authored Feb 14, 2019
2 parents 97d4200 + 5b8e2d6 commit 15d9a9b
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 86 deletions.
2 changes: 1 addition & 1 deletion examples/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void printRedfishEvent(redfishPayload* event, enumeratorAuthentication* auth, co

(void)context;

printf("%s: Called!\n", __FUNCTION__);
printf("%s: Called!\n", __func__);
if(auth == NULL)
{
printf("No authentication provided\n");
Expand Down
2 changes: 1 addition & 1 deletion examples/testAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void printRedfishEvent(redfishPayload* event, enumeratorAuthentication* auth, co

(void)context;

printf("%s: Called!\n", __FUNCTION__);
printf("%s: Called!\n", __func__);
if(auth == NULL)
{
printf("No authentication provided\n");
Expand Down
26 changes: 15 additions & 11 deletions src/asyncEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void terminateAsyncEventThread(redfishService* service)
addTerminationToQueue(service);
if(service->eventThread == getThreadId())
{
REDFISH_DEBUG_INFO_PRINT("%s: Event thread self cleanup...\n", __FUNCTION__);
REDFISH_DEBUG_INFO_PRINT("%s: Event thread self cleanup...\n", __func__);
#ifndef _MSC_VER
//Need to set this thread detached and make it clean itself up
pthread_detach(pthread_self());
Expand Down Expand Up @@ -240,7 +240,7 @@ static threadRet WINAPI eventActorTask(void* args)
switch(wi->type)
{
default:
REDFISH_DEBUG_ERR_PRINT("%s: Unknown work item type %d!\n", __FUNCTION__, wi->type);
REDFISH_DEBUG_ERR_PRINT("%s: Unknown work item type %d!\n", __func__, wi->type);
case WorkItemTermination:
term = true;
break;
Expand All @@ -249,7 +249,7 @@ static threadRet WINAPI eventActorTask(void* args)
wi->registration = NULL;//This is cleaned up, or not as appropirate in the prior call...
break;
case WorkItemEvent:
REDFISH_DEBUG_ERR_PRINT("%s: Got new event %p (registrations = %p)\n", __FUNCTION__, wi->event, registrations);
REDFISH_DEBUG_ERR_PRINT("%s: Got new event %p (registrations = %p)\n", __func__, wi->event, registrations);
current = registrations;
while(current)
{
Expand All @@ -268,7 +268,7 @@ static threadRet WINAPI eventActorTask(void* args)
break;
}
}
REDFISH_DEBUG_WARNING_PRINT("%s: Exiting...\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Exiting...\n", __func__);
current = registrations;
while(current)
{
Expand Down Expand Up @@ -358,7 +358,11 @@ static threadRet WINAPI sseThread(void* args)
curl_easy_setopt(curl, CURLOPT_URL, uri);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
REDFISH_DEBUG_ERR_PRINT("%s: Thread is done %d\n", __FUNCTION__, res);
if(res != CURLE_OK)
{
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __func__, res);
}
REDFISH_DEBUG_ERR_PRINT("%s: Thread is done\n", __func__);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_slist_free_all(headers);
if(httpCode > 400)
Expand Down Expand Up @@ -466,7 +470,7 @@ static threadRet WINAPI tcpThread(void* args)
if(SSL_accept(ssl) <= 0)
{
err = ERR_get_error();
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete TLS handshake %u %s\n", __FUNCTION__, err, ERR_error_string(err, NULL));
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete TLS handshake %u %s\n", __func__, err, ERR_error_string(err, NULL));
SSL_free(ssl);
close(tmpSock);
continue;
Expand All @@ -478,11 +482,11 @@ static threadRet WINAPI tcpThread(void* args)
while((unsigned int)buffPos < sizeof(buffer)-1)
{
readCount = SSL_read(ssl, buffer+buffPos, 2047-buffPos);
//REDFISH_DEBUG_INFO_PRINT("%s: SSL_read returned %d bytes\n", __FUNCTION__, readCount);
//REDFISH_DEBUG_INFO_PRINT("%s: Current Buffer is %s\n", __FUNCTION__, buffer);
//REDFISH_DEBUG_INFO_PRINT("%s: SSL_read returned %d bytes\n", __func__, readCount);
//REDFISH_DEBUG_INFO_PRINT("%s: Current Buffer is %s\n", __func__, buffer);
if(readCount < 0)
{
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete SSL read %u %s\n", __FUNCTION__, err, ERR_error_string(err, NULL));
REDFISH_DEBUG_ERR_PRINT("%s: Unable to complete SSL read %u %s\n", __func__, err, ERR_error_string(err, NULL));
SSL_free(ssl);
close(tmpSock);
tmpSock = -1;
Expand Down Expand Up @@ -799,7 +803,7 @@ static size_t getRedfishEventInfoFromRawHttp(const char* buffer, redfishService*
const char* bodyStart;
redfishPayload* payload;

//REDFISH_DEBUG_DEBUG_PRINT("%s: Got Payload: %s\n", __FUNCTION__, buffer);
//REDFISH_DEBUG_DEBUG_PRINT("%s: Got Payload: %s\n", __func__, buffer);

if(strncmp(buffer, "POST", 4) != 0)
{
Expand Down Expand Up @@ -925,7 +929,7 @@ static SSL_CTX* createSSLContext()
ctx = SSL_CTX_new(method);
if(!ctx)
{
REDFISH_DEBUG_ERR_PRINT("%s: Unable to create SSL context\n", __FUNCTION__);
REDFISH_DEBUG_ERR_PRINT("%s: Unable to create SSL context\n", __func__);
return NULL;
}
SSL_CTX_set_ecdh_auto(ctx, 1);
Expand Down
16 changes: 8 additions & 8 deletions src/asyncRaw.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ asyncHttpRequest* createRequest(const char* url, httpMethod method, size_t bodys

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

Expand Down Expand Up @@ -134,7 +134,7 @@ void terminateAsyncThread(redfishService* service)
queuePush(service->queue, workItem);
if(service->asyncThread == getThreadId())
{
REDFISH_DEBUG_INFO_PRINT("%s: Async thread self cleanup...\n", __FUNCTION__);
REDFISH_DEBUG_INFO_PRINT("%s: Async thread self cleanup...\n", __func__);
#ifndef _MSC_VER
//Need to set this thread detached and make it clean itself up
pthread_detach(pthread_self());
Expand All @@ -143,7 +143,7 @@ void terminateAsyncThread(redfishService* service)
}
else
{
REDFISH_DEBUG_INFO_PRINT("%s: Async thread other thread cleanup...\n", __FUNCTION__);
REDFISH_DEBUG_INFO_PRINT("%s: Async thread other thread cleanup...\n", __func__);
#ifdef _MSC_VER
WaitForSingleObject(service->asyncThread, INFINITE);
#else
Expand Down Expand Up @@ -355,7 +355,7 @@ threadRet rawAsyncWorkThread(void* data)
curl_easy_getinfo(curl, CURLINFO_REDIRECT_URL, &redirect);
if(redirect)
{
REDFISH_DEBUG_INFO_PRINT("%s: Redirect from %s to %s\n", __FUNCTION__, workItem->request->url, redirect);
REDFISH_DEBUG_INFO_PRINT("%s: Redirect from %s to %s\n", __func__, workItem->request->url, redirect);
if(response)
{
safeFree(readChunk.memory);
Expand All @@ -379,7 +379,7 @@ threadRet rawAsyncWorkThread(void* data)
{
if(res != CURLE_OK)
{
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __FUNCTION__, res);
REDFISH_DEBUG_ERR_PRINT("%s: CURL returned %d\n", __func__, res);
response->connectError = 1;
response->httpResponseCode = 0xFFFF;
response->body = NULL;
Expand All @@ -397,7 +397,7 @@ threadRet rawAsyncWorkThread(void* data)

response->connectError = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response->httpResponseCode);
REDFISH_DEBUG_NOTICE_PRINT("%s: Got response for url %s with code %ld\n", __FUNCTION__, workItem->request->url, response->httpResponseCode);
REDFISH_DEBUG_NOTICE_PRINT("%s: Got response for url %s with code %ld\n", __func__, workItem->request->url, response->httpResponseCode);
response->body = readChunk.memory;
response->bodySize = readChunk.size;
}
Expand Down Expand Up @@ -438,7 +438,7 @@ static void freeHeaders(httpHeader* headers)
{
httpHeader* node;
httpHeader* tmp;
REDFISH_DEBUG_NOTICE_PRINT("%s: Freeing %p\n", __FUNCTION__, headers);
REDFISH_DEBUG_NOTICE_PRINT("%s: Freeing %p\n", __func__, headers);
if(headers)
{
node = headers;
Expand Down Expand Up @@ -516,7 +516,7 @@ static size_t asyncHeaderCallback(char* buffer, size_t size, size_t nitems, void
//Replace \r\n with NULL terminator...
save[0] = 0;
}
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __FUNCTION__, name, value, response->headers);
REDFISH_DEBUG_NOTICE_PRINT("%s: Adding %s => %s to %p\n", __func__, name, value, response->headers);
addHeader(&(response->headers), name, value);
free(tmp);

Expand Down
16 changes: 8 additions & 8 deletions src/entities/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ static redfishHealth _getResourceHealth(redfishPayload* payload, const char* sub

redfishHealth getResourceHealth(redfishPayload* payload)
{
return _getResourceHealth(payload, "Health", __FUNCTION__);
return _getResourceHealth(payload, "Health", __func__);
}

redfishHealth getResourceRollupHealth(redfishPayload* payload)
{
return _getResourceHealth(payload, "HealthRollup", __FUNCTION__);
return _getResourceHealth(payload, "HealthRollup", __func__);
}

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

if(payload == NULL)
{
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __func__);
return RedfishStateError;
}
status = getPayloadByNodeNameNoNetwork(payload, "Status");
if(status == NULL)
{
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Status resource from payload...\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Status resource from payload...\n", __func__);
return RedfishStateError;
}
state = getPayloadByNodeNameNoNetwork(status, "State");
cleanupPayload(status);
if(state == NULL)
{
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain State resource from payload...\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain State resource from payload...\n", __func__);
return RedfishStateError;
}
stateStr = getPayloadStringValue(state);
Expand All @@ -87,7 +87,7 @@ redfishState getResourceState(redfishPayload* payload)
return stateMapping[i].state;
}
}
REDFISH_DEBUG_WARNING_PRINT("%s: Got unknown state string %s...\n", __FUNCTION__, stateStr);
REDFISH_DEBUG_WARNING_PRINT("%s: Got unknown state string %s...\n", __func__, stateStr);
free(stateStr);
return RedfishStateUnknown;
}
Expand All @@ -99,13 +99,13 @@ char* getResourceName(redfishPayload* payload)

if(payload == NULL)
{
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Payload is NULL\n", __func__);
return NULL;
}
name = getPayloadByNodeNameNoNetwork(payload, "Name");
if(name == NULL)
{
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Name resource from payload...\n", __FUNCTION__);
REDFISH_DEBUG_WARNING_PRINT("%s: Unable to obtain Name resource from payload...\n", __func__);
return NULL;
}
ret = getPayloadStringValue(name);
Expand Down
32 changes: 16 additions & 16 deletions src/payload.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ redfishPayload* createRedfishPayloadFromString(const char* value, redfishService
json_t* jValue = json_loads(value, 0, &err);
if(jValue == NULL)
{
REDFISH_DEBUG_ERR_PRINT("%s: Unable to parse json! %s %s\n", __FUNCTION__, err.text);
REDFISH_DEBUG_ERR_PRINT("%s: Unable to parse json! %s %s\n", __func__, err.text);
return NULL;
}
return createRedfishPayload(jValue, service);
Expand All @@ -56,7 +56,7 @@ redfishPayload* createRedfishPayloadFromString(const char* value, redfishService
redfishPayload* createRedfishPayloadFromContent(const char* content, size_t contentLength, const char* contentType, redfishService* service)
{
redfishPayload* ret;
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. content = %p, contentLength = %lu, contentType = %s, service = %p\n", __FUNCTION__, content, contentLength, contentType, service);
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. content = %p, contentLength = %lu, contentType = %s, service = %p\n", __func__, content, contentLength, contentType, service);
if(contentType == NULL || strncasecmp(contentType, "application/json", 16) == 0)
{
return createRedfishPayloadFromString(content, service);
Expand Down Expand Up @@ -89,7 +89,7 @@ redfishPayload* createRedfishPayloadFromContent(const char* content, size_t cont
redfishPayload* copyRedfishPayload(const redfishPayload* original)
{
redfishPayload* ret;
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. original = %p\n", __FUNCTION__, original);
REDFISH_DEBUG_DEBUG_PRINT("%s: Entered. original = %p\n", __func__, original);

if(original == NULL)
{
Expand Down Expand Up @@ -722,7 +722,7 @@ bool getPayloadByNodeNameAsync(redfishPayload* payload, const char* nodeName, re
}
if(value == NULL)
{
REDFISH_DEBUG_ERR_PRINT("%s: Payload contains no element named %s\n", __FUNCTION__, nodeName);
REDFISH_DEBUG_ERR_PRINT("%s: Payload contains no element named %s\n", __func__, nodeName);
return false;
}
}
Expand Down Expand Up @@ -809,7 +809,7 @@ void gotNextRedPath(bool success, unsigned short httpCode, redfishPayload* paylo
redpathAsyncContext* myContext = (redpathAsyncContext*)context;
bool ret;

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

if(success == false || httpCode >= 400 || myContext->redpath->next == NULL)
{
Expand Down Expand Up @@ -839,7 +839,7 @@ bool getPayloadForPathAsync(redfishPayload* payload, redPathNode* redpath, redfi
redpathAsyncContext* myContext;
bool ret;

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

if(!payload || !redpath)
{
Expand Down Expand Up @@ -1001,11 +1001,11 @@ static bool getSimpleOpResult(json_t* json, const char* propName, RedPathOp op,
long long intVal, intPropVal;
bool ret;

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

if(json == NULL)
{
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. Null JSON\n", __FUNCTION__);
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. Null JSON\n", __func__);
return false;
}

Expand Down Expand Up @@ -1045,7 +1045,7 @@ static bool getSimpleOpResult(json_t* json, const char* propName, RedPathOp op,
ret = false;
break;
}
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. %u\n", __FUNCTION__, ret);
REDFISH_DEBUG_DEBUG_PRINT("%s: Exit. %u\n", __func__, ret);
return ret;
}

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

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

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

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

if(isPayloadCollection(payload))
{
Expand Down Expand Up @@ -1266,7 +1266,7 @@ static void opGotResultAsync(bool success, unsigned short httpCode, redfishPaylo
{
redpathAsyncOpContext* myContext = (redpathAsyncOpContext*)context;

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

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

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

if(success == true && httpCode < 300 && payload != NULL)
{
Expand Down Expand Up @@ -1320,9 +1320,9 @@ static bool collectionEvalOpAsync(redfishPayload* payload, const char* propName,
redfishPayload* members;
redfishPayload* tmp;

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

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

max = getCollectionSize(payload);
if(max == 0)
Expand Down Expand Up @@ -1463,7 +1463,7 @@ static bool arrayEvalOpAsync(redfishPayload* payload, const char* propName, RedP
redpathAsyncOpContext* myContext;
redfishPayload* tmp;

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

max = json_array_size(payload->json);
if(max == 0)
Expand Down
Loading

0 comments on commit 15d9a9b

Please sign in to comment.