diff --git a/.gitignore b/.gitignore index 156907aa..a7896fba 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ packages/ # vcpkg generated vcpkg_installed/ + +# run-tests log +error.log diff --git a/README.md b/README.md index fff512f5..264b7807 100644 --- a/README.md +++ b/README.md @@ -108,18 +108,24 @@ $ make TARGET=zoul clean all In order to `make` the documentation you need to install [doxygen](https://www.doxygen.nl/). -Use one of the following commands to install `doxygen`: +Use one of the following commands to install `doxygen` and Valgrind for `run-tests` in +`tests/external/valgrind-checks`: ### macOS +This doesn't work great so a `run-tests-macos-arm` was added that calls `leaks`. + ```sh $ brew install doxygen +$ brew tap LouisBrunner/valgrind +$ brew install --HEAD LouisBrunner/valgrind/valgrind ``` ### Linux (Ubuntu/Debian) ```sh -$ apt-get install doxygen +$ sudo apt-get install doxygen +$ sudo apt-get install valgrind ``` ### Windows diff --git a/doc/dev/Doxyfile b/doc/dev/Doxyfile index e87c40b1..e6acd376 100644 --- a/doc/dev/Doxyfile +++ b/doc/dev/Doxyfile @@ -1055,7 +1055,7 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = *.txt # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/include/EXISerializer.h b/include/EXISerializer.h index 8207c440..a0647f8c 100644 --- a/include/EXISerializer.h +++ b/include/EXISerializer.h @@ -122,7 +122,6 @@ errorCode endElement(EXIStream* strm); * of the attribute. It should be used to determine which function for data handling * to be used for its content. Otherwise - VALUE_TYPE_NONE_CLASS * @return Error handling code - * @todo Consider handling the lexicographical sorting of attributes by exip encoding utilities? */ errorCode attribute(EXIStream* strm, QName qname, bool isSchemaType, EXITypeClass* valueType); @@ -224,7 +223,6 @@ errorCode qnameData(EXIStream* strm, QName qname); * * @param[in, out] strm EXI stream object * @return Error handling code - * @todo define the parameters! */ errorCode processingInstruction(EXIStream* strm); @@ -247,7 +245,6 @@ errorCode namespaceDeclaration(EXIStream* strm, const String ns, const String pr * * @param[in, out] strm EXI stream object * @return Error handling code - * @todo define the parameters! */ errorCode selfContained(EXIStream* strm); @@ -321,7 +318,7 @@ errorCode flushEXIData(EXIStream* strm, char* outBuf, unsigned int bufSize, unsi * To be used by code generation tools such as static XML bindings * and when efficiency is of high importance * - * @param[in, out] strm EXI stream + * @param[in, out] strm EXI stream object * @param[in] ec EXI event code of the production * @param[in] qname used only for SE(*), AT(*), SE(uri:*), AT(uri:*) and when * a new prefix should be serialized in SE(QName) and AT(QName); NULL otherwise diff --git a/src/contentIO/src/EXISerializer.c b/src/contentIO/src/EXISerializer.c index 6246e46b..d44d5ff2 100644 --- a/src/contentIO/src/EXISerializer.c +++ b/src/contentIO/src/EXISerializer.c @@ -25,7 +25,6 @@ #include "stringManipulate.h" #include "streamEncode.h" #include "initSchemaInstance.h" -#include "ioUtil.h" #include "streamEncode.h" /** diff --git a/src/contentIO/src/bodyDecode.c b/src/contentIO/src/bodyDecode.c index 7458359d..69747421 100644 --- a/src/contentIO/src/bodyDecode.c +++ b/src/contentIO/src/bodyDecode.c @@ -15,8 +15,8 @@ */ #include "bodyDecode.h" +#include "procTypes.h" #include "sTables.h" -#include "memManagement.h" #include "ioUtil.h" #include "streamDecode.h" #include "grammars.h" @@ -31,10 +31,10 @@ static errorCode decodeQNameValue(EXIStream* strm, ContentHandler* handler, Smal errorCode processNextProduction(EXIStream* strm, SmallIndex* nonTermID_out, ContentHandler* handler, void* app_data) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - unsigned int bitCount; - unsigned long tmp_bits_val = 0; - GrammarRule* currentRule; - Index prodCount; + unsigned int bitCount = 0; + unsigned int tmp_bits_val = 0; + GrammarRule* currentRule = NULL; + Index prodCount = 0; SmallIndex currNonTermID = strm->gStack->currNonTermID; // TODO: GR_CONTENT_2 is only needed when schema deviations are allowed. @@ -165,7 +165,7 @@ static errorCode stateMachineProdDecode(EXIStream* strm, GrammarRule* currentRul { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; unsigned int prodCnt = 0; - unsigned long tmp_bits_val = 0; + unsigned int tmp_bits_val = 0; if(IS_BUILT_IN_ELEM(strm->gStack->grammar->props)) { @@ -177,7 +177,7 @@ static errorCode stateMachineProdDecode(EXIStream* strm, GrammarRule* currentRul * The state depends on the input event code from the stream and the * available productions at level 2. * (Note this is the state for level 2 productions) */ - unsigned long state = 0; + unsigned int state = 0; /* The state mask stores the availability of the productions on level 2. * They are encoded ordered: @@ -424,7 +424,7 @@ static errorCode stateMachineProdDecode(EXIStream* strm, GrammarRule* currentRul else { // Schema-informed element/type grammar - QName qname; + QName qname = {0}; if(WITH_STRICT(strm->header.opts.enumOpt)) { @@ -435,7 +435,7 @@ static errorCode stateMachineProdDecode(EXIStream* strm, GrammarRule* currentRul { /* There are 2 possible states to exit the state machine: AT(xsi:type) and AT(xsi:nil) * (Note this is the state for level 2 productions) */ - unsigned long state = 1; + unsigned int state = 1; bool nil; *nonTermID_out = GR_START_TAG_CONTENT; @@ -518,7 +518,7 @@ static errorCode stateMachineProdDecode(EXIStream* strm, GrammarRule* currentRul * Availability for EE is encoded in position 0, * availability for AT(xsi:type) is encoded in position 1, * and so on. */ - bool state_mask[11] = {false, false, false, false, false, false, false, false, false, false, false}; + bool state_mask[11] = {0}; // all false unsigned int i; // Create a copy of the content grammar if and only if there are AT // productions that point to the content grammar rule OR the content index is 0. @@ -743,7 +743,7 @@ errorCode decodeQName(EXIStream* strm, QName* qname, QNameID* qnameID) errorCode decodeUri(EXIStream* strm, SmallIndex* uriId) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - unsigned long tmp_val_buf = 0; + unsigned int tmp_val_buf = 0; unsigned char uriBits = getBitsNumber(strm->schema->uriTable.count); TRY(decodeNBitUnsignedInteger(strm, uriBits, &tmp_val_buf)); @@ -774,7 +774,7 @@ errorCode decodeLn(EXIStream* strm, Index uriId, Index* lnId) if(tmpVar == 0) // local-name table hit { - unsigned long l_lnId; + unsigned int l_lnId; unsigned char lnBits = getBitsNumber((unsigned int)(strm->schema->uriTable.uri[uriId].lnTable.count - 1)); DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">local-name table hit\n")); TRY(decodeNBitUnsignedInteger(strm, lnBits, &l_lnId)); @@ -806,7 +806,7 @@ errorCode decodePfxQname(EXIStream* strm, QName* qname, SmallIndex uriId) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; unsigned char prefixBits = 0; - unsigned long prefixID = 0; + unsigned int prefixID = 0; qname->prefix = NULL; @@ -834,7 +834,7 @@ errorCode decodePfxQname(EXIStream* strm, QName* qname, SmallIndex uriId) errorCode decodePfx(EXIStream* strm, SmallIndex uriId, SmallIndex* pfxId) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - unsigned long tmp_val_buf = 0; + unsigned int tmp_val_buf = 0; unsigned char prfxBits = getBitsNumber(strm->schema->uriTable.uri[uriId].pfxTable.count); TRY(decodeNBitUnsignedInteger(strm, prfxBits, &tmp_val_buf)); @@ -866,7 +866,7 @@ errorCode decodeStringValue(EXIStream* strm, QNameID qnameID, String* value) if(tmpVar == 0) // "local" value partition table hit { #if VALUE_CROSSTABLE_USE - unsigned long vxEntryId = 0; + unsigned int vxEntryId = 0; unsigned char vxBits; VxTable* vxTable; @@ -883,7 +883,7 @@ errorCode decodeStringValue(EXIStream* strm, QNameID qnameID, String* value) } else if(tmpVar == 1)// global value partition table hit { - unsigned long valueEntryID = 0; + unsigned int valueEntryID = 0; unsigned char valueBits; valueBits = getBitsNumber(strm->valueTable.count - 1); @@ -1047,8 +1047,8 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler break; case VALUE_TYPE_SMALL_INTEGER: { - unsigned long uintVal; - int64_t base; + unsigned int uintVal; + int base; int64_t upLimit; if(typeId >= strm->schema->simpleTypeTable.count) @@ -1112,8 +1112,8 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler break; case VALUE_TYPE_BINARY: { - Index nbytes; - char *binary_val; + Index nbytes = 0; + char *binary_val = NULL; //DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">Binary value\n")); TRY(decodeBinary(strm, &binary_val, &nbytes)); @@ -1192,9 +1192,9 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler break; case VALUE_TYPE_LIST: { - UnsignedInteger itemCount; - Index itemTypeId; - unsigned int i; + UnsignedInteger itemCount = 0; + Index itemTypeId = 0; + unsigned int i = 0; TRY(decodeUnsignedInteger(strm, &itemCount)); @@ -1222,7 +1222,7 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler break; default: // VALUE_TYPE_STRING || VALUE_TYPE_NONE || VALUE_TYPE_UNTYPED { - String value; + String value = {0}; bool freeable = false; /* ENUMERATION CHECK */ @@ -1231,7 +1231,7 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler // There is enumeration defined EnumDefinition eDefSearch; EnumDefinition* eDefFound; - unsigned long indx; + unsigned int indx; eDefSearch.typeId = typeId; eDefFound = bsearch(&eDefSearch, strm->schema->enumTable.enumDef, strm->schema->enumTable.count, sizeof(EnumDefinition), compareEnumDefs); @@ -1266,8 +1266,8 @@ errorCode decodeValueItem(EXIStream* strm, Index typeId, ContentHandler* handler errorCode decodeNSEvent(EXIStream* strm, ContentHandler* handler, SmallIndex* nonTermID_out, void* app_data) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - SmallIndex ns_uriId; - SmallIndex pfxId; + SmallIndex ns_uriId = 0; + SmallIndex pfxId = 0; bool bool_val = false; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">NS event:\n")); @@ -1289,7 +1289,7 @@ errorCode decodeSEWildcardEvent(EXIStream* strm, ContentHandler* handler, SmallI { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; EXIGrammar* elemGrammar = NULL; - QName qname; + QName qname = {0}; QNameID qnameId = {URI_MAX, LN_MAX}; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">SE(*) event\n")); @@ -1423,7 +1423,7 @@ errorCode decodeSEWildcardEvent(EXIStream* strm, ContentHandler* handler, SmallI errorCode decodeATWildcardEvent(EXIStream* strm, ContentHandler* handler, SmallIndex* nonTermID_out, void* app_data) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - QName qname; + QName qname = {0}; QNameID qnameId = {URI_MAX, LN_MAX}; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">AT(*) event\n")); @@ -1455,8 +1455,8 @@ static errorCode decodeQNameValue(EXIStream* strm, ContentHandler* handler, Smal { // TODO: Add the case when Preserve.lexicalValues option value is true - instead of Qname decode it as String errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - QName qname; - QNameID qnameId; + QName qname = {0}; + QNameID qnameId = {URI_MAX, LN_MAX}; EXIGrammar* newGrammar = NULL; TRY(decodeQName(strm, &qname, &qnameId)); diff --git a/src/contentIO/src/headerDecode.c b/src/contentIO/src/headerDecode.c index c90a9e7e..c7acc78f 100644 --- a/src/contentIO/src/headerDecode.c +++ b/src/contentIO/src/headerDecode.c @@ -16,16 +16,11 @@ */ #include "headerDecode.h" -#include "streamDecode.h" #include "streamRead.h" #include "contentHandler.h" -#include "memManagement.h" -#include "bodyDecode.h" -#include "grammars.h" #include "EXIParser.h" #include "sTables.h" #include "stringManipulate.h" -#include "initSchemaInstance.h" /** This is the statically generated EXIP schema definition for the EXI Options document*/ extern const EXIPSchema ops_schema; @@ -53,7 +48,7 @@ struct ops_AppData errorCode decodeHeader(EXIStream* strm, bool outOfBandOpts) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - unsigned long bits_val = 0; + unsigned int bits_val = 0; bool boolVal = false; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">Start EXI header decoding\n")); diff --git a/src/streamIO/include/streamDecode.h b/src/streamIO/include/streamDecode.h index fcdee062..1cbc469d 100644 --- a/src/streamIO/include/streamDecode.h +++ b/src/streamIO/include/streamDecode.h @@ -29,7 +29,7 @@ * @param[out] int_val resulting n-bit unsigned integer value * @return Error handling code */ -errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned long* int_val); +errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned int* int_val); /** * @brief Decode EXI Boolean diff --git a/src/streamIO/include/streamEncode.h b/src/streamIO/include/streamEncode.h index 175d19d0..e45a785d 100644 --- a/src/streamIO/include/streamEncode.h +++ b/src/streamIO/include/streamEncode.h @@ -29,7 +29,7 @@ * @param[in] int_val n-bit unsigned integer value * @return Error handling code */ -errorCode encodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned long int_val); +errorCode encodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned int int_val); /** * @brief Encode EXI Boolean diff --git a/src/streamIO/include/streamRead.h b/src/streamIO/include/streamRead.h index eab2f29a..f1ded80a 100644 --- a/src/streamIO/include/streamRead.h +++ b/src/streamIO/include/streamRead.h @@ -37,6 +37,6 @@ errorCode readNextBit(EXIStream* strm, bool* bit_val); * @param[out] bits_val resulting bits value * @return Error handling code */ -errorCode readBits(EXIStream* strm, unsigned char n, unsigned long* bits_val); +errorCode readBits(EXIStream* strm, unsigned char n, unsigned int* bits_val); #endif /* STREAMREADER_H_ */ diff --git a/src/streamIO/include/streamWrite.h b/src/streamIO/include/streamWrite.h index d3f4f9a3..061f097d 100644 --- a/src/streamIO/include/streamWrite.h +++ b/src/streamIO/include/streamWrite.h @@ -36,6 +36,6 @@ errorCode writeNextBit(EXIStream* strm, bool bit_val); * @param[in] nbits number of bits * @param[in] bits_val resulting bits value */ -errorCode writeNBits(EXIStream* strm, unsigned char nbits, unsigned long bits_val); +errorCode writeNBits(EXIStream* strm, unsigned char nbits, unsigned int bits_val); #endif /* STREAMWRITE_H_ */ diff --git a/src/streamIO/src/streamDecode.c b/src/streamIO/src/streamDecode.c index 518c2b92..7e6bdc49 100644 --- a/src/streamIO/src/streamDecode.c +++ b/src/streamIO/src/streamDecode.c @@ -19,9 +19,8 @@ #include "streamRead.h" #include "stringManipulate.h" #include "ioUtil.h" -#include -errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned long* int_val) +errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned int* int_val) { DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (%d-bits uint)", n)); if(n == 0) @@ -36,9 +35,9 @@ errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned l } else { - unsigned int byte_number = ((unsigned int) n) / 8 + (n % 8 != 0); - unsigned long tmp_byte_buf = 0; - unsigned int i = 0; + uint8_t byte_number = ((unsigned int) n) / 8 + (n % 8 != 0); + uint16_t tmp_byte_buf = 0; + uint8_t i = 0; if(strm->buffer.bufContent < strm->context.bufferIndx + byte_number) { @@ -51,7 +50,7 @@ errorCode decodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned l *int_val = 0; for(i = 0; i < byte_number*8; i += 8) { - tmp_byte_buf = strm->buffer.buf[strm->context.bufferIndx] << i; + tmp_byte_buf = ((uint8_t)strm->buffer.buf[strm->context.bufferIndx]) << i; *int_val = *int_val | tmp_byte_buf; strm->context.bufferIndx++; } @@ -63,7 +62,7 @@ errorCode decodeBoolean(EXIStream* strm, bool* bool_val) { //TODO: when pattern facets are available in the schema datatype - handle it differently errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; - unsigned long lBoolVal; + unsigned int lBoolVal; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (bool)")); TRY(decodeNBitUnsignedInteger(strm, 1, &lBoolVal)); *bool_val = (bool) lBoolVal; @@ -74,7 +73,7 @@ errorCode decodeUnsignedInteger(EXIStream* strm, UnsignedInteger* int_val) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; unsigned int i = 0; - unsigned long tmp_byte_buf = 0; + unsigned int tmp_byte_buf = 0; *int_val = 0; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (uint)")); @@ -127,7 +126,7 @@ errorCode decodeBinary(EXIStream* strm, char** binary_val, Index* nbytes) { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; UnsignedInteger length = 0; - unsigned long int_val = 0; + unsigned int int_val = 0; UnsignedInteger i = 0; DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> (binary)")); @@ -250,8 +249,8 @@ errorCode decodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime* dt_ { errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; Integer year; - unsigned long monDay = 0; - unsigned long timeVal = 0; + unsigned int monDay = 0; + unsigned int timeVal = 0; bool presence = false; dt_val->presenceMask = 0; @@ -273,8 +272,8 @@ errorCode decodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime* dt_ { /* MonthDay component */ TRY(decodeNBitUnsignedInteger(strm, 9, &monDay)); - dt_val->dateTime.tm_mon = (int) monDay / 32 - 1; - dt_val->dateTime.tm_mday = (int) monDay % 32; + dt_val->dateTime.tm_mon = monDay / 32 - 1; + dt_val->dateTime.tm_mday = monDay % 32; } else { @@ -331,14 +330,14 @@ errorCode decodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime* dt_ if(presence) { - unsigned long tzone = 0; + unsigned int tzone = 0; dt_val->presenceMask = dt_val->presenceMask | TZONE_PRESENCE; TRY(decodeNBitUnsignedInteger(strm, 11, &tzone)); if(tzone > 1851) { tzone = 1851; - DEBUG_MSG(WARNING, DEBUG_STREAM_IO, (">Invalid TimeZone value: %lu\n", tzone)); + DEBUG_MSG(WARNING, DEBUG_STREAM_IO, (">Invalid TimeZone value: %u\n", tzone)); } dt_val->TimeZone = (int16_t) tzone - 896; diff --git a/src/streamIO/src/streamEncode.c b/src/streamIO/src/streamEncode.c index 3a1051f2..dee934db 100644 --- a/src/streamIO/src/streamEncode.c +++ b/src/streamIO/src/streamEncode.c @@ -19,21 +19,20 @@ #include "streamWrite.h" #include "stringManipulate.h" #include "ioUtil.h" -#include -errorCode encodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned long int_val) +errorCode encodeNBitUnsignedInteger(EXIStream* strm, unsigned char n, unsigned int int_val) { - DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> %lu [0x%lX] (%u bits)", int_val, int_val, n)); + DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> %u [%#X] (%u bits)", int_val, int_val, n)); if(WITH_COMPRESSION(strm->header.opts.enumOpt) == false && GET_ALIGNMENT(strm->header.opts.enumOpt) == BIT_PACKED) { return writeNBits(strm, n, int_val); } else { - unsigned int byte_number = n / 8 + (n % 8 != 0); - int tmp_byte_buf; - unsigned int i; + uint8_t byte_number = n / 8 + (n % 8 != 0); + uint8_t tmp_byte_buf; + uint8_t i; if(strm->buffer.bufLen < strm->context.bufferIndx + byte_number) { @@ -251,7 +250,7 @@ errorCode encodeDateTimeValue(EXIStream* strm, EXIType dtType, EXIPDateTime dt_v if(dtType == VALUE_TYPE_DATE_TIME || dtType == VALUE_TYPE_TIME) { /* Time component */ - unsigned long timeVal = 0; + unsigned int timeVal = 0; timeVal += dt_val.dateTime.tm_hour; timeVal = timeVal * 64; diff --git a/src/streamIO/src/streamRead.c b/src/streamIO/src/streamRead.c index 354f7917..eb67ba45 100644 --- a/src/streamIO/src/streamRead.c +++ b/src/streamIO/src/streamRead.c @@ -49,7 +49,7 @@ errorCode readNextBit(EXIStream* strm, bool* bit_val) return EXIP_OK; } -errorCode readBits(EXIStream* strm, unsigned char n, unsigned long* bits_val) +errorCode readBits(EXIStream* strm, unsigned char n, unsigned int* bits_val) { unsigned int numBytesToBeRead = 1 + ((n + strm->context.bitPointer - 1) / 8); unsigned int byteIndx = 1; @@ -69,13 +69,13 @@ errorCode readBits(EXIStream* strm, unsigned char n, unsigned long* bits_val) while(byteIndx < numBytesToBeRead) { - *bits_val += (unsigned long) (buf[byteIndx])<<((numBytesToBeRead-byteIndx-1)*8); + *bits_val += (unsigned int) (buf[byteIndx])<<((numBytesToBeRead-byteIndx-1)*8); byteIndx++; } *bits_val = *bits_val >> (numBytesToBeRead*8 - n - strm->context.bitPointer); - DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> %lu [0x%lX] (%u bits)", *bits_val, *bits_val, n)); + DEBUG_MSG(INFO, DEBUG_STREAM_IO, (">> %u [%#X] (%u bits)", *bits_val, *bits_val, n)); n += strm->context.bitPointer; strm->context.bufferIndx += n / 8; diff --git a/src/streamIO/src/streamWrite.c b/src/streamIO/src/streamWrite.c index 22431efb..f0fd8622 100644 --- a/src/streamIO/src/streamWrite.c +++ b/src/streamIO/src/streamWrite.c @@ -44,7 +44,7 @@ errorCode writeNextBit(EXIStream* strm, bool bit_val) return EXIP_OK; } -errorCode writeNBits(EXIStream* strm, unsigned char nbits, unsigned long bits_val) +errorCode writeNBits(EXIStream* strm, unsigned char nbits, unsigned int bits_val) { unsigned int numBitsWrite = 0; // Number of the bits written so far unsigned char tmp = 0; diff --git a/tests/check_streamIO.c b/tests/check_streamIO.c index 47a9d94b..8da6ecee 100644 --- a/tests/check_streamIO.c +++ b/tests/check_streamIO.c @@ -94,7 +94,7 @@ START_TEST (test_readBits) { EXIStream testStream; char buf[2]; - unsigned long bits_val = 0; + unsigned int bits_val = 0; errorCode err = EXIP_UNEXPECTED_ERROR; testStream.context.bitPointer = 0; @@ -111,7 +111,7 @@ START_TEST (test_readBits) err = readBits(&testStream, 4, &bits_val); fail_unless (bits_val == 13, - "The bits 1101 from the stream are read as %lu", bits_val); + "The bits 1101 from the stream are read as %u", bits_val); fail_unless (err == EXIP_OK, "readBits returns error code %d", err); fail_unless (testStream.context.bitPointer == 4, @@ -123,7 +123,7 @@ START_TEST (test_readBits) err = readBits(&testStream, 5, &bits_val); fail_unless (bits_val == 6, - "The bits 00110 from the stream are read as %lu", bits_val); + "The bits 00110 from the stream are read as %u", bits_val); fail_unless (err == EXIP_OK, "readNextBit returns error code %d", err); fail_unless (testStream.context.bitPointer == 4 && testStream.context.bufferIndx == 1, @@ -251,7 +251,7 @@ START_TEST (test_decodeNBitUnsignedInteger) EXIStream testStream; char buf[2]; - unsigned long bit_val = 0; + unsigned int bit_val = 0; errorCode err = EXIP_UNEXPECTED_ERROR; testStream.context.bitPointer = 0; @@ -270,7 +270,7 @@ START_TEST (test_decodeNBitUnsignedInteger) err = decodeNBitUnsignedInteger(&testStream, 6, &bit_val); fail_unless (bit_val == 53, - "The 110101 from the stream is read as %lu", bit_val); + "The 110101 from the stream is read as %u", bit_val); fail_unless (err == EXIP_OK, "decodeNBitUnsignedInteger returns error code %d", err); fail_unless (testStream.context.bitPointer == 6, diff --git a/tests/external/valgrind-checks/run-tests-macos-arm b/tests/external/valgrind-checks/run-tests-macos-arm new file mode 100755 index 00000000..239ec54c --- /dev/null +++ b/tests/external/valgrind-checks/run-tests-macos-arm @@ -0,0 +1,16 @@ +#!/bin/bash + +EXIPD=../../../bin/examples/exipd +export MallocStackLogging=1 + +if ! [ -f $EXIPD ]; + then + echo "ERROR: You need to compile the exipd executable before executing this test." +fi + +leaks --atExit -- ../../../bin/examples/exipd ../../test-set/SchemaLess-WrongBody.exi > error.log 2>&1 +leaks --atExit -- ../../../bin/examples/exipd ../../test-set/SchemaLess-TotallyWrong.exi >> error.log 2>&1 +leaks --atExit -- ../../../bin/examples/exipd -schema ../../test-set/Schema.exi ../../test-set/Schema-WrongBody.exi >> error.log 2>&1 +leaks --atExit -- ../../../bin/examples/exipd -schema ../../test-set/Schema.exi ../../test-set/Schema-TotallyWrong.exi >> error.log 2>&1 + +grep "ERROR SUMMARY" < error.log \ No newline at end of file