- code cleanup; fixed issues from compiler warnings

pull/202/head
Michael Zillgith 6 years ago
parent 6cbadb4b45
commit 8c1b75b382

@ -134,6 +134,7 @@ CFLAGS += -Wnested-externs
CFLAGS += -Wmissing-declarations
CFLAGS += -Wshadow
CFLAGS += -Wall
CGLAGS += -Wextra
#CFLAGS += -Werror
all: lib

@ -43,7 +43,7 @@ dirname(char* path)
_dirname[lastSep - path] = 0;
}
else
strcpy("", path);
strcpy(_dirname, "");
return _dirname;
}

@ -460,7 +460,7 @@ iedConnection_handleReport(IedConnection self, MmsValue* value)
matchingReport->timestamp = MmsValue_getBinaryTimeAsUtcMs(timeStampValue);
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: report has timestamp %lu\n", matchingReport->timestamp);
printf("IED_CLIENT: report has timestamp %llu\n", (unsigned long long) matchingReport->timestamp);
inclusionIndex++;
}

@ -1925,9 +1925,7 @@ IedConnection_getFile(IedConnection self, IedClientError* error, const char* fil
clientFileReadHandler.retVal = true;
clientFileReadHandler.byteReceived = 0;
bool continueRead = true;
while (continueRead == true) {
while (true) {
bool moreFollows =
MmsConnection_fileRead(self->connection, &mmsError, frsmId, mmsFileReadHandler,
&clientFileReadHandler);

@ -22,6 +22,7 @@
*/
#include "iec61850_common.h"
#include "iec61850_common_internal.h"
#include "libiec61850_platform_includes.h"

@ -2186,7 +2186,10 @@ removeAllGIReportsFromReportBuffer(ReportBuffer* reportBuffer)
reportBuffer->oldestReport = currentReport->next;
}
else {
if (lastReport != NULL)
lastReport->next = currentReport->next;
else
lastReport = currentReport;
}
#if (DEBUG_IED_SERVER == 1)

@ -1261,13 +1261,15 @@ OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
asn_enc_rval_t er;
int ct_extensible = ct->flags & APC_EXTENSIBLE;
int inext = 0; /* Lies not within extension root */
int sizeinunits = st->size;
int sizeinunits;
const uint8_t *buf;
int ret;
if(!st || !st->buf)
_ASN_ENCODE_FAILED;
sizeinunits = st->size;
if(unit_bits == 1) {
sizeinunits = sizeinunits * 8 - (st->bits_unused & 0x07);
}
@ -1387,18 +1389,21 @@ OCTET_STRING_print_utf8(asn_TYPE_descriptor_t *td, const void *sptr,
}
void
OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
{
OCTET_STRING_t *st = (OCTET_STRING_t*) sptr;
if ((td == NULL) || (st == NULL))
return;
asn_OCTET_STRING_specifics_t *specs = td->specifics
? (asn_OCTET_STRING_specifics_t*) td->specifics
: &asn_DEF_OCTET_STRING_specs;
:
&asn_DEF_OCTET_STRING_specs;
asn_struct_ctx_t *ctx = (asn_struct_ctx_t*)
((char*) st + specs->ctx_offset);
struct _stack *stck;
if(!td || !st)
return;
if (st->buf) {
FREEMEM(st->buf);
}

@ -964,12 +964,13 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
void
CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
int present;
if(!td || !ptr)
return;
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
int present;
/*
* Figure out which CHOICE element is encoded.
*/

@ -841,6 +841,13 @@ asn_dec_rval_t
SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) {
asn_dec_rval_t rv;
rv.code = RC_OK;
rv.consumed = 0;
if (td == NULL)
return rv;
asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics;
asn_TYPE_member_t *elm = td->elements; /* Single one */
void *st = *sptr;
@ -866,7 +873,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
else if(td->per_constraints) ct = &td->per_constraints->size;
else ct = 0;
if(ct && ct->flags & APC_EXTENSIBLE) {
if(ct && (ct->flags & APC_EXTENSIBLE)) {
int value = per_get_few_bits(pd, 1);
if(value < 0) _ASN_DECODE_STARVED;
if(value) ct = 0; /* Not restricted! */
@ -905,8 +912,6 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
nelems = -1; /* Allow uper_get_length() */
} while(repeat);
rv.code = RC_OK;
rv.consumed = 0;
return rv;
}

@ -1273,7 +1273,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
if (bufPos == -1)
goto exit_with_error;
uint32_t invokeId;
bool hasInvokeId = false;
uint32_t invokeId = 0;
while (bufPos < payload->size) {
@ -1291,6 +1292,14 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
goto exit_with_error;
if (extendedTag) {
if (hasInvokeId == false) {
if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: invalid message received - missing invoke ID!\n");
goto exit_with_error;
}
switch (nestedTag)
{
@ -1351,6 +1360,8 @@ mmsIsoCallback(IsoIndication indication, void* parameter, ByteBuffer* payload)
if (DEBUG_MMS_CLIENT)
printf("MMS_CLIENT: received request with invokeId: %i\n", invokeId);
hasInvokeId = true;
self->lastInvokeId = invokeId;
break;
@ -3376,6 +3387,7 @@ MmsConnection_readJournalTimeRangeAsync(MmsConnection self, MmsError* mmsError,
if ((MmsValue_getType(startTime) != MMS_BINARY_TIME) ||
(MmsValue_getType(endTime) != MMS_BINARY_TIME)) {
if (mmsError)
*mmsError = MMS_ERROR_INVALID_ARGUMENTS;
goto exit_function;
}
@ -3447,6 +3459,7 @@ MmsConnection_readJournalStartAfterAsync(MmsConnection self, MmsError* mmsError,
if ((MmsValue_getType(timeSpecification) != MMS_BINARY_TIME) ||
(MmsValue_getType(entrySpecification) != MMS_OCTET_STRING)) {
if (mmsError)
*mmsError = MMS_ERROR_INVALID_ARGUMENTS;
goto exit_function;
}

@ -244,36 +244,6 @@ mmsMsg_parseDataElement(Data_t* dataElement)
printf("MMS CLIENT: error parsing data element (invalid structure size)!\n");
}
}
else if (dataElement->present == Data_PR_array) {
int componentCount = dataElement->choice.array->list.count;
if (componentCount > 0) {
value = (MmsValue*) GLOBAL_CALLOC(1, sizeof(MmsValue));
value->type = MMS_ARRAY;
value->value.structure.size = componentCount;
value->value.structure.components = (MmsValue**) GLOBAL_CALLOC(componentCount, sizeof(MmsValue*));
int i;
for (i = 0; i < componentCount; i++) {
value->value.structure.components[i] =
mmsMsg_parseDataElement(dataElement->choice.array->list.array[i]);
if (value->value.structure.components[i] == NULL) {
MmsValue_delete(value);
value = NULL;
break;
}
}
}
else {
if (DEBUG_MMS_CLIENT)
printf("MMS CLIENT: error parsing data element (invalid array size)!\n");
}
}
else {
if (dataElement->present == Data_PR_integer) {

@ -257,10 +257,11 @@ getNameListDomainSpecific(MmsServerConnection connection, char* domainName)
#if (MMS_DATA_SET_SERVICE == 1)
static LinkedList
createStringsFromNamedVariableList(LinkedList nameList, LinkedList variableLists)
createStringsFromNamedVariableList(LinkedList variableLists)
{
nameList = LinkedList_create();
LinkedList nameList = LinkedList_create();
LinkedList variableListsElement = LinkedList_getNext(variableLists);
while (variableListsElement != NULL) {
MmsNamedVariableList variableList =
(MmsNamedVariableList) variableListsElement->data;
@ -285,7 +286,7 @@ getNamedVariableListsDomainSpecific(MmsServerConnection connection, char* domain
if (domain != NULL) {
LinkedList variableLists = MmsDomain_getNamedVariableLists(domain);
nameList = createStringsFromNamedVariableList(nameList, variableLists);
nameList = createStringsFromNamedVariableList(variableLists);
}
return nameList;
@ -300,7 +301,7 @@ getNamedVariableListsVMDSpecific(MmsServerConnection connection)
LinkedList variableLists = MmsDevice_getNamedVariableLists(device);
nameList = createStringsFromNamedVariableList(nameList, variableLists);
nameList = createStringsFromNamedVariableList(variableLists);
return nameList;
}
@ -313,7 +314,7 @@ getNamedVariableListAssociationSpecific(MmsServerConnection connection)
LinkedList variableLists = MmsServerConnection_getNamedVariableLists(connection);
nameList = createStringsFromNamedVariableList(nameList, variableLists);
nameList = createStringsFromNamedVariableList(variableLists);
return nameList;
}

Loading…
Cancel
Save