Commit 79a776d6 authored by Ian Craggs's avatar Ian Craggs

Some lint changes for lgtm report

parent 275fee94
......@@ -196,7 +196,7 @@ void* mymalloc(char* file, int line, size_t size)
space += size + 2*sizeof(int);
*(int*)(s->ptr) = eyecatcher; /* start eyecatcher */
*(int*)(((char*)(s->ptr)) + (sizeof(int) + size)) = eyecatcher; /* end eyecatcher */
Log(TRACE_MAX, -1, "Allocating %d bytes in heap at file %s line %d ptr %p\n", size, file, line, s->ptr);
Log(TRACE_MAX, -1, "Allocating %d bytes in heap at file %s line %d ptr %p\n", (int)size, file, line, s->ptr);
TreeAdd(&heap, s, space);
state.current_size += size;
if (state.current_size > state.max_size)
......@@ -241,7 +241,7 @@ static int Internal_heap_unlink(char* file, int line, void* p)
{
storageElement* s = (storageElement*)(e->content);
Log(TRACE_MAX, -1, "Freeing %d bytes in heap at file %s line %d, heap use now %d bytes\n",
s->size, file, line, state.current_size);
(int)s->size, file, line, state.current_size);
checkEyecatchers(file, line, p, s->size);
/* free(s->ptr); */
free(s->file);
......@@ -371,12 +371,12 @@ static void HeapScan(enum LOG_LEVELS log_level)
Node* current = NULL;
Thread_lock_mutex(heap_mutex);
Log(log_level, -1, "Heap scan start, total %d bytes", state.current_size);
Log(log_level, -1, "Heap scan start, total %d bytes", (int)state.current_size);
while ((current = TreeNextElement(&heap, current)) != NULL)
{
storageElement* s = (storageElement*)(current->content);
Log(log_level, -1, "Heap element size %d, line %d, file %s, ptr %p", s->size, s->line, s->file, s->ptr);
Log(log_level, -1, " Content %.*s", (10 > current->size) ? s->size : 10, (char*)(((int*)s->ptr) + 1));
Log(log_level, -1, "Heap element size %d, line %d, file %s, ptr %p", (int)s->size, s->line, s->file, s->ptr);
Log(log_level, -1, " Content %.*s", (10 > current->size) ? (int)s->size : 10, (char*)(((int*)s->ptr) + 1));
#if defined(HEAP_STACK)
Log(log_level, -1, " Stack:\n%s", s->stack);
#endif
......@@ -402,7 +402,7 @@ int Heap_initialize(void)
*/
void Heap_terminate(void)
{
Log(TRACE_MIN, -1, "Maximum heap use was %d bytes", state.max_size);
Log(TRACE_MIN, -1, "Maximum heap use was %d bytes", (int)state.max_size);
if (state.current_size > 20) /* One log list is freed after this function is called */
{
Log(LOG_ERROR, -1, "Some memory not freed at shutdown, possible memory leak");
......
......@@ -82,17 +82,16 @@
* @endcond
*/
/*
/// @cond EXCLUDE
*/
#if !defined(MQTTASYNC_H)
#define MQTTASYNC_H
#if defined(__cplusplus)
extern "C" {
#endif
#if !defined(MQTTASYNC_H)
#define MQTTASYNC_H
#if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
......@@ -1944,9 +1943,8 @@ exit:
* @endcond
*/
#endif
#ifdef __cplusplus
}
#endif
#endif
......@@ -177,7 +177,7 @@ void MQTTClient_init(void)
#define WINAPI
#endif
static volatile int initialized = 0;
static volatile int library_initialized = 0;
static List* handles = NULL;
static int running = 0;
static int tostop = 0;
......@@ -373,7 +373,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
goto exit;
}
if (!initialized)
if (!library_initialized)
{
#if defined(HEAP_H)
Heap_initialize();
......@@ -386,7 +386,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
#if defined(OPENSSL)
SSLSocket_initialize();
#endif
initialized = 1;
library_initialized = 1;
}
m = malloc(sizeof(MQTTClients));
......@@ -466,7 +466,7 @@ static void MQTTClient_terminate(void)
{
FUNC_ENTRY;
MQTTClient_stop();
if (initialized)
if (library_initialized)
{
ListFree(bstate->clients);
ListFree(handles);
......@@ -476,7 +476,7 @@ static void MQTTClient_terminate(void)
Heap_terminate();
#endif
Log_terminate();
initialized = 0;
library_initialized = 0;
}
FUNC_EXIT;
}
......@@ -1678,14 +1678,6 @@ static int MQTTClient_disconnect1(MQTTClient handle, int timeout, int call_conne
MQTTClient_closeSession(m->c, reason, props);
/*while (Thread_wait_sem(m->connect_sem, 100))
;
while (Thread_wait_sem(m->connack_sem, 100))
;
while (Thread_wait_sem(m->suback_sem, 100))
;
while (Thread_wait_sem(m->unsuback_sem, 100))
;*/
exit:
if (stop)
MQTTClient_stop();
......@@ -1835,11 +1827,11 @@ MQTTResponse MQTTClient_subscribeMany5(MQTTClient handle, int count, char* const
if (sub->qoss->count > 1)
{
ListElement* current = NULL;
int count = 0;
int rc_count = 0;
resp.reasonCodes = malloc(sizeof(enum MQTTReasonCodes) * (sub->qoss->count));
while (ListNextElement(sub->qoss, &current))
(resp.reasonCodes)[count++] = *(enum MQTTReasonCodes*)(current->content);
(resp.reasonCodes)[rc_count++] = *(enum MQTTReasonCodes*)(current->content);
}
}
else
......@@ -1987,11 +1979,11 @@ MQTTResponse MQTTClient_unsubscribeMany5(MQTTClient handle, int count, char* con
if (unsub->reasonCodes->count > 1)
{
ListElement* current = NULL;
int count = 0;
int rc_count = 0;
resp.reasonCodes = malloc(sizeof(enum MQTTReasonCodes) * (unsub->reasonCodes->count));
while (ListNextElement(unsub->reasonCodes, &current))
(resp.reasonCodes)[count++] = *(enum MQTTReasonCodes*)(current->content);
(resp.reasonCodes)[rc_count++] = *(enum MQTTReasonCodes*)(current->content);
}
}
else
......
......@@ -103,11 +103,12 @@
/*
/// @cond EXCLUDE
*/
#if !defined(MQTTCLIENT_H)
#define MQTTCLIENT_H
#if defined(__cplusplus)
extern "C" {
#endif
#if !defined(MQTTCLIENT_H)
#define MQTTCLIENT_H
#if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
......@@ -1158,11 +1159,12 @@ DLLExport void MQTTClient_setTraceCallback(MQTTClient_traceCallback* callback);
*/
DLLExport const char* MQTTClient_strerror(int code);
#endif
#ifdef __cplusplus
}
#endif
#endif
/**
* @cond MQTTClient_main
* @page async Asynchronous vs synchronous client applications
......
......@@ -391,7 +391,7 @@ char *Socket_getdata(int socket, size_t bytes, size_t* actual_len)
else /* we didn't read the whole packet */
{
SocketBuffer_interrupted(socket, *actual_len);
Log(TRACE_MAX, -1, "%d bytes expected but %d bytes now received", bytes, *actual_len);
Log(TRACE_MAX, -1, "%d bytes expected but %d bytes now received", (int)bytes, (int)*actual_len);
}
exit:
FUNC_EXIT;
......@@ -527,7 +527,7 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
else
{
int* sockmem = (int*)malloc(sizeof(int));
Log(TRACE_MIN, -1, "Partial write: %ld bytes of %d actually written on socket %d",
Log(TRACE_MIN, -1, "Partial write: %lu bytes of %d actually written on socket %d",
bytes, total, socket);
#if defined(OPENSSL)
SocketBuffer_pendingWrite(socket, NULL, count+1, iovecs, frees1, total, bytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment