diff options
| -rw-r--r-- | src/client.c | 5 | ||||
| -rw-r--r-- | src/deserialize.c | 2 | ||||
| -rw-r--r-- | src/misc.c | 2 | ||||
| -rw-r--r-- | src/serialize.c | 2 | ||||
| -rw-r--r-- | src/socketstream.c | 6 | ||||
| -rw-r--r-- | src/stream.c | 5 | ||||
| -rw-r--r-- | src/stringbuf.c | 6 |
7 files changed, 15 insertions, 13 deletions
diff --git a/src/client.c b/src/client.c index aaebad3..09d8455 100644 --- a/src/client.c +++ b/src/client.c @@ -342,8 +342,8 @@ int MqttClientRunOnce(MqttClient *client) FD_SET(client->stream.sock, &wfd); } - // TODO: break select when queuing packets (need to protect queue with mutex - // to allow queuing packets from another thread) + /* TODO: break select when queuing packets (need to protect queue with + mutex to allow queuing packets from another thread) */ memset(&tv, 0, sizeof(tv)); tv.tv_sec = client->keepAlive; @@ -749,7 +749,6 @@ static void MqttClientHandlePublish(MqttClient *client, MqttPacketPublish *packe if (pubRec) { LOG_DEBUG("resending PUBREC id:%d", MqttPacketId(packet)); - // MqttPacketWithId *pubRec = (MqttPacketWithId *) pubRecNode->packet; MqttClientQueuePacket(client, pubRec); MqttPacketFree((MqttPacket *) packet); return; diff --git a/src/deserialize.c b/src/deserialize.c index 19be4ce..0c9d7b0 100644 --- a/src/deserialize.c +++ b/src/deserialize.c @@ -50,7 +50,7 @@ static int MqttPacketSubAckDeserialize(MqttPacketSubAck **packet, Stream *stream if (StreamReadRemainingLength(&remainingLength, stream) == -1) return -1; - // 2 bytes for packet id and 1 byte for single return code + /* 2 bytes for packet id and 1 byte for single return code */ if (remainingLength != 3) return -1; @@ -17,7 +17,7 @@ int64_t GetCurrentTime() } #endif -// https://gist.github.com/ccbrown/9722406 +/* https://gist.github.com/ccbrown/9722406 */ void DumpHex(const void* data, size_t size) { char ascii[17]; size_t i, j; diff --git a/src/serialize.c b/src/serialize.c index d14cf03..1fa9c8b 100644 --- a/src/serialize.c +++ b/src/serialize.c @@ -55,7 +55,7 @@ static size_t MqttPacketPublishGetRemainingLength(const MqttPacketPublish *packe remainingLength += MqttStringLengthSerialized(&packet->topicName); - // Packet id + /* Packet id */ if (MqttPacketPublishQos(packet) == 1 || MqttPacketPublishQos(packet) == 2) { remainingLength += 2; diff --git a/src/socketstream.c b/src/socketstream.c index 3bcc411..bef1803 100644 --- a/src/socketstream.c +++ b/src/socketstream.c @@ -5,7 +5,7 @@ #include <arpa/inet.h> -// close +/* close */ #include <unistd.h> static int SocketStreamClose(Stream *base) @@ -27,10 +27,10 @@ static int64_t SocketStreamRead(void *ptr, size_t size, Stream *stream) { char *p = ((char *) ptr) + received; ssize_t rv = recv(ss->sock, p, size - received, 0); - // Error + /* Error */ if (rv == -1) return -1; - // TODO: Closed? + /* TODO: Closed? */ if (rv == 0) break; received += (size_t) rv; diff --git a/src/stream.c b/src/stream.c index 5296501..97a8a2d 100644 --- a/src/stream.c +++ b/src/stream.c @@ -6,7 +6,7 @@ #include <assert.h> #include <errno.h> -// htons, ntohs +/* htons, ntohs */ #include <arpa/inet.h> #define STREAM_CHECK_OP(stream, op) \ @@ -27,8 +27,9 @@ int StreamClose(Stream *stream) int64_t StreamRead(void *ptr, size_t size, Stream *stream) { + int64_t rv; STREAM_CHECK_OP(stream, read); - int64_t rv = stream->ops->read(ptr, size, stream); + rv = stream->ops->read(ptr, size, stream); #if defined(STREAM_HEXDUMP_READ) if (rv >= 0) { diff --git a/src/stringbuf.c b/src/stringbuf.c index bc71dc3..1c250ca 100644 --- a/src/stringbuf.c +++ b/src/stringbuf.c @@ -45,9 +45,11 @@ size_t StringBufAvailable(StringBuf *buf) int StringBufGrow(StringBuf *buf, size_t size) { + size_t newSize; + char *ptr; assert(buf != NULL); - size_t newSize = buf->size + size; - char *ptr = realloc(buf->data, newSize+1); + newSize = buf->size + size; + ptr = realloc(buf->data, newSize+1); if (!ptr) return -1; buf->data = ptr; |
