@@ -1022,8 +1022,9 @@ SEXP rnng_recv(SEXP socket, SEXP mode, SEXP block, SEXP keep) {
10221022 return mk_error (xc );
10231023 }
10241024 nng_msg * msgp = nng_aio_get_msg (aiop );
1025+ buf = nng_msg_body (msgp );
10251026 sz = nng_msg_len (msgp );
1026- res = nano_decode ((unsigned char * ) nng_msg_body ( msgp ) , sz , mod , kpr );
1027+ res = nano_decode ((unsigned char * ) buf , sz , mod , kpr );
10271028 nng_msg_free (msgp );
10281029 nng_aio_free (aiop );
10291030 }
@@ -1090,7 +1091,7 @@ SEXP rnng_ctx_recv(SEXP context, SEXP mode, SEXP timeout, SEXP keep) {
10901091 mode = rnng_matcharg (mode );
10911092 const int mod = * INTEGER (mode ), kpr = * LOGICAL (keep );
10921093 int xc ;
1093- unsigned char * buf ;
1094+ void * buf ;
10941095 size_t sz ;
10951096 SEXP res ;
10961097
@@ -1115,9 +1116,9 @@ SEXP rnng_ctx_recv(SEXP context, SEXP mode, SEXP timeout, SEXP keep) {
11151116 }
11161117
11171118 nng_msg * msgp = nng_aio_get_msg (aiop );
1118- buf = ( unsigned char * ) nng_msg_body (msgp );
1119+ buf = nng_msg_body (msgp );
11191120 sz = nng_msg_len (msgp );
1120- res = nano_decode (buf , sz , mod , kpr );
1121+ res = nano_decode (( unsigned char * ) buf , sz , mod , kpr );
11211122 nng_msg_free (msgp );
11221123 nng_aio_free (aiop );
11231124
@@ -1189,6 +1190,7 @@ SEXP rnng_stream_recv(SEXP stream, SEXP mode, SEXP timeout, SEXP keep, SEXP byte
11891190 const size_t xlen = (size_t ) Rf_asInteger (bytes );
11901191 nng_duration dur ;
11911192 int xc ;
1193+ size_t sz ;
11921194 nng_iov iov ;
11931195 nng_aio * aiop ;
11941196 SEXP res ;
@@ -1201,7 +1203,7 @@ SEXP rnng_stream_recv(SEXP stream, SEXP mode, SEXP timeout, SEXP keep, SEXP byte
12011203 }
12021204
12031205 iov .iov_len = xlen ;
1204- iov .iov_buf = ( unsigned char * ) R_Calloc (xlen , unsigned char );
1206+ iov .iov_buf = R_Calloc (xlen , unsigned char );
12051207
12061208 xc = nng_aio_alloc (& aiop , NULL , NULL );
12071209 if (xc ) {
@@ -1227,7 +1229,8 @@ SEXP rnng_stream_recv(SEXP stream, SEXP mode, SEXP timeout, SEXP keep, SEXP byte
12271229 return mk_error (xc );
12281230 }
12291231
1230- res = nano_decode (iov .iov_buf , nng_aio_count (aiop ), mod , kpr );
1232+ sz = nng_aio_count (aiop );
1233+ res = nano_decode ((unsigned char * ) iov .iov_buf , sz , mod , kpr );
12311234 nng_aio_free (aiop );
12321235 R_Free (iov .iov_buf );
12331236
0 commit comments