Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
79a776d6
Commit
79a776d6
authored
Jul 06, 2018
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some lint changes for lgtm report
parent
275fee94
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
35 deletions
+27
-35
Heap.c
src/Heap.c
+6
-6
MQTTAsync.h
src/MQTTAsync.h
+5
-7
MQTTClient.c
src/MQTTClient.c
+9
-17
MQTTClient.h
src/MQTTClient.h
+5
-3
Socket.c
src/Socket.c
+2
-2
No files found.
src/Heap.c
View file @
79a776d6
...
@@ -196,7 +196,7 @@ void* mymalloc(char* file, int line, size_t size)
...
@@ -196,7 +196,7 @@ void* mymalloc(char* file, int line, size_t size)
space
+=
size
+
2
*
sizeof
(
int
);
space
+=
size
+
2
*
sizeof
(
int
);
*
(
int
*
)(
s
->
ptr
)
=
eyecatcher
;
/* start eyecatcher */
*
(
int
*
)(
s
->
ptr
)
=
eyecatcher
;
/* start eyecatcher */
*
(
int
*
)(((
char
*
)(
s
->
ptr
))
+
(
sizeof
(
int
)
+
size
))
=
eyecatcher
;
/* end 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
);
TreeAdd
(
&
heap
,
s
,
space
);
state
.
current_size
+=
size
;
state
.
current_size
+=
size
;
if
(
state
.
current_size
>
state
.
max_size
)
if
(
state
.
current_size
>
state
.
max_size
)
...
@@ -241,7 +241,7 @@ static int Internal_heap_unlink(char* file, int line, void* p)
...
@@ -241,7 +241,7 @@ static int Internal_heap_unlink(char* file, int line, void* p)
{
{
storageElement
*
s
=
(
storageElement
*
)(
e
->
content
);
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
"
,
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
);
checkEyecatchers
(
file
,
line
,
p
,
s
->
size
);
/* free(s->ptr); */
/* free(s->ptr); */
free
(
s
->
file
);
free
(
s
->
file
);
...
@@ -371,12 +371,12 @@ static void HeapScan(enum LOG_LEVELS log_level)
...
@@ -371,12 +371,12 @@ static void HeapScan(enum LOG_LEVELS log_level)
Node
*
current
=
NULL
;
Node
*
current
=
NULL
;
Thread_lock_mutex
(
heap_mutex
);
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
)
while
((
current
=
TreeNextElement
(
&
heap
,
current
))
!=
NULL
)
{
{
storageElement
*
s
=
(
storageElement
*
)(
current
->
content
);
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
,
"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
)
?
s
->
size
:
10
,
(
char
*
)(((
int
*
)
s
->
ptr
)
+
1
));
Log
(
log_level
,
-
1
,
" Content %.*s"
,
(
10
>
current
->
size
)
?
(
int
)
s
->
size
:
10
,
(
char
*
)(((
int
*
)
s
->
ptr
)
+
1
));
#if defined(HEAP_STACK)
#if defined(HEAP_STACK)
Log
(
log_level
,
-
1
,
" Stack:
\n
%s"
,
s
->
stack
);
Log
(
log_level
,
-
1
,
" Stack:
\n
%s"
,
s
->
stack
);
#endif
#endif
...
@@ -402,7 +402,7 @@ int Heap_initialize(void)
...
@@ -402,7 +402,7 @@ int Heap_initialize(void)
*/
*/
void
Heap_terminate
(
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 */
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"
);
Log
(
LOG_ERROR
,
-
1
,
"Some memory not freed at shutdown, possible memory leak"
);
...
...
src/MQTTAsync.h
View file @
79a776d6
...
@@ -82,17 +82,16 @@
...
@@ -82,17 +82,16 @@
* @endcond
* @endcond
*/
*/
/*
/*
/// @cond EXCLUDE
/// @cond EXCLUDE
*/
*/
#if !defined(MQTTASYNC_H)
#define MQTTASYNC_H
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
{
extern
"C"
{
#endif
#endif
#if !defined(MQTTASYNC_H)
#define MQTTASYNC_H
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#define DLLExport __declspec(dllexport)
...
@@ -1944,9 +1943,8 @@ exit:
...
@@ -1944,9 +1943,8 @@ exit:
* @endcond
* @endcond
*/
*/
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
src/MQTTClient.c
View file @
79a776d6
...
@@ -177,7 +177,7 @@ void MQTTClient_init(void)
...
@@ -177,7 +177,7 @@ void MQTTClient_init(void)
#define WINAPI
#define WINAPI
#endif
#endif
static
volatile
int
initialized
=
0
;
static
volatile
int
library_
initialized
=
0
;
static
List
*
handles
=
NULL
;
static
List
*
handles
=
NULL
;
static
int
running
=
0
;
static
int
running
=
0
;
static
int
tostop
=
0
;
static
int
tostop
=
0
;
...
@@ -373,7 +373,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
...
@@ -373,7 +373,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
goto
exit
;
goto
exit
;
}
}
if
(
!
initialized
)
if
(
!
library_
initialized
)
{
{
#if defined(HEAP_H)
#if defined(HEAP_H)
Heap_initialize
();
Heap_initialize
();
...
@@ -386,7 +386,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
...
@@ -386,7 +386,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
#if defined(OPENSSL)
#if defined(OPENSSL)
SSLSocket_initialize
();
SSLSocket_initialize
();
#endif
#endif
initialized
=
1
;
library_
initialized
=
1
;
}
}
m
=
malloc
(
sizeof
(
MQTTClients
));
m
=
malloc
(
sizeof
(
MQTTClients
));
...
@@ -466,7 +466,7 @@ static void MQTTClient_terminate(void)
...
@@ -466,7 +466,7 @@ static void MQTTClient_terminate(void)
{
{
FUNC_ENTRY
;
FUNC_ENTRY
;
MQTTClient_stop
();
MQTTClient_stop
();
if
(
initialized
)
if
(
library_
initialized
)
{
{
ListFree
(
bstate
->
clients
);
ListFree
(
bstate
->
clients
);
ListFree
(
handles
);
ListFree
(
handles
);
...
@@ -476,7 +476,7 @@ static void MQTTClient_terminate(void)
...
@@ -476,7 +476,7 @@ static void MQTTClient_terminate(void)
Heap_terminate
();
Heap_terminate
();
#endif
#endif
Log_terminate
();
Log_terminate
();
initialized
=
0
;
library_
initialized
=
0
;
}
}
FUNC_EXIT
;
FUNC_EXIT
;
}
}
...
@@ -1678,14 +1678,6 @@ static int MQTTClient_disconnect1(MQTTClient handle, int timeout, int call_conne
...
@@ -1678,14 +1678,6 @@ static int MQTTClient_disconnect1(MQTTClient handle, int timeout, int call_conne
MQTTClient_closeSession
(
m
->
c
,
reason
,
props
);
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:
exit:
if
(
stop
)
if
(
stop
)
MQTTClient_stop
();
MQTTClient_stop
();
...
@@ -1835,11 +1827,11 @@ MQTTResponse MQTTClient_subscribeMany5(MQTTClient handle, int count, char* const
...
@@ -1835,11 +1827,11 @@ MQTTResponse MQTTClient_subscribeMany5(MQTTClient handle, int count, char* const
if
(
sub
->
qoss
->
count
>
1
)
if
(
sub
->
qoss
->
count
>
1
)
{
{
ListElement
*
current
=
NULL
;
ListElement
*
current
=
NULL
;
int
count
=
0
;
int
rc_
count
=
0
;
resp
.
reasonCodes
=
malloc
(
sizeof
(
enum
MQTTReasonCodes
)
*
(
sub
->
qoss
->
count
));
resp
.
reasonCodes
=
malloc
(
sizeof
(
enum
MQTTReasonCodes
)
*
(
sub
->
qoss
->
count
));
while
(
ListNextElement
(
sub
->
qoss
,
&
current
))
while
(
ListNextElement
(
sub
->
qoss
,
&
current
))
(
resp
.
reasonCodes
)[
count
++
]
=
*
(
enum
MQTTReasonCodes
*
)(
current
->
content
);
(
resp
.
reasonCodes
)[
rc_
count
++
]
=
*
(
enum
MQTTReasonCodes
*
)(
current
->
content
);
}
}
}
}
else
else
...
@@ -1987,11 +1979,11 @@ MQTTResponse MQTTClient_unsubscribeMany5(MQTTClient handle, int count, char* con
...
@@ -1987,11 +1979,11 @@ MQTTResponse MQTTClient_unsubscribeMany5(MQTTClient handle, int count, char* con
if
(
unsub
->
reasonCodes
->
count
>
1
)
if
(
unsub
->
reasonCodes
->
count
>
1
)
{
{
ListElement
*
current
=
NULL
;
ListElement
*
current
=
NULL
;
int
count
=
0
;
int
rc_
count
=
0
;
resp
.
reasonCodes
=
malloc
(
sizeof
(
enum
MQTTReasonCodes
)
*
(
unsub
->
reasonCodes
->
count
));
resp
.
reasonCodes
=
malloc
(
sizeof
(
enum
MQTTReasonCodes
)
*
(
unsub
->
reasonCodes
->
count
));
while
(
ListNextElement
(
unsub
->
reasonCodes
,
&
current
))
while
(
ListNextElement
(
unsub
->
reasonCodes
,
&
current
))
(
resp
.
reasonCodes
)[
count
++
]
=
*
(
enum
MQTTReasonCodes
*
)(
current
->
content
);
(
resp
.
reasonCodes
)[
rc_
count
++
]
=
*
(
enum
MQTTReasonCodes
*
)(
current
->
content
);
}
}
}
}
else
else
...
...
src/MQTTClient.h
View file @
79a776d6
...
@@ -103,11 +103,12 @@
...
@@ -103,11 +103,12 @@
/*
/*
/// @cond EXCLUDE
/// @cond EXCLUDE
*/
*/
#if !defined(MQTTCLIENT_H)
#define MQTTCLIENT_H
#if defined(__cplusplus)
#if defined(__cplusplus)
extern
"C"
{
extern
"C"
{
#endif
#endif
#if !defined(MQTTCLIENT_H)
#define MQTTCLIENT_H
#if defined(WIN32) || defined(WIN64)
#if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport)
#define DLLImport __declspec(dllimport)
...
@@ -1158,11 +1159,12 @@ DLLExport void MQTTClient_setTraceCallback(MQTTClient_traceCallback* callback);
...
@@ -1158,11 +1159,12 @@ DLLExport void MQTTClient_setTraceCallback(MQTTClient_traceCallback* callback);
*/
*/
DLLExport
const
char
*
MQTTClient_strerror
(
int
code
);
DLLExport
const
char
*
MQTTClient_strerror
(
int
code
);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/**
/**
* @cond MQTTClient_main
* @cond MQTTClient_main
* @page async Asynchronous vs synchronous client applications
* @page async Asynchronous vs synchronous client applications
...
...
src/Socket.c
View file @
79a776d6
...
@@ -391,7 +391,7 @@ char *Socket_getdata(int socket, size_t bytes, size_t* actual_len)
...
@@ -391,7 +391,7 @@ char *Socket_getdata(int socket, size_t bytes, size_t* actual_len)
else
/* we didn't read the whole packet */
else
/* we didn't read the whole packet */
{
{
SocketBuffer_interrupted
(
socket
,
*
actual_len
);
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:
exit:
FUNC_EXIT
;
FUNC_EXIT
;
...
@@ -527,7 +527,7 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
...
@@ -527,7 +527,7 @@ int Socket_putdatas(int socket, char* buf0, size_t buf0len, int count, char** bu
else
else
{
{
int
*
sockmem
=
(
int
*
)
malloc
(
sizeof
(
int
));
int
*
sockmem
=
(
int
*
)
malloc
(
sizeof
(
int
));
Log
(
TRACE_MIN
,
-
1
,
"Partial write: %l
d
bytes of %d actually written on socket %d"
,
Log
(
TRACE_MIN
,
-
1
,
"Partial write: %l
u
bytes of %d actually written on socket %d"
,
bytes
,
total
,
socket
);
bytes
,
total
,
socket
);
#if defined(OPENSSL)
#if defined(OPENSSL)
SocketBuffer_pendingWrite
(
socket
,
NULL
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
SocketBuffer_pendingWrite
(
socket
,
NULL
,
count
+
1
,
iovecs
,
frees1
,
total
,
bytes
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment