Code Review
/
ric-plt
/
lib
/
rmr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Re-enable RMR libary's module tests
[ric-plt/lib/rmr.git]
/
src
/
rmr
/
common
/
src
/
mbuf_api.c
diff --git
a/src/rmr/common/src/mbuf_api.c
b/src/rmr/common/src/mbuf_api.c
index
029dd74
..
6abcf8b
100644
(file)
--- a/
src/rmr/common/src/mbuf_api.c
+++ b/
src/rmr/common/src/mbuf_api.c
@@
-40,6
+40,10
@@
#include "rmr.h" // things the users see
#include "rmr_agnostic.h" // agnostic things (must be included before private)
#include "rmr.h" // things the users see
#include "rmr_agnostic.h" // agnostic things (must be included before private)
+#include "rmr_logging.h"
+
+//#define BUF_TOOLS_ONLY 1
+#include "tools_static.c"
// ---------- some wrappers need explicit copy-in functions, also header field setters -----
// ---------- some wrappers need explicit copy-in functions, also header field setters -----
@@
-105,7
+109,7
@@
extern int rmr_str2meid( rmr_mbuf_t* mbuf, unsigned char const* str ) {
}
errno = 0;
}
errno = 0;
- if( (len = strlen( (char
*) str )) > RMR_MAX_MEID-1 ) {
+ if( (len = strlen( (char
const *) str )) > (size_t) (RMR_MAX_MEID-1) ) { // cast keep sonar from twisting its knickers
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
@@
-144,7
+148,7
@@
extern void rmr_bytes2payload( rmr_mbuf_t* mbuf, unsigned char const* src, int l
is set to the string length.
*/
extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str ) {
is set to the string length.
*/
extern void rmr_str2payload( rmr_mbuf_t* mbuf, unsigned char const* str ) {
- rmr_bytes2payload( mbuf, str, strlen( (char *) str ) + 1 );
+ rmr_bytes2payload( mbuf, str, strlen( (char
const
*) str ) + 1 );
}
}
@@
-196,7
+200,7
@@
extern int rmr_str2xact( rmr_mbuf_t* mbuf, unsigned char const* str ) {
}
errno = 0;
}
errno = 0;
- if( (len = strlen( (char *) str )) > RMR_MAX_XID-1 ) {
+ if( (len = strlen( (char
const
*) str )) > RMR_MAX_XID-1 ) {
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
errno = EOVERFLOW;
return RMR_ERR_OVERFLOW;
}
@@
-280,6
+284,10
@@
extern unsigned char* rmr_get_meid( rmr_mbuf_t* mbuf, unsigned char* dest ) {
The return value is the number of bytes actually coppied. If 0 bytes are coppied
errno should indicate the reason. If 0 is returned and errno is 0, then size
passed was 0. The state in the message is left UNCHANGED.
The return value is the number of bytes actually coppied. If 0 bytes are coppied
errno should indicate the reason. If 0 is returned and errno is 0, then size
passed was 0. The state in the message is left UNCHANGED.
+
+ Regardless of action taken (actual realloc or not) the caller's reference to mbuf
+ is still valid follwing the call and will point to the correct spot (same tp
+ buffer if no realloc needed, or the new one if there was).
*/
extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size ) {
uta_mhdr_t* hdr;
*/
extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size ) {
uta_mhdr_t* hdr;
@@
-308,7
+316,7
@@
extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size )
if( len != size ) { // different sized trace data, must realloc the buffer
nm = rmr_realloc_msg( msg, size ); // realloc with changed trace size
if( len != size ) { // different sized trace data, must realloc the buffer
nm = rmr_realloc_msg( msg, size ); // realloc with changed trace size
- old_tp_buf = msg->tp_buf;
+ old_tp_buf = msg->tp_buf;
// hold to repoint new mbuf at small buffer
old_hdr = msg->header;
msg->tp_buf = nm->tp_buf; // reference the reallocated buffer
old_hdr = msg->header;
msg->tp_buf = nm->tp_buf; // reference the reallocated buffer
@@
-317,7
+325,7
@@
extern int rmr_set_trace( rmr_mbuf_t* msg, unsigned const char* data, int size )
msg->xaction = nm->xaction;
msg->payload = nm->payload;
msg->xaction = nm->xaction;
msg->payload = nm->payload;
- nm->tp_buf = old_tp_buf; // set to free
+ nm->tp_buf = old_tp_buf; // set to free
; point to the small buffer
nm->header = old_hdr; // nano frees on hdr, so must set both
rmr_free_msg( nm );
nm->header = old_hdr; // nano frees on hdr, so must set both
rmr_free_msg( nm );
@@
-429,7
+437,7
@@
extern unsigned char* rmr_get_src( rmr_mbuf_t* msg, unsigned char* dest ) {
if( dest != NULL ) {
hdr = msg->header;
if( dest != NULL ) {
hdr = msg->header;
-
strncpy
( dest, hdr->src, RMR_MAX_SRC );
+
zt_buf_fill
( dest, hdr->src, RMR_MAX_SRC );
}
return dest;
}
return dest;
@@
-453,11
+461,11
@@
extern unsigned char* rmr_get_srcip( rmr_mbuf_t* msg, unsigned char* dest ) {
hdr = msg->header;
if( HDR_VERSION( msg->header ) > 2 ) { // src ip was not present in hdr until ver 3
errno = 0;
hdr = msg->header;
if( HDR_VERSION( msg->header ) > 2 ) { // src ip was not present in hdr until ver 3
errno = 0;
-
strncpy
( dest, hdr->srcip, RMR_MAX_SRC );
+
zt_buf_fill
( dest, hdr->srcip, RMR_MAX_SRC );
rstr = dest;
} else {
errno = 0;
rstr = dest;
} else {
errno = 0;
-
strncpy( dest, hdr->src, RMR_MAX_SRC );
// reutrn the name:port for old messages
+
zt_buf_fill( dest, hdr->src, RMR_MAX_SRC );
// reutrn the name:port for old messages
rstr = dest;
}
}
rstr = dest;
}
}