Basic C library for MQTT packet serialization and deserialization

Dependents:   MQTT MQTT MQTT MQTT ... more

Fork of MQTTPacket by MQTT

This library is part of the EclipseTM Paho project; specifically the embedded client.

A basic MQTT library in C for packet serialization and deserialization

Files at this revision

API Documentation at this revision

Comitter:
icraggs
Date:
Fri Aug 01 17:25:52 2014 +0000
Parent:
16:d0b3886ada32
Child:
18:bf36e077e7b8
Commit message:
Initializations to remove compiler warnings

Changed in this revision

MQTTConnectClient.c Show annotated file Show diff for this revision Revisions of this file
MQTTConnectServer.c Show annotated file Show diff for this revision Revisions of this file
MQTTDeserializePublish.c Show annotated file Show diff for this revision Revisions of this file
MQTTPacket.c Show annotated file Show diff for this revision Revisions of this file
MQTTSerializePublish.c Show annotated file Show diff for this revision Revisions of this file
MQTTSubscribeClient.c Show annotated file Show diff for this revision Revisions of this file
MQTTSubscribeServer.c Show annotated file Show diff for this revision Revisions of this file
MQTTUnsubscribeClient.c Show annotated file Show diff for this revision Revisions of this file
MQTTUnsubscribeServer.c Show annotated file Show diff for this revision Revisions of this file
--- a/MQTTConnectClient.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTConnectClient.c	Fri Aug 01 17:25:52 2014 +0000
@@ -58,8 +58,8 @@
 int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options)
 {
 	unsigned char *ptr = buf;
-	MQTTHeader header;
-	MQTTConnectFlags flags;
+	MQTTHeader header = {0};
+	MQTTConnectFlags flags = {0};
 	int len = 0;
 	int rc = -1;
 
@@ -131,12 +131,12 @@
   */
 int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = 0;
 	int mylen;
-	MQTTConnackFlags flags;
+	MQTTConnackFlags flags = {0};
 
 	FUNC_ENTRY;
 	header.byte = readChar(&curdata);
@@ -169,7 +169,7 @@
   */
 int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rc = -1;
 	unsigned char *ptr = buf;
 
--- a/MQTTConnectServer.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTConnectServer.c	Fri Aug 01 17:25:52 2014 +0000
@@ -50,8 +50,8 @@
   */
 int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len)
 {
-	MQTTHeader header;
-	MQTTConnectFlags flags;
+	MQTTHeader header = {0};
+	MQTTConnectFlags flags = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = &buf[len];
 	int rc = 0;
@@ -118,10 +118,10 @@
   */
 int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rc = 0;
 	unsigned char *ptr = buf;
-	MQTTConnackFlags flags;
+	MQTTConnackFlags flags = {0};
 
 	FUNC_ENTRY;
 	if (buflen < 2)
--- a/MQTTDeserializePublish.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTDeserializePublish.c	Fri Aug 01 17:25:52 2014 +0000
@@ -36,7 +36,7 @@
 int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
 		unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = 0;
@@ -81,7 +81,7 @@
   */
 int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = 0;
--- a/MQTTPacket.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTPacket.c	Fri Aug 01 17:25:52 2014 +0000
@@ -288,7 +288,7 @@
 int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int))
 {
 	int rc = -1;
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int len = 0;
 	int rem_len = 0;
 
--- a/MQTTSerializePublish.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTSerializePublish.c	Fri Aug 01 17:25:52 2014 +0000
@@ -55,7 +55,7 @@
 		MQTTString topicName, unsigned char* payload, int payloadlen)
 {
 	unsigned char *ptr = buf;
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rem_len = 0;
 	int rc = 0;
 
@@ -102,7 +102,7 @@
   */
 int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rc = 0;
 	unsigned char *ptr = buf;
 
--- a/MQTTSubscribeClient.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTSubscribeClient.c	Fri Aug 01 17:25:52 2014 +0000
@@ -51,7 +51,7 @@
 		MQTTString topicFilters[], int requestedQoSs[])
 {
 	unsigned char *ptr = buf;
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rem_len = 0;
 	int rc = 0;
 	int i = 0;
@@ -99,7 +99,7 @@
   */
 int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = 0;
--- a/MQTTSubscribeServer.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTSubscribeServer.c	Fri Aug 01 17:25:52 2014 +0000
@@ -35,7 +35,7 @@
 int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
 	int requestedQoSs[], unsigned char* buf, int buflen)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = -1;
@@ -81,7 +81,7 @@
   */
 int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rc = -1;
 	unsigned char *ptr = buf;
 	int i;
--- a/MQTTUnsubscribeClient.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTUnsubscribeClient.c	Fri Aug 01 17:25:52 2014 +0000
@@ -50,7 +50,7 @@
 		int count, MQTTString topicFilters[])
 {
 	unsigned char *ptr = buf;
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rem_len = 0;
 	int rc = -1;
 	int i = 0;
--- a/MQTTUnsubscribeServer.c	Fri Aug 01 16:58:18 2014 +0000
+++ b/MQTTUnsubscribeServer.c	Fri Aug 01 17:25:52 2014 +0000
@@ -34,7 +34,7 @@
 int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
 		unsigned char* buf, int len)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	unsigned char* curdata = buf;
 	unsigned char* enddata = NULL;
 	int rc = 0;
@@ -75,7 +75,7 @@
   */
 int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid)
 {
-	MQTTHeader header;
+	MQTTHeader header = {0};
 	int rc = 0;
 	unsigned char *ptr = buf;