mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
@@ -115,7 +115,7 @@ rball_init(struct read_block * rb, char * buffer, int size) {
|
|||||||
rb->ptr = 0;
|
rb->ptr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static const void *
|
||||||
rb_read(struct read_block *rb, int sz) {
|
rb_read(struct read_block *rb, int sz) {
|
||||||
if (rb->len < sz) {
|
if (rb->len < sz) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -363,7 +363,7 @@ get_integer(lua_State *L, struct read_block *rb, int cookie) {
|
|||||||
return 0;
|
return 0;
|
||||||
case TYPE_NUMBER_BYTE: {
|
case TYPE_NUMBER_BYTE: {
|
||||||
uint8_t n;
|
uint8_t n;
|
||||||
uint8_t * pn = rb_read(rb,sizeof(n));
|
const uint8_t * pn = (const uint8_t *)rb_read(rb,sizeof(n));
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
n = *pn;
|
n = *pn;
|
||||||
@@ -371,7 +371,7 @@ get_integer(lua_State *L, struct read_block *rb, int cookie) {
|
|||||||
}
|
}
|
||||||
case TYPE_NUMBER_WORD: {
|
case TYPE_NUMBER_WORD: {
|
||||||
uint16_t n;
|
uint16_t n;
|
||||||
uint16_t * pn = rb_read(rb,sizeof(n));
|
const void * pn = rb_read(rb,sizeof(n));
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
memcpy(&n, pn, sizeof(n));
|
memcpy(&n, pn, sizeof(n));
|
||||||
@@ -379,7 +379,7 @@ get_integer(lua_State *L, struct read_block *rb, int cookie) {
|
|||||||
}
|
}
|
||||||
case TYPE_NUMBER_DWORD: {
|
case TYPE_NUMBER_DWORD: {
|
||||||
int32_t n;
|
int32_t n;
|
||||||
int32_t * pn = rb_read(rb,sizeof(n));
|
const void * pn = rb_read(rb,sizeof(n));
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
memcpy(&n, pn, sizeof(n));
|
memcpy(&n, pn, sizeof(n));
|
||||||
@@ -387,7 +387,7 @@ get_integer(lua_State *L, struct read_block *rb, int cookie) {
|
|||||||
}
|
}
|
||||||
case TYPE_NUMBER_QWORD: {
|
case TYPE_NUMBER_QWORD: {
|
||||||
int64_t n;
|
int64_t n;
|
||||||
int64_t * pn = rb_read(rb,sizeof(n));
|
const void * pn = rb_read(rb,sizeof(n));
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
memcpy(&n, pn, sizeof(n));
|
memcpy(&n, pn, sizeof(n));
|
||||||
@@ -402,7 +402,7 @@ get_integer(lua_State *L, struct read_block *rb, int cookie) {
|
|||||||
static double
|
static double
|
||||||
get_real(lua_State *L, struct read_block *rb) {
|
get_real(lua_State *L, struct read_block *rb) {
|
||||||
double n;
|
double n;
|
||||||
double * pn = rb_read(rb,sizeof(n));
|
const void * pn = rb_read(rb,sizeof(n));
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
memcpy(&n, pn, sizeof(n));
|
memcpy(&n, pn, sizeof(n));
|
||||||
@@ -412,7 +412,7 @@ get_real(lua_State *L, struct read_block *rb) {
|
|||||||
static void *
|
static void *
|
||||||
get_pointer(lua_State *L, struct read_block *rb) {
|
get_pointer(lua_State *L, struct read_block *rb) {
|
||||||
void * userdata = 0;
|
void * userdata = 0;
|
||||||
void ** v = (void **)rb_read(rb,sizeof(userdata));
|
const void * v = rb_read(rb,sizeof(userdata));
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
@@ -422,7 +422,7 @@ get_pointer(lua_State *L, struct read_block *rb) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
get_buffer(lua_State *L, struct read_block *rb, int len) {
|
get_buffer(lua_State *L, struct read_block *rb, int len) {
|
||||||
char * p = rb_read(rb,len);
|
const char * p = (const char *)rb_read(rb,len);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
@@ -435,7 +435,7 @@ static void
|
|||||||
unpack_table(lua_State *L, struct read_block *rb, int array_size) {
|
unpack_table(lua_State *L, struct read_block *rb, int array_size) {
|
||||||
if (array_size == MAX_COOKIE-1) {
|
if (array_size == MAX_COOKIE-1) {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t *t = rb_read(rb, sizeof(type));
|
const uint8_t * t = (const uint8_t *)rb_read(rb, sizeof(type));
|
||||||
if (t==NULL) {
|
if (t==NULL) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
@@ -488,7 +488,7 @@ push_value(lua_State *L, struct read_block *rb, int type, int cookie) {
|
|||||||
break;
|
break;
|
||||||
case TYPE_LONG_STRING: {
|
case TYPE_LONG_STRING: {
|
||||||
if (cookie == 2) {
|
if (cookie == 2) {
|
||||||
uint16_t *plen = rb_read(rb, 2);
|
const void * plen = rb_read(rb, 2);
|
||||||
if (plen == NULL) {
|
if (plen == NULL) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
@@ -499,7 +499,7 @@ push_value(lua_State *L, struct read_block *rb, int type, int cookie) {
|
|||||||
if (cookie != 4) {
|
if (cookie != 4) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
uint32_t *plen = rb_read(rb, 4);
|
const void * plen = rb_read(rb, 4);
|
||||||
if (plen == NULL) {
|
if (plen == NULL) {
|
||||||
invalid_stream(L,rb);
|
invalid_stream(L,rb);
|
||||||
}
|
}
|
||||||
@@ -523,7 +523,7 @@ push_value(lua_State *L, struct read_block *rb, int type, int cookie) {
|
|||||||
static void
|
static void
|
||||||
unpack_one(lua_State *L, struct read_block *rb) {
|
unpack_one(lua_State *L, struct read_block *rb) {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
uint8_t *t = rb_read(rb, sizeof(type));
|
const uint8_t * t = (const uint8_t *)rb_read(rb, sizeof(type));
|
||||||
if (t==NULL) {
|
if (t==NULL) {
|
||||||
invalid_stream(L, rb);
|
invalid_stream(L, rb);
|
||||||
}
|
}
|
||||||
@@ -584,7 +584,7 @@ luaseri_unpack(lua_State *L) {
|
|||||||
luaL_checkstack(L,LUA_MINSTACK,NULL);
|
luaL_checkstack(L,LUA_MINSTACK,NULL);
|
||||||
}
|
}
|
||||||
uint8_t type = 0;
|
uint8_t type = 0;
|
||||||
uint8_t *t = rb_read(&rb, sizeof(type));
|
const uint8_t * t = (const uint8_t *)rb_read(&rb, sizeof(type));
|
||||||
if (t==NULL)
|
if (t==NULL)
|
||||||
break;
|
break;
|
||||||
type = *t;
|
type = *t;
|
||||||
|
|||||||
Reference in New Issue
Block a user