diff --git a/src/common/linked_list.c b/src/common/linked_list.c index 693d5890..c3f8720b 100644 --- a/src/common/linked_list.c +++ b/src/common/linked_list.c @@ -204,14 +204,8 @@ LinkedList_printStringList(LinkedList list) { LinkedList element = list; - int elementCount = 0; - while ((element = LinkedList_getNext(element)) != NULL) { char* str = (char*) (element->data); printf("%s\n", str); - elementCount++; } } - - - diff --git a/src/common/string_utilities.c b/src/common/string_utilities.c index dc197009..80a2c7a6 100644 --- a/src/common/string_utilities.c +++ b/src/common/string_utilities.c @@ -111,7 +111,6 @@ StringUtils_createString(int count, ...) { va_list ap; char* newStr; - char* currentPos; int newStringLength = 0; int i; @@ -127,7 +126,7 @@ StringUtils_createString(int count, ...) newStr = (char*) GLOBAL_MALLOC(newStringLength + 1); if (newStr) { - currentPos = newStr; + char* currentPos = newStr; va_start(ap, count); for (i = 0; i < count; i++) { @@ -136,8 +135,6 @@ StringUtils_createString(int count, ...) currentPos += strlen(str); } va_end(ap); - - *currentPos = 0; } return newStr; @@ -271,11 +268,11 @@ getCharWeight(int c) { static bool initialized = false; static char lookupTable[LT_MAX_CHARS + 1]; - static const char* charOrder = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz$_0123456789"; if (!initialized) { int ltIndex; int weight = 1; + const char* charOrder = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz$_0123456789"; for (ltIndex = 1; ltIndex < LT_MAX_CHARS; ltIndex++) { if (strchr(charOrder, ltIndex)) continue; diff --git a/src/iec61850/client/client_control.c b/src/iec61850/client/client_control.c index 64d98e24..83c3a852 100644 --- a/src/iec61850/client/client_control.c +++ b/src/iec61850/client/client_control.c @@ -570,7 +570,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: %d)!\n", invokeId); + printf("IED_CLIENT: internal error - no matching outstanding call (ID: %u)!\n", invokeId); } } diff --git a/src/iec61850/client/client_report.c b/src/iec61850/client/client_report.c index e1448310..dc4374ea 100644 --- a/src/iec61850/client/client_report.c +++ b/src/iec61850/client/client_report.c @@ -386,7 +386,8 @@ iedConnection_handleReport(IedConnection self, MmsValue* value) char defaultRptId[130]; char* rptId = report->rptId; - if ((rptId == NULL) || (rptId && (strlen(rptId) == 0))) { + if ((rptId == NULL) || (strlen(rptId) == 0)) { + //if ((rptId == NULL) || (rptId && (strlen(rptId) == 0))) { strncpy(defaultRptId, report->rcbReference, 129); defaultRptId[129] = 0; StringUtils_replace(defaultRptId, '.', '$'); diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index ca922313..bf3ba92e 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -1676,7 +1676,6 @@ IedConnection_writeOctetString(IedConnection self, IedClientError* error, const mmsValue.type = MMS_OCTET_STRING; mmsValue.value.octetString.buf = value; mmsValue.value.octetString.size = valueLength; - mmsValue.value.octetString.size = valueLength; IedConnection_writeObject(self, error, objectReference, fc, &mmsValue); } diff --git a/src/iec61850/server/impl/ied_server.c b/src/iec61850/server/impl/ied_server.c index fde9754b..cf2e0bdc 100644 --- a/src/iec61850/server/impl/ied_server.c +++ b/src/iec61850/server/impl/ied_server.c @@ -1163,8 +1163,8 @@ IedServer_updateAttributeValue(IedServer self, DataAttribute* dataAttribute, Mms void IedServer_updateFloatAttributeValue(IedServer self, DataAttribute* dataAttribute, float value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_FLOAT); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_FLOAT); assert(self != NULL); float currentValue = MmsValue_toFloat(dataAttribute->mmsValue); @@ -1187,8 +1187,8 @@ IedServer_updateFloatAttributeValue(IedServer self, DataAttribute* dataAttribute void IedServer_updateInt32AttributeValue(IedServer self, DataAttribute* dataAttribute, int32_t value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_INTEGER); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_INTEGER); assert(self != NULL); int32_t currentValue = MmsValue_toInt32(dataAttribute->mmsValue); @@ -1233,8 +1233,8 @@ IedServer_updateDbposValue(IedServer self, DataAttribute* dataAttribute, Dbpos v void IedServer_updateInt64AttributeValue(IedServer self, DataAttribute* dataAttribute, int64_t value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_INTEGER); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_INTEGER); assert(self != NULL); int64_t currentValue = MmsValue_toInt64(dataAttribute->mmsValue); @@ -1258,8 +1258,8 @@ IedServer_updateInt64AttributeValue(IedServer self, DataAttribute* dataAttribute void IedServer_updateUnsignedAttributeValue(IedServer self, DataAttribute* dataAttribute, uint32_t value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UNSIGNED); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UNSIGNED); assert(self != NULL); uint32_t currentValue = MmsValue_toUint32(dataAttribute->mmsValue); @@ -1283,8 +1283,8 @@ IedServer_updateUnsignedAttributeValue(IedServer self, DataAttribute* dataAttrib void IedServer_updateBitStringAttributeValue(IedServer self, DataAttribute* dataAttribute, uint32_t value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_BIT_STRING); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_BIT_STRING); assert(self != NULL); uint32_t currentValue = MmsValue_getBitStringAsInteger(dataAttribute->mmsValue); @@ -1340,8 +1340,8 @@ IedServer_updateBooleanAttributeValue(IedServer self, DataAttribute* dataAttribu void IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataAttribute, char *value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_VISIBLE_STRING); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_VISIBLE_STRING); assert(self != NULL); const char* currentValue = MmsValue_toString(dataAttribute->mmsValue); @@ -1364,8 +1364,8 @@ IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataA void IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribute, uint64_t value) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME); assert(self != NULL); uint64_t currentValue = MmsValue_getUtcTimeInMs(dataAttribute->mmsValue); @@ -1389,8 +1389,8 @@ IedServer_updateUTCTimeAttributeValue(IedServer self, DataAttribute* dataAttribu void IedServer_updateTimestampAttributeValue(IedServer self, DataAttribute* dataAttribute, Timestamp* timestamp) { - assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME); assert(dataAttribute != NULL); + assert(MmsValue_getType(dataAttribute->mmsValue) == MMS_UTC_TIME); assert(self != NULL); if (memcmp(dataAttribute->mmsValue->value.utcTime, timestamp->val, 8)) { diff --git a/src/iec61850/server/mms_mapping/control.c b/src/iec61850/server/mms_mapping/control.c index ea6bef22..3a640723 100644 --- a/src/iec61850/server/mms_mapping/control.c +++ b/src/iec61850/server/mms_mapping/control.c @@ -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 = %i) for control %s/%s.%s\n", + printf("IED_SERVER: select-timeout (timeout-val = %u) for control %s/%s.%s\n", self->selectTimeout, MmsDomain_getName(self->mmsDomain), self->lnName, self->name); unselectObject(self, SELECT_STATE_REASON_TIMEOUT, mmsMapping); @@ -1874,7 +1874,7 @@ Control_readAccessControlObject(MmsMapping* self, MmsDomain* domain, char* varia } else { if (DEBUG_IED_SERVER) - printf("IED_SERVER: select not applicable for control model %i\n", controlObject->ctlModel); + printf("IED_SERVER: select not applicable for control model %u\n", controlObject->ctlModel); value = controlObject->sbo; } diff --git a/src/iec61850/server/mms_mapping/logging.c b/src/iec61850/server/mms_mapping/logging.c index 9218cfd7..97d627ff 100644 --- a/src/iec61850/server/mms_mapping/logging.c +++ b/src/iec61850/server/mms_mapping/logging.c @@ -502,8 +502,10 @@ LIBIEC61850_LOG_SVC_writeAccessLogControlBlock(MmsMapping* self, MmsDomain* doma char* varName = MmsMapping_getNextNameElement(objectName); - if (varName != NULL) - *(varName - 1) = 0; + if (varName == NULL) + return DATA_ACCESS_ERROR_INVALID_ADDRESS; + + *(varName - 1) = 0; LogControl* logControl = lookupLogControl(self, domain, lnName, objectName); diff --git a/src/iec61850/server/mms_mapping/mms_mapping.c b/src/iec61850/server/mms_mapping/mms_mapping.c index 658625b0..23145aa4 100644 --- a/src/iec61850/server/mms_mapping/mms_mapping.c +++ b/src/iec61850/server/mms_mapping/mms_mapping.c @@ -2677,11 +2677,16 @@ mmsWriteHandler(void* parameter, MmsDomain* domain, } else retVal = DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID; - } + #if (CONFIG_IEC61850_SERVICE_TRACKING == 1) - copySGCBValuesToTrackingObject(self, sg->sgcb); - updateGenericTrackingObjectValues(self, sg->sgcb, IEC61850_SERVICE_TYPE_SELECT_ACTIVE_SG, retVal); + copySGCBValuesToTrackingObject(self, sg->sgcb); + updateGenericTrackingObjectValues(self, sg->sgcb, IEC61850_SERVICE_TYPE_SELECT_ACTIVE_SG, retVal); #endif /* (CONFIG_IEC61850_SERVICE_TRACKING == 1) */ + } + else { + retVal = DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID; + } + return retVal; } else if (strcmp(nameId, "EditSG") == 0) { diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index 91f1c004..4bac9847 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -801,7 +801,7 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet, #endif /* (MMS_DYNAMIC_DATA_SETS == 1) */ - if ((dataSet == NULL) || (dataSetChanged == true)) { + if (dataSetChanged == true) { /* delete pending event and create buffer for new data set */ deleteDataSetValuesShadowBuffer(rc); @@ -3089,7 +3089,7 @@ exit_function: #define SENT_REPORT_ENTRY_FINISHED 1 #define SENT_REPORT_ENTRY_MORE_FOLLOWS 2 -static bool +static int sendNextReportEntrySegment(ReportControl* self) { if (self->clientConnection == NULL) @@ -3297,10 +3297,10 @@ sendNextReportEntrySegment(ReportControl* self) if ((report->flags > 0) || MmsValue_getBitStringBit(inclusionField, i)) { - int elementSize = 0; - if (i >= startElementIndex) { + int elementSize = 0; + if (withDataReference) { DataSetEntry* dataSetEntry = getDataSetEntryWithIndex(self->dataSet->fcdas, i); diff --git a/src/iec61850/server/model/config_file_parser.c b/src/iec61850/server/model/config_file_parser.c index b6afa3bd..1029beb8 100644 --- a/src/iec61850/server/model/config_file_parser.c +++ b/src/iec61850/server/model/config_file_parser.c @@ -170,7 +170,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) if (StringUtils_startsWith((char*) lineBuffer, "LD")) { indendation = 2; - if (sscanf((char*) lineBuffer, "LD(%s)", nameString) < 1) + if (sscanf((char*) lineBuffer, "LD(%129s)", nameString) < 1) goto exit_error; terminateString(nameString, ')'); @@ -184,7 +184,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) if (StringUtils_startsWith((char*) lineBuffer, "LN")) { indendation = 3; - if (sscanf((char*) lineBuffer, "LN(%s)", nameString) < 1) + if (sscanf((char*) lineBuffer, "LN(%129s)", nameString) < 1) goto exit_error; terminateString(nameString, ')'); @@ -200,7 +200,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int arrayElements = 0; - sscanf((char*) lineBuffer, "DO(%s %i)", nameString, &arrayElements); + sscanf((char*) lineBuffer, "DO(%129s %i)", nameString, &arrayElements); currentModelNode = (ModelNode*) DataObject_create(nameString, (ModelNode*) currentLN, arrayElements); @@ -221,7 +221,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) uint32_t bufTm; uint32_t intgPd; - int matchedItems = sscanf((char*) lineBuffer, "RC(%s %s %i %s %u %i %i %u %u)", + int matchedItems = sscanf((char*) lineBuffer, "RC(%129s %129s %i %129s %u %i %i %u %u)", nameString, nameString2, &isBuffered, nameString3, &confRef, &trgOps, &options, &bufTm, &intgPd); @@ -246,7 +246,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int logEna; int withReasonCode; - int matchedItems = sscanf((char*) lineBuffer, "LC(%s %s %s %u %u %i %i)", + int matchedItems = sscanf((char*) lineBuffer, "LC(%129s %129s %129s %u %u %i %i)", nameString, nameString2, nameString3, &trgOps, &intgPd, &logEna, &withReasonCode); if (matchedItems < 7) goto exit_error; @@ -262,7 +262,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) LogControlBlock_create(nameString, currentLN, dataSet, logRef, trgOps, intgPd, logEna, withReasonCode); } else if (StringUtils_startsWith((char*) lineBuffer, "LOG")) { - int matchedItems = sscanf((char*) lineBuffer, "LOG(%s)", nameString); + int matchedItems = sscanf((char*) lineBuffer, "LOG(%129s)", nameString); if (matchedItems < 1) goto exit_error; @@ -277,7 +277,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int minTime = -1; int maxTime = -1; - int matchedItems = sscanf((char*) lineBuffer, "GC(%s %s %s %u %i %i %i)", + int matchedItems = sscanf((char*) lineBuffer, "GC(%129s %129s %129s %u %i %i %i)", nameString, nameString2, nameString3, &confRef, &fixedOffs, &minTime, &maxTime); if (matchedItems < 5) goto exit_error; @@ -295,7 +295,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int optFlds; int isUnicast; - int matchedItems = sscanf((char*) lineBuffer, "SMVC(%s %s %s %u %i %i %i %i)", + int matchedItems = sscanf((char*) lineBuffer, "SMVC(%129s %129s %129s %u %i %i %i %i)", nameString, nameString2, nameString3, &confRev, &smpMod, &smpRate, &optFlds, &isUnicast); if (matchedItems < 5) goto exit_error; @@ -341,7 +341,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int arrayElements = 0; - int matchedItems = sscanf((char*) lineBuffer, "DO(%s %i)", nameString, &arrayElements); + int matchedItems = sscanf((char*) lineBuffer, "DO(%129s %i)", nameString, &arrayElements); if (matchedItems != 2) goto exit_error; @@ -356,7 +356,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) int triggerOptions = 0; uint32_t sAddr = 0; - sscanf((char*) lineBuffer, "DA(%s %i %i %i %i %u)", nameString, &arrayElements, &attributeType, &functionalConstraint, &triggerOptions, &sAddr); + sscanf((char*) lineBuffer, "DA(%129s %i %i %i %i %u)", nameString, &arrayElements, &attributeType, &functionalConstraint, &triggerOptions, &sAddr); DataAttribute* dataAttribute = DataAttribute_create(nameString, currentModelNode, (DataAttributeType) attributeType, (FunctionalConstraint) functionalConstraint, triggerOptions, arrayElements, sAddr); @@ -503,7 +503,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) uint32_t vlanId; uint32_t appId; - int matchedItems = sscanf((char*) lineBuffer, "PA(%u %u %u %s)", &vlanPrio, &vlanId, &appId, nameString); + int matchedItems = sscanf((char*) lineBuffer, "PA(%u %u %u %129s)", &vlanPrio, &vlanId, &appId, nameString); if ((matchedItems != 4) || ((currentGoCB == NULL) && (currentSMVCB == NULL))) goto exit_error; @@ -541,7 +541,7 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle) indendation = 1; } else if (StringUtils_startsWith((char*) lineBuffer, "MODEL(")) { - sscanf((char*) lineBuffer, "MODEL(%s)", nameString); + sscanf((char*) lineBuffer, "MODEL(%129s)", nameString); terminateString(nameString, ')'); model = IedModel_create(nameString); stateInModel = true; diff --git a/src/iec61850/server/model/model.c b/src/iec61850/server/model/model.c index 4d8444b0..c4e35db8 100644 --- a/src/iec61850/server/model/model.c +++ b/src/iec61850/server/model/model.c @@ -470,17 +470,15 @@ LogicalDevice_getLogicalNodeCount(LogicalDevice* logicalDevice) ModelNode* LogicalDevice_getChildByMmsVariableName(LogicalDevice* logicalDevice, const char* mmsVariableName) { - - - char fcString[3]; - char nameRef[65]; - const char* separator = strchr(mmsVariableName,'$'); if (separator == NULL) return NULL; if (strlen(separator) > 4) { + char fcString[3]; + char nameRef[65]; + fcString[0] = separator[1]; fcString[1] = separator[2]; fcString[2] = 0; diff --git a/src/mms/asn1/ber_encoder.c b/src/mms/asn1/ber_encoder.c index 181e83a0..49168f66 100644 --- a/src/mms/asn1/ber_encoder.c +++ b/src/mms/asn1/ber_encoder.c @@ -181,16 +181,14 @@ void BerEncoder_revertByteOrder(uint8_t* octets, const int size) { int i; - uint8_t temp; for (i = 0; i < size / 2; i++) { - temp = octets[i]; + uint8_t temp = octets[i]; octets[i] = octets[(size - 1) - i]; octets[(size - 1) - i] = temp; } } - int BerEncoder_compressInteger(uint8_t* integer, int originalSize) { @@ -431,13 +429,13 @@ BerEncoder_encodeOIDToBuffer(const char* oidString, uint8_t* buffer, int maxBufL val = atoi(separator + 1); - int requiredBytes = 0; - if (val == 0) { buffer[encodedBytes++] = 0; } else { + int requiredBytes = 0; int val2 = val; + while (val2 > 0) { requiredBytes++; val2 = val2 >> 7; diff --git a/src/mms/iso_acse/acse.c b/src/mms/iso_acse/acse.c index 60b0f534..f46b024d 100644 --- a/src/mms/iso_acse/acse.c +++ b/src/mms/iso_acse/acse.c @@ -579,7 +579,6 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self, assert(payload != NULL); int payloadLength = payload->length; - int authValueLength; int authValueStringLength = 0; int passwordLength = 0; @@ -637,7 +636,7 @@ AcseConnection_createAssociateRequestMessage(AcseConnection* self, contentLength += passwordLength + authValueStringLength; - authValueLength = BerEncoder_determineLengthSize( + int authValueLength = BerEncoder_determineLengthSize( passwordLength + authValueStringLength + 1); contentLength += authValueLength; diff --git a/src/mms/iso_mms/client/mms_client_connection.c b/src/mms/iso_mms/client/mms_client_connection.c index cdbbb2b2..5635fd78 100644 --- a/src/mms/iso_mms/client/mms_client_connection.c +++ b/src/mms/iso_mms/client/mms_client_connection.c @@ -1,7 +1,7 @@ /* * mms_client_connection.c * - * Copyright 2013-2019 Michael Zillgith + * Copyright 2013-2022 Michael Zillgith * * This file is part of libIEC61850. * @@ -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: %i length: %i bufLen: %i\n", + printf("MMS_CLIENT: mms_client_connection: rcvd confirmed resp - invokeId: %u length: %i bufLen: %i\n", invokeId, length, payload->size); bufPos += invokeIdLength; @@ -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: %i\n", invokeId); + printf("MMS_CLIENT: received request with invokeId: %u\n", invokeId); hasInvokeId = true; @@ -1479,8 +1479,6 @@ MmsConnection_createInternal(TLSConfiguration tlsConfig, bool createThread) self->parameters.dataStructureNestingLevel = -1; self->parameters.maxServOutstandingCalled = -1; self->parameters.maxServOutstandingCalling = -1; - self->parameters.maxPduSize = -1; - self->parameters.maxPduSize = CONFIG_MMS_MAXIMUM_PDU_SIZE; self->requestTimeout = CONFIG_MMS_CONNECTION_DEFAULT_TIMEOUT; diff --git a/src/mms/iso_mms/common/mms_value.c b/src/mms/iso_mms/common/mms_value.c index 53d6563c..1ce3a0b2 100644 --- a/src/mms/iso_mms/common/mms_value.c +++ b/src/mms/iso_mms/common/mms_value.c @@ -1,7 +1,7 @@ /* * mms_value.c * - * Copyright 2013-2020 Michael Zillgith + * Copyright 2013-2022 Michael Zillgith * * This file is part of libIEC61850. * @@ -270,7 +270,7 @@ MmsValue_update(MmsValue* self, const MmsValue* update) case MMS_BIT_STRING: if (self->value.bitString.size == update->value.bitString.size) memcpy(self->value.bitString.buf, update->value.bitString.buf, bitStringByteSize(self)); - else if (update->value.bitString.size != self->value.bitString.size) { + else { int i; for (i = 0; i < update->value.bitString.size; i++) { @@ -280,8 +280,7 @@ MmsValue_update(MmsValue* self, const MmsValue* update) break; } } - else - return false; + break; case MMS_OCTET_STRING: diff --git a/src/mms/iso_mms/server/mms_information_report.c b/src/mms/iso_mms/server/mms_information_report.c index e0411dc2..95ae5e24 100644 --- a/src/mms/iso_mms/server/mms_information_report.c +++ b/src/mms/iso_mms/server/mms_information_report.c @@ -52,7 +52,7 @@ MmsServerConnection_sendInformationReportSingleVariableVMDSpecific(MmsServerConn if (completeMessageSize > self->maxPduSize) { if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: report message too large %i (max = %i) -> skip message!\n", completeMessageSize, self->maxPduSize); + printf("MMS_SERVER: report message too large %u (max = %u) -> skip message!\n", completeMessageSize, self->maxPduSize); goto exit_function; } @@ -157,7 +157,7 @@ MmsServerConnection_sendInformationReportListOfVariables( if (completeMessageSize > self->maxPduSize) { if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: report message too large %i (max = %i) -> skip message!\n", completeMessageSize, self->maxPduSize); + printf("MMS_SERVER: report message too large %u (max = %u) -> skip message!\n", completeMessageSize, self->maxPduSize); goto exit_function; } @@ -281,7 +281,7 @@ MmsServerConnection_sendInformationReportVMDSpecific(MmsServerConnection self, c if (completeMessageSize > self->maxPduSize) { if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: report message too large %i (max = %i) -> skip message!\n", completeMessageSize, self->maxPduSize); + printf("MMS_SERVER: report message too large %u (max = %u) -> skip message!\n", completeMessageSize, self->maxPduSize); goto exit_function; } diff --git a/src/mms/iso_mms/server/mms_journal_service.c b/src/mms/iso_mms/server/mms_journal_service.c index 8cdafb68..22980f76 100644 --- a/src/mms/iso_mms/server/mms_journal_service.c +++ b/src/mms/iso_mms/server/mms_journal_service.c @@ -40,16 +40,6 @@ struct sJournalVariable { JournalVariable next; }; -typedef struct { - uint8_t* entryID; - int entryIDSize; - - uint64_t timestamp; - - JournalVariable listOfVariables; -} JournalEntry; - - typedef struct sJournalEncoder* JournalEncoder; struct sJournalEncoder { diff --git a/src/mms/iso_mms/server/mms_server.c b/src/mms/iso_mms/server/mms_server.c index aa77f5ab..81250fd8 100644 --- a/src/mms/iso_mms/server/mms_server.c +++ b/src/mms/iso_mms/server/mms_server.c @@ -662,10 +662,11 @@ MmsServer_startListeningThreadless(MmsServer self, int tcpPort) int MmsServer_waitReady(MmsServer self, unsigned int timeoutMs) { - bool isFirst = true; int result = 0; if (self->isoServerList) { + bool isFirst = true; + LinkedList elem = LinkedList_getNext(self->isoServerList); while (elem) { diff --git a/src/mms/iso_mms/server/mms_server_connection.c b/src/mms/iso_mms/server/mms_server_connection.c index ab95673c..6cce1696 100644 --- a/src/mms/iso_mms/server/mms_server_connection.c +++ b/src/mms/iso_mms/server/mms_server_connection.c @@ -1,7 +1,7 @@ /* * mms_server_connection.c * - * Copyright 2013-2018 Michael Zillgith + * Copyright 2013-2022 Michael Zillgith * * This file is part of libIEC61850. * @@ -306,7 +306,7 @@ handleConfirmedRequestPdu( case 0x02: /* invoke Id */ invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: received request with invokeId: %i\n", invokeId); + printf("MMS_SERVER: received request with invokeId: %u\n", invokeId); self->lastInvokeId = invokeId; break; @@ -476,7 +476,7 @@ mmsFileReadHandler(uint32_t invokeId, void* parameter, MmsError mmsError, int32_ if (mmsError == MMS_ERROR_NONE) { if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: file %i received %i bytes\n", task->frmsId, bytesReceived); + printf("MMS_SERVER: file %i received %u bytes\n", task->frmsId, bytesReceived); if(task->fileHandle){ FileSystem_writeFile(task->fileHandle, buffer, bytesReceived); @@ -634,7 +634,7 @@ handleConfirmedResponsePdu( case 0x02: /* invoke Id */ invokeId = BerDecoder_decodeUint32(buffer, length, bufPos); if (DEBUG_MMS_SERVER) - printf("MMS_SERVER: received request with invokeId: %i\n", invokeId); + printf("MMS_SERVER: received request with invokeId: %u\n", invokeId); self->lastInvokeId = invokeId; break; diff --git a/src/sampled_values/sv_subscriber.c b/src/sampled_values/sv_subscriber.c index 8d701dd1..99f5d34f 100644 --- a/src/sampled_values/sv_subscriber.c +++ b/src/sampled_values/sv_subscriber.c @@ -1,7 +1,7 @@ /* * sv_receiver.c * - * Copyright 2015-2018 Michael Zillgith + * Copyright 2015-2022 Michael Zillgith * * This file is part of libIEC61850. * @@ -352,8 +352,8 @@ parseASDU(SVReceiver self, SVSubscriber subscriber, uint8_t* buffer, int length) printf("SV_SUBSCRIBER: SV ASDU: ----------------\n"); printf("SV_SUBSCRIBER: DataLength: %d\n", asdu.dataBufferLength); printf("SV_SUBSCRIBER: SvId: %s\n", asdu.svId); - printf("SV_SUBSCRIBER: SmpCnt: %d\n", SVSubscriber_ASDU_getSmpCnt(&asdu)); - printf("SV_SUBSCRIBER: ConfRev: %d\n", SVSubscriber_ASDU_getConfRev(&asdu)); + printf("SV_SUBSCRIBER: SmpCnt: %u\n", SVSubscriber_ASDU_getSmpCnt(&asdu)); + printf("SV_SUBSCRIBER: ConfRev: %u\n", SVSubscriber_ASDU_getConfRev(&asdu)); if (SVSubscriber_ASDU_hasDatSet(&asdu)) printf("SV_SUBSCRIBER: DatSet: %s\n", asdu.datSet);