To avoid warnings on some compilers, return NDN_ERROR_success instead of 0.
diff --git a/ndn-cpp/c/encoding/binary-xml-data.c b/ndn-cpp/c/encoding/binary-xml-data.c
index c02ca70..4533fd0 100644
--- a/ndn-cpp/c/encoding/binary-xml-data.c
+++ b/ndn-cpp/c/encoding/binary-xml-data.c
@@ -30,7 +30,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
static ndn_Error decodeSignature(struct ndn_Signature *signature, struct ndn_BinaryXmlDecoder *decoder)
@@ -53,13 +53,13 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
static ndn_Error encodeSignedInfo(struct ndn_SignedInfo *signedInfo, struct ndn_BinaryXmlEncoder *encoder)
{
if (signedInfo->type < 0)
- return 0;
+ return NDN_ERROR_success;
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_SignedInfo)))
@@ -93,7 +93,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
static ndn_Error decodeSignedInfo(struct ndn_SignedInfo *signedInfo, struct ndn_BinaryXmlDecoder *decoder)
@@ -126,7 +126,7 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_encodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlEncoder *encoder)
@@ -136,13 +136,13 @@
return error;
if ((error = encodeSignature(&data->signature, encoder)))
- return 0;
+ return NDN_ERROR_success;
if ((error = ndn_encodeBinaryXmlName(&data->name, encoder)))
return error;
if ((error = encodeSignedInfo(&data->signedInfo, encoder)))
- return 0;
+ return NDN_ERROR_success;
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
(encoder, ndn_BinaryXml_DTag_Content, data->content, data->contentLength)))
@@ -151,7 +151,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeBinaryXmlData(struct ndn_Data *data, struct ndn_BinaryXmlDecoder *decoder)
@@ -190,5 +190,5 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-decoder.c b/ndn-cpp/c/encoding/binary-xml-decoder.c
index 1d50461..fd9ed4c 100644
--- a/ndn-cpp/c/encoding/binary-xml-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-decoder.c
@@ -48,7 +48,7 @@
}
*resultOut = result;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_decodeTypeAndValue(struct ndn_BinaryXmlDecoder *self, unsigned int *type, unsigned int *valueOut)
@@ -80,7 +80,7 @@
}
*valueOut = value;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readElementStartDTag(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag)
@@ -97,7 +97,7 @@
if (value != expectedTag)
return NDN_ERROR_did_not_get_the_expected_DTAG;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readElementClose(struct ndn_BinaryXmlDecoder *self)
@@ -108,7 +108,7 @@
if (unsafeReadOctet(self) != ndn_BinaryXml_CLOSE)
return NDN_ERROR_did_not_get_the_expected_element_close;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_peekDTag(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int *gotExpectedTag)
@@ -120,7 +120,7 @@
if (self->offset >= self->inputLength)
return NDN_ERROR_read_past_the_end_of_the_input;
if (unsafeGetOctet(self) == 0)
- return 0;
+ return NDN_ERROR_success;
unsigned int type;
unsigned int value;
@@ -135,7 +135,7 @@
if (type == ndn_BinaryXml_DTAG && value == expectedTag)
*gotExpectedTag = 1;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
@@ -154,7 +154,7 @@
++self->offset;
*value = 0;
*valueLength = 0;
- return 0;
+ return NDN_ERROR_success;
}
}
@@ -168,7 +168,7 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
@@ -187,7 +187,7 @@
*valueLength = 0;
}
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
@@ -208,7 +208,7 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(self)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
@@ -223,7 +223,7 @@
if ((error = parseUnsignedDecimalInt(udataValue, udataValueLength, value)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
@@ -236,7 +236,7 @@
if (!gotExpectedTag) {
*value = -1;
- return 0;
+ return NDN_ERROR_success;
}
unsigned int unsignedValue;
@@ -244,7 +244,7 @@
return error;
*value = (int)unsignedValue;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readTimeMillisecondsDTagElement
@@ -257,7 +257,7 @@
return error;
*milliseconds = 1000.0 * ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(bytes, bytesLength) / 4096.0;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlDecoder_readOptionalTimeMillisecondsDTagElement
@@ -270,13 +270,13 @@
if (!gotExpectedTag) {
*milliseconds = -1.0;
- return 0;
+ return NDN_ERROR_success;
}
if ((error = ndn_BinaryXmlDecoder_readTimeMillisecondsDTagElement(self, expectedTag, milliseconds)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(unsigned char *bytes, unsigned int bytesLength)
diff --git a/ndn-cpp/c/encoding/binary-xml-element-reader.c b/ndn-cpp/c/encoding/binary-xml-element-reader.c
index 110b496..b7c062e 100644
--- a/ndn-cpp/c/encoding/binary-xml-element-reader.c
+++ b/ndn-cpp/c/encoding/binary-xml-element-reader.c
@@ -18,10 +18,6 @@
return error;
if (self->structureDecoder.gotElementEnd) {
// Got the remainder of an element. Report to the caller.
-#if 0 // TODO: implement saving data parts.
- this.dataParts.push(data.subarray(0, this.structureDecoder.offset));
- var element = DataUtils.concatArrays(this.dataParts);
-#endif
if (self->usePartialData) {
// We have partial data from a previous call, so append this data and point to partialData.
if ((error = ndn_DynamicUCharArray_set(&self->partialData, data, self->structureDecoder.offset, self->partialDataLength)))
@@ -42,7 +38,7 @@
ndn_BinaryXmlStructureDecoder_init(&self->structureDecoder);
if (dataLength == 0)
// No more data in the packet.
- return 0;
+ return NDN_ERROR_success;
// else loop back to decode.
}
@@ -57,7 +53,7 @@
return error;
self->partialDataLength += dataLength;
- return 0;
+ return NDN_ERROR_success;
}
}
}
\ No newline at end of file
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.c b/ndn-cpp/c/encoding/binary-xml-encoder.c
index d245f19..5042c25 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.c
@@ -32,7 +32,7 @@
ndn_memcpy(self->output.array + self->offset, array, arrayLength);
self->offset += arrayLength;
- return 0;
+ return NDN_ERROR_success;
}
/**
@@ -106,7 +106,7 @@
break;
}
- return 0;
+ return NDN_ERROR_success;
}
/**
@@ -146,7 +146,7 @@
return error;
self->offset = startOffset + nHeaderBytes + nBufferBytes;
- return 0;
+ return NDN_ERROR_success;
}
/**
@@ -201,7 +201,7 @@
self->offset+= nEncodingBytes;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeElementClose(struct ndn_BinaryXmlEncoder *self)
@@ -213,7 +213,7 @@
self->output.array[self->offset] = ndn_BinaryXml_CLOSE;
self->offset += 1;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength)
@@ -225,7 +225,7 @@
if ((error = writeArray(self, value, valueLength)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
@@ -240,7 +240,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(self)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeUnsignedDecimalInt(struct ndn_BinaryXmlEncoder *self, unsigned int value)
@@ -255,7 +255,7 @@
if ((error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXml_UDATA)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeUnsignedDecimalIntDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned int value)
@@ -270,7 +270,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(self)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeAbsDoubleBigEndianBlob(struct ndn_BinaryXmlEncoder *self, double value)
@@ -312,7 +312,7 @@
if ((error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXml_BLOB)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_BinaryXmlEncoder_writeTimeMillisecondsDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, double milliseconds)
@@ -327,5 +327,5 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(self)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-interest.c b/ndn-cpp/c/encoding/binary-xml-interest.c
index 7c90a1b..b5c17a4 100644
--- a/ndn-cpp/c/encoding/binary-xml-interest.c
+++ b/ndn-cpp/c/encoding/binary-xml-interest.c
@@ -13,7 +13,7 @@
static ndn_Error encodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXmlEncoder *encoder)
{
if (exclude->nEntries == 0)
- return 0;
+ return NDN_ERROR_success;
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_Exclude)))
@@ -42,7 +42,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
static ndn_Error decodeExclude(struct ndn_Exclude *exclude, struct ndn_BinaryXmlDecoder *decoder)
@@ -116,7 +116,7 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_encodeBinaryXmlInterest(struct ndn_Interest *interest, struct ndn_BinaryXmlEncoder *encoder)
@@ -166,7 +166,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeBinaryXmlInterest(struct ndn_Interest *interest, struct ndn_BinaryXmlDecoder *decoder)
@@ -219,5 +219,5 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-key.c b/ndn-cpp/c/encoding/binary-xml-key.c
index 554c88d..4375c6c 100644
--- a/ndn-cpp/c/encoding/binary-xml-key.c
+++ b/ndn-cpp/c/encoding/binary-xml-key.c
@@ -11,7 +11,7 @@
ndn_Error ndn_encodeBinaryXmlKeyLocator(struct ndn_KeyLocator *keyLocator, struct ndn_BinaryXmlEncoder *encoder)
{
if (keyLocator->type < 0)
- return 0;
+ return NDN_ERROR_success;
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeElementStartDTag(encoder, ndn_BinaryXml_DTag_KeyLocator)))
@@ -36,7 +36,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeBinaryXmlKeyLocator(struct ndn_KeyLocator *keyLocator, struct ndn_BinaryXmlDecoder *decoder)
@@ -88,7 +88,7 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeOptionalBinaryXmlKeyLocator(struct ndn_KeyLocator *keyLocator, struct ndn_BinaryXmlDecoder *decoder)
@@ -104,5 +104,5 @@
else
ndn_KeyLocator_init(keyLocator);
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-name.c b/ndn-cpp/c/encoding/binary-xml-name.c
index 6437843..776965a 100644
--- a/ndn-cpp/c/encoding/binary-xml-name.c
+++ b/ndn-cpp/c/encoding/binary-xml-name.c
@@ -24,7 +24,7 @@
if ((error = ndn_BinaryXmlEncoder_writeElementClose(encoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeBinaryXmlName(struct ndn_Name *name, struct ndn_BinaryXmlDecoder *decoder)
@@ -58,5 +58,5 @@
if ((error = ndn_BinaryXmlDecoder_readElementClose(decoder)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c b/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
index fe9530a..bce4a79 100644
--- a/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
+++ b/ndn-cpp/c/encoding/binary-xml-publisher-public-key-digest.c
@@ -11,7 +11,7 @@
(struct ndn_PublisherPublicKeyDigest *publisherPublicKeyDigest, struct ndn_BinaryXmlEncoder *encoder)
{
if (!publisherPublicKeyDigest->publisherPublicKeyDigest || publisherPublicKeyDigest->publisherPublicKeyDigestLength == 0)
- return 0;
+ return NDN_ERROR_success;
ndn_Error error;
if ((error = ndn_BinaryXmlEncoder_writeBlobDTagElement
@@ -19,7 +19,7 @@
publisherPublicKeyDigest->publisherPublicKeyDigestLength)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeBinaryXmlPublisherPublicKeyDigest
@@ -31,7 +31,7 @@
&publisherPublicKeyDigest->publisherPublicKeyDigestLength)))
return error;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_decodeOptionalBinaryXmlPublisherPublicKeyDigest
@@ -50,5 +50,5 @@
publisherPublicKeyDigest->publisherPublicKeyDigestLength = 0;
}
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/encoding/binary-xml-structure-decoder.c b/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
index 2c114fe..6a3d417 100644
--- a/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
+++ b/ndn-cpp/c/encoding/binary-xml-structure-decoder.c
@@ -34,7 +34,7 @@
{
if (self->gotElementEnd)
// Someone is calling when we already got the end.
- return 0;
+ return NDN_ERROR_success;
struct ndn_BinaryXmlDecoder decoder;
ndn_BinaryXmlDecoder_init(&decoder, input, inputLength);
@@ -42,7 +42,7 @@
while (1) {
if (self->offset >= inputLength)
// All the cases assume we have some input. Return and wait for more.
- return 0;
+ return NDN_ERROR_success;
if (self->state == ndn_BinaryXmlStructureDecoder_READ_HEADER_OR_CLOSE) {
// First check for CLOSE.
@@ -53,7 +53,7 @@
if (self->level == 0) {
// Finished.
self->gotElementEnd = 1;
- return 0;
+ return NDN_ERROR_success;
}
if (self->level < 0)
return NDN_ERROR_findElementEnd_unexpected_close_tag;
@@ -73,7 +73,7 @@
unsigned int nNewBytes = self->headerLength - startingHeaderLength;
ndn_memcpy(self->headerBuffer + startingHeaderLength, input + (self->offset - nNewBytes), nNewBytes);
- return 0;
+ return NDN_ERROR_success;
}
unsigned int headerByte = (unsigned int)input[self->offset++];
++self->headerLength;
@@ -136,7 +136,7 @@
// Need more.
self->offset += nRemainingBytes;
self->nBytesToRead -= nRemainingBytes;
- return 0;
+ return NDN_ERROR_success;
}
// Got the bytes. Read a new header or close.
self->offset += self->nBytesToRead;
diff --git a/ndn-cpp/c/transport/socket-transport.c b/ndn-cpp/c/transport/socket-transport.c
index b4ded31..d48c794 100644
--- a/ndn-cpp/c/transport/socket-transport.c
+++ b/ndn-cpp/c/transport/socket-transport.c
@@ -62,7 +62,7 @@
freeaddrinfo(serverInfo);
self->socketDescriptor = socketDescriptor;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_SocketTransport_send(struct ndn_SocketTransport *self, unsigned char *data, unsigned int dataLength)
@@ -81,7 +81,7 @@
dataLength -= nBytes;
}
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_SocketTransport_receive
@@ -96,19 +96,19 @@
*nBytesOut = (unsigned int)nBytes;
- return 0;
+ return NDN_ERROR_success;
}
ndn_Error ndn_SocketTransport_close(struct ndn_SocketTransport *self)
{
if (self->socketDescriptor < 0)
// Already closed. Do nothing.
- return 0;
+ return NDN_ERROR_success;
if (close(self->socketDescriptor) != 0)
return NDN_ERROR_SocketTransport_error_in_close;
self->socketDescriptor = -1;
- return 0;
+ return NDN_ERROR_success;
}
diff --git a/ndn-cpp/c/util/dynamic-uchar-array.c b/ndn-cpp/c/util/dynamic-uchar-array.c
index c6a8f40..208544f 100644
--- a/ndn-cpp/c/util/dynamic-uchar-array.c
+++ b/ndn-cpp/c/util/dynamic-uchar-array.c
@@ -23,5 +23,5 @@
self->array = newArray;
self->length = newLength;
- return 0;
+ return NDN_ERROR_success;
}
\ No newline at end of file
diff --git a/ndn-cpp/c/util/dynamic-uchar-array.h b/ndn-cpp/c/util/dynamic-uchar-array.h
index ab5dca4..9543721 100644
--- a/ndn-cpp/c/util/dynamic-uchar-array.h
+++ b/ndn-cpp/c/util/dynamic-uchar-array.h
@@ -78,6 +78,7 @@
if ((error = ndn_DynamicUCharArray_ensureLength(self, valueLength + offset)))
return error;
ndn_memcpy(self->array + offset, value, valueLength);
+ return NDN_ERROR_success;
};
#ifdef __cplusplus