Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gcc-arm-none-eabi -Wall warnings #462

Open
wants to merge 2 commits into
base: v1.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/common/inc/libiec61850_platform_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
#ifndef LIBIEC61850_PLATFORM_INCLUDES_H_
#define LIBIEC61850_PLATFORM_INCLUDES_H_

#define __STDC_FORMAT_MACROS 1

#include "stack_config.h"

#include "libiec61850_common_api.h"

#include "string_utilities.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
Expand Down
16 changes: 8 additions & 8 deletions src/goose/goose_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
timeAllowedToLive = BerDecoder_decodeUint32(buffer, elementLength, bufPos);

if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found timeAllowedToLive %u\n", timeAllowedToLive);
printf("GOOSE_SUBSCRIBER: Found timeAllowedToLive %"PRIu32"\n", timeAllowedToLive);

break;

Expand Down Expand Up @@ -783,13 +783,13 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
case 0x85:
stNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found stNum: %u\n", stNum);
printf("GOOSE_SUBSCRIBER: Found stNum: %"PRIu32"\n", stNum);
break;

case 0x86:
sqNum = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found sqNum: %u\n", sqNum);
printf("GOOSE_SUBSCRIBER: Found sqNum: %"PRIu32"\n", sqNum);
break;

case 0x87:
Expand All @@ -801,7 +801,7 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
case 0x88:
confRev = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found confRev: %u\n", confRev);
printf("GOOSE_SUBSCRIBER: Found confRev: %"PRIu32"\n", confRev);
break;

case 0x89:
Expand All @@ -813,7 +813,7 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)
case 0x8a:
numberOfDatSetEntries = BerDecoder_decodeUint32(buffer, elementLength, bufPos);
if (DEBUG_GOOSE_SUBSCRIBER)
printf("GOOSE_SUBSCRIBER: Found number of entries: %u\n", numberOfDatSetEntries);
printf("GOOSE_SUBSCRIBER: Found number of entries: %"PRIu32"\n", numberOfDatSetEntries);
break;

case 0xab:
Expand Down Expand Up @@ -856,7 +856,7 @@ parseGoosePayload(GooseReceiver self, uint8_t* buffer, int apduLength)

MmsValue_setUtcTime(matchingSubscriber->timestamp, 0);
}

if (matchingSubscriber->isObserver && matchingSubscriber->dataSetValues != NULL) {
MmsValue_delete(matchingSubscriber->dataSetValues);
matchingSubscriber->dataSetValues = NULL;
Expand Down Expand Up @@ -934,7 +934,7 @@ parseGooseMessage(GooseReceiver self, uint8_t* buffer, int numbytes)
return;
if (buffer[bufPos++] != 0xb8)
return;

uint8_t srcMac[6];
memcpy(srcMac,&buffer[6],6);

Expand Down Expand Up @@ -976,7 +976,7 @@ parseGooseMessage(GooseReceiver self, uint8_t* buffer, int numbytes)

while (element != NULL) {
GooseSubscriber subscriber = (GooseSubscriber) LinkedList_getData(element);

if (subscriber->isObserver)
{
subscriber->appId = appId;
Expand Down
2 changes: 1 addition & 1 deletion src/iec61850/client/client_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ internalOperateHandler(uint32_t invokeId, void* parameter, MmsError err, MmsData
}
else {
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: internal error - no matching outstanding call (ID: %u)!\n", invokeId);
printf("IED_CLIENT: internal error - no matching outstanding call (ID: %"PRIu32")!\n", invokeId);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/iec61850/client/client_report_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ writeMultipleVariablesHandler(uint32_t invokeId, void* parameter, MmsError mmsEr
}
else {
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: internal error - no matching outstanding call with invoke ID: %u!\n", invokeId);
printf("IED_CLIENT: internal error - no matching outstanding call with invoke ID: %"PRIu32"!\n", invokeId);
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/iec61850/client/ied_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,13 @@ handleLastApplErrorMessage(IedConnection self, MmsValue* lastApplError)
printf("IED_CLIENT: CntrlObj: %s\n", MmsValue_toString(cntrlObj));

if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: ctlNum: %u\n", MmsValue_toUint32(ctlNum));
printf("IED_CLIENT: ctlNum: %"PRIu32"\n", MmsValue_toUint32(ctlNum));

if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: addCause: %i\n", MmsValue_toInt32(addCause));
printf("IED_CLIENT: addCause: %"PRIi32"\n", MmsValue_toInt32(addCause));

if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: error: %i\n", MmsValue_toInt32(error));
printf("IED_CLIENT: error: %"PRIi32"\n", MmsValue_toInt32(error));

self->lastApplError.ctlNum = MmsValue_toUint32(ctlNum);
self->lastApplError.addCause = (ControlAddCause) MmsValue_toInt32(addCause);
Expand Down Expand Up @@ -652,11 +652,11 @@ IedConnection_tick(IedConnection self)
}

void
IedConnection_setLocalAddress(IedConnection self, const char* localIpAddress, int localPort)
IedConnection_setLocalAddress(IedConnection self, const char* localIpAddress, int localPort)
{
MmsConnection connection = self->connection;
IsoConnectionParameters isoP = MmsConnection_getIsoConnectionParameters(connection);

IsoConnectionParameters_setLocalTcpParameters(isoP, localIpAddress, localPort);
}

Expand Down Expand Up @@ -4252,4 +4252,3 @@ FileDirectoryEntry_getLastModified(FileDirectoryEntry self)
{
return self->lastModified;
}

2 changes: 1 addition & 1 deletion src/iec61850/common/iec61850_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ MmsMapping_varAccessSpecToObjectReference(MmsVariableAccessSpecification* varAcc

/* Add array index part */
if (varAccessSpec->arrayIndex > -1) {
sprintf(targetPos, "(%i)", varAccessSpec->arrayIndex);
sprintf(targetPos, "(%"PRIi32")", varAccessSpec->arrayIndex);
targetPos += arrayIndexLen;
}

Expand Down
7 changes: 3 additions & 4 deletions src/iec61850/server/mms_mapping/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ updateSboTimeoutValue(ControlObject* self)
uint32_t sboTimeoutVal = MmsValue_toInt32(self->sboTimeout);

if (DEBUG_IED_SERVER)
printf("IED_SERVER: set timeout for %s/%s.%s to %u\n", MmsDomain_getName(self->mmsDomain), self->lnName, self->name, sboTimeoutVal);
printf("IED_SERVER: set timeout for %s/%s.%s to %"PRIu32"\n", MmsDomain_getName(self->mmsDomain), self->lnName, self->name, sboTimeoutVal);

self->selectTimeout = sboTimeoutVal;
}
Expand Down Expand Up @@ -546,7 +546,7 @@ checkSelectTimeout(ControlObject* self, uint64_t currentTime, MmsMapping* mmsMap
if (self->selectTimeout > 0) {
if (currentTime > (self->selectTime + self->selectTimeout)) {
if (DEBUG_IED_SERVER)
printf("IED_SERVER: select-timeout (timeout-val = %u) for control %s/%s.%s\n",
printf("IED_SERVER: select-timeout (timeout-val = %"PRIu32") for control %s/%s.%s\n",
self->selectTimeout, MmsDomain_getName(self->mmsDomain), self->lnName, self->name);

unselectObject(self, SELECT_STATE_REASON_TIMEOUT, mmsMapping);
Expand Down Expand Up @@ -1681,7 +1681,7 @@ ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection connect
if (DEBUG_IED_SERVER) {
printf("IED_SERVER: sendLastApplError:\n");
printf("IED_SERVER: control object: %s\n", ctlObj);
printf("IED_SERVER: ctlNum: %u\n", MmsValue_toUint32(ctlNum));
printf("IED_SERVER: ctlNum: %"PRIu32"\n", MmsValue_toUint32(ctlNum));
}

MmsValue ctlObjValueMemory;
Expand Down Expand Up @@ -2550,4 +2550,3 @@ ControlAction_getControlTime(ControlAction self)
}

#endif /* (CONFIG_IEC61850_CONTROL_SERVICE == 1) */

18 changes: 8 additions & 10 deletions src/iec61850/server/model/config_file_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
uint32_t bufTm;
uint32_t intgPd;

int matchedItems = sscanf((char*) lineBuffer, "RC(%129s %129s %i %129s %u %i %i %u %u)",
int matchedItems = sscanf((char*) lineBuffer, "RC(%129s %129s %i %129s %"SCNu32" %i %i %"SCNu32" %"SCNu32")",
nameString, nameString2, &isBuffered, nameString3, &confRef,
&trgOps, &options, &bufTm, &intgPd);

Expand All @@ -246,7 +246,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
int logEna;
int withReasonCode;

int matchedItems = sscanf((char*) lineBuffer, "LC(%129s %129s %129s %u %u %i %i)",
int matchedItems = sscanf((char*) lineBuffer, "LC(%129s %129s %129s %"SCNu32" %"SCNu32" %i %i)",
nameString, nameString2, nameString3, &trgOps, &intgPd, &logEna, &withReasonCode);

if (matchedItems < 7) goto exit_error;
Expand Down Expand Up @@ -277,7 +277,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
int minTime = -1;
int maxTime = -1;

int matchedItems = sscanf((char*) lineBuffer, "GC(%129s %129s %129s %u %i %i %i)",
int matchedItems = sscanf((char*) lineBuffer, "GC(%129s %129s %129s %"SCNu32" %i %i %i)",
nameString, nameString2, nameString3, &confRef, &fixedOffs, &minTime, &maxTime);

if (matchedItems < 5) goto exit_error;
Expand All @@ -295,7 +295,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
int optFlds;
int isUnicast;

int matchedItems = sscanf((char*) lineBuffer, "SMVC(%129s %129s %129s %u %i %i %i %i)",
int matchedItems = sscanf((char*) lineBuffer, "SMVC(%129s %129s %129s %"SCNu32" %i %i %i %i)",
nameString, nameString2, nameString3, &confRev, &smpMod, &smpRate, &optFlds, &isUnicast);

if (matchedItems < 5) goto exit_error;
Expand Down Expand Up @@ -356,7 +356,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
int triggerOptions = 0;
uint32_t sAddr = 0;

sscanf((char*) lineBuffer, "DA(%129s %i %i %i %i %u)", nameString, &arrayElements, &attributeType, &functionalConstraint, &triggerOptions, &sAddr);
sscanf((char*) lineBuffer, "DA(%129s %i %i %i %i %"SCNu32")", nameString, &arrayElements, &attributeType, &functionalConstraint, &triggerOptions, &sAddr);

DataAttribute* dataAttribute = DataAttribute_create(nameString, currentModelNode,
(DataAttributeType) attributeType, (FunctionalConstraint) functionalConstraint, triggerOptions, arrayElements, sAddr);
Expand Down Expand Up @@ -394,7 +394,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
case IEC61850_ENUMERATED:
{
int32_t intValue;
if (sscanf(valueIndicator + 1, "%i", &intValue) != 1) goto exit_error;
if (sscanf(valueIndicator + 1, "%"SCNi32, &intValue) != 1) goto exit_error;
dataAttribute->mmsValue = MmsValue_newIntegerFromInt32(intValue);
}
break;
Expand All @@ -405,7 +405,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
case IEC61850_INT32U:
{
uint32_t uintValue;
if (sscanf(valueIndicator + 1, "%u", &uintValue) != 1) goto exit_error;
if (sscanf(valueIndicator + 1, "%"SCNu32, &uintValue) != 1) goto exit_error;
dataAttribute->mmsValue = MmsValue_newUnsignedFromUint32(uintValue);
}
break;
Expand Down Expand Up @@ -504,7 +504,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
uint32_t vlanId;
uint32_t appId;

int matchedItems = sscanf((char*) lineBuffer, "PA(%u %u %u %129s)", &vlanPrio, &vlanId, &appId, nameString);
int matchedItems = sscanf((char*) lineBuffer, "PA(%"SCNu32" %"SCNu32" %"SCNu32" %129s)", &vlanPrio, &vlanId, &appId, nameString);

if ((matchedItems != 4) || ((currentGoCB == NULL) && (currentSMVCB == NULL))) goto exit_error;

Expand Down Expand Up @@ -563,5 +563,3 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
IedModel_destroy(model);
return NULL;
}


10 changes: 5 additions & 5 deletions src/mms/iso_mms/client/mms_client_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ handleUnconfirmedMmsPdu(MmsConnection self, ByteBuffer* message)
}
else {
if (DEBUG_MMS_CLIENT)
printf("handleUnconfirmedMmsPdu: error parsing PDU at %u\n", (uint32_t) rval.consumed);
printf("handleUnconfirmedMmsPdu: error parsing PDU at %"PRIu32"\n", (uint32_t) rval.consumed);
}

asn_DEF_MmsPdu.free_struct(&asn_DEF_MmsPdu, mmsPdu, 0);
Expand Down Expand Up @@ -1230,7 +1230,7 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
if (mmsMsg_parseRejectPDU(payload->buffer, 0, payload->size, &invokeId, &hasInvokeId, &rejectType, &rejectReason) >= 0) {

if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: reject PDU invokeID: %u type: %i reason: %i\n", invokeId, rejectType, rejectReason);
printf("MMS_CLIENT: reject PDU invokeID: %"PRIu32" type: %i reason: %i\n", invokeId, rejectType, rejectReason);

if (hasInvokeId) {
MmsOutstandingCall call = checkForOutstandingCall(self, invokeId);
Expand Down Expand Up @@ -1280,7 +1280,7 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
BerDecoder_decodeUint32(buf, invokeIdLength, bufPos);

if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: mms_client_connection: rcvd confirmed resp - invokeId: %u length: %i bufLen: %i\n",
printf("MMS_CLIENT: mms_client_connection: rcvd confirmed resp - invokeId: %"PRIu32" length: %i bufLen: %i\n",
invokeId, length, payload->size);

bufPos += invokeIdLength;
Expand Down Expand Up @@ -1407,7 +1407,7 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
case 0x02: /* invoke Id */
invokeId = BerDecoder_decodeUint32(buf, length, bufPos);
if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: received request with invokeId: %u\n", invokeId);
printf("MMS_CLIENT: received request with invokeId: %"PRIu32"\n", invokeId);

hasInvokeId = true;

Expand Down Expand Up @@ -1867,7 +1867,7 @@ MmsConnection_abort(MmsConnection self, MmsError* mmsError)
}

}

if (success == false) {
IsoClientConnection_close(self->isoClient);
*mmsError = MMS_ERROR_SERVICE_TIMEOUT;
Expand Down
2 changes: 1 addition & 1 deletion src/mms/iso_mms/client/mms_client_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mmsClient_handleFileReadRequest(
int32_t frsmId = BerDecoder_decodeInt32(buffer, maxBufPos - bufPos, bufPos);

if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: mmsClient_handleFileReadRequest read request for frsmId: %i\n", frsmId);
printf("MMS_CLIENT: mmsClient_handleFileReadRequest read request for frsmId: %"PRIi32"\n", frsmId);

MmsFileReadStateMachine* frsm = getFrsm(connection, frsmId);

Expand Down
2 changes: 1 addition & 1 deletion src/mms/iso_mms/common/mms_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ MmsValue_printToBuffer(const MmsValue* self, char* buffer, int bufferSize)
break;

case MMS_UNSIGNED:
snprintf(buffer, bufferSize, "%u", MmsValue_toUint32(self));
snprintf(buffer, bufferSize, "%"PRIu32, MmsValue_toUint32(self));
break;

case MMS_UTC_TIME:
Expand Down
4 changes: 2 additions & 2 deletions src/mms/iso_mms/server/mms_association_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,13 @@ parseInitRequestDetail(MmsServerConnection self, uint8_t* buffer, int bufPos, in

if (protocolVersion < 1) {
if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: invalid protocol version %u\n", protocolVersion);
printf("MMS_SERVER: invalid protocol version %"PRIu32"\n", protocolVersion);

return false;
}

if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: proposed version number %u\n", protocolVersion);
printf("MMS_SERVER: proposed version number %"PRIu32"\n", protocolVersion);
}

break;
Expand Down
13 changes: 6 additions & 7 deletions src/mms/iso_mms/server/mms_file_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ mmsServer_fileUploadTask(MmsServer self, MmsObtainFileTask task, int taskState)

ByteBuffer* message = NULL;

if (taskState == MMS_FILE_UPLOAD_STATE_SEND_FILE_READ ||
if (taskState == MMS_FILE_UPLOAD_STATE_SEND_FILE_READ ||
taskState == MMS_FILE_UPLOAD_STATE_SEND_FILE_CLOSE ||
taskState == MMS_FILE_UPLOAD_STATE_SEND_OBTAIN_FILE_ERROR_SOURCE ||
taskState == MMS_FILE_UPLOAD_STATE_SEND_OBTAIN_FILE_ERROR_DESTINATION ||
taskState == MMS_FILE_UPLOAD_STATE_SEND_OBTAIN_FILE_RESPONSE)
taskState == MMS_FILE_UPLOAD_STATE_SEND_OBTAIN_FILE_RESPONSE)
{
IsoConnection_lock(task->connection->isoConnection);

Expand Down Expand Up @@ -551,7 +551,7 @@ mmsServer_fileUploadTask(MmsServer self, MmsObtainFileTask task, int taskState)
FileSystem_closeFile(task->fileHandle);
task->fileHandle = NULL;
}

deleteFile(MmsServer_getFilesystemBasepath(self), task->destinationFilename);

if (DEBUG_MMS_SERVER)
Expand Down Expand Up @@ -891,7 +891,7 @@ mmsServer_handleFileReadRequest(
int32_t frsmId = BerDecoder_decodeInt32(buffer, maxBufPos - bufPos, bufPos);

if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: mmsServer_handleFileReadRequest read request for frsmId: %i\n", frsmId);
printf("MMS_SERVER: mmsServer_handleFileReadRequest read request for frsmId: %"PRIi32"\n", frsmId);

MmsFileReadStateMachine* frsm = getFrsm(connection, frsmId);

Expand Down Expand Up @@ -927,7 +927,7 @@ mmsServer_handleFileCloseRequest(
}
else {
if (DEBUG_MMS_SERVER)
printf("MMS_SERVER: Unused file ID %i\n", frsmId);
printf("MMS_SERVER: Unused file ID %"PRIi32"\n", frsmId);

mmsMsg_createServiceErrorPdu(invokeId, response, MMS_ERROR_FILE_OTHER);
}
Expand Down Expand Up @@ -1051,7 +1051,7 @@ createFileDirectoryResponse(const char* basepath, uint32_t invokeId, ByteBuffer*
continueAfterFileName = NULL;
}

if ((directoryName && mmsMsg_isFilenameSave(directoryName) == false) ||
if ((directoryName && mmsMsg_isFilenameSave(directoryName) == false) ||
(continueAfterFileName && mmsMsg_isFilenameSave(continueAfterFileName) == false))
{
if (DEBUG_MMS_SERVER)
Expand Down Expand Up @@ -1282,4 +1282,3 @@ mmsServer_handleFileDirectoryRequest(
}

#endif /* MMS_FILE_SERVICE == 1 */

Loading