mirror of
https://github.com/msgpack/msgpack-python.git
synced 2025-10-31 17:40:54 +00:00
Merge pull request #153 from methane/fix/warnings
fix compiler warnings
This commit is contained in:
commit
a329850147
4 changed files with 21 additions and 26 deletions
11
.travis.yml
11
.travis.yml
|
|
@ -1,8 +1,5 @@
|
|||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- wheelhouse
|
||||
|
||||
cache: pip
|
||||
language: python
|
||||
python:
|
||||
- 2.7
|
||||
|
|
@ -19,10 +16,8 @@ env:
|
|||
- TOXENV=pypy-pure,pypy3-pure
|
||||
|
||||
install:
|
||||
- pip install wheel tox
|
||||
- ls -la wheelhouse
|
||||
- if [ ! -f wheelhouse/Cython-0.22-cp27-none-linux_x86_64.whl ] ; then pip wheel cython==0.22 ; fi
|
||||
- pip install wheelhouse/Cython-0.22-cp27-none-linux_x86_64.whl
|
||||
- pip install tox
|
||||
- pip install cython --install-option=--cython-with-refnanny --install-option=--no-cython-compile
|
||||
- cython --cplus msgpack/_packer.pyx msgpack/_unpacker.pyx
|
||||
|
||||
script: tox
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ cdef extern from "unpack.h":
|
|||
ctypedef struct unpack_context:
|
||||
msgpack_user user
|
||||
PyObject* obj
|
||||
size_t count
|
||||
Py_ssize_t count
|
||||
|
||||
ctypedef int (*execute_fn)(unpack_context* ctx, const char* data,
|
||||
size_t len, size_t* off) except? -1
|
||||
Py_ssize_t len, Py_ssize_t* off) except? -1
|
||||
execute_fn unpack_construct
|
||||
execute_fn unpack_skip
|
||||
execute_fn read_array_header
|
||||
|
|
@ -112,7 +112,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
|
|||
See :class:`Unpacker` for options.
|
||||
"""
|
||||
cdef unpack_context ctx
|
||||
cdef size_t off = 0
|
||||
cdef Py_ssize_t off = 0
|
||||
cdef int ret
|
||||
|
||||
cdef char* buf
|
||||
|
|
@ -142,7 +142,7 @@ def unpackb(object packed, object object_hook=None, object list_hook=None,
|
|||
raise ExtraData(obj, PyBytes_FromStringAndSize(buf+off, buf_len-off))
|
||||
return obj
|
||||
else:
|
||||
raise UnpackValueError("Unpack failed: error = %d" % (ret,))
|
||||
raise UnpackValueError("Unpack failed: error = %s" % (ret,))
|
||||
|
||||
|
||||
def unpack(object stream, object object_hook=None, object list_hook=None,
|
||||
|
|
@ -233,14 +233,14 @@ cdef class Unpacker(object):
|
|||
"""
|
||||
cdef unpack_context ctx
|
||||
cdef char* buf
|
||||
cdef size_t buf_size, buf_head, buf_tail
|
||||
cdef Py_ssize_t buf_size, buf_head, buf_tail
|
||||
cdef object file_like
|
||||
cdef object file_like_read
|
||||
cdef Py_ssize_t read_size
|
||||
# To maintain refcnt.
|
||||
cdef object object_hook, object_pairs_hook, list_hook, ext_hook
|
||||
cdef object encoding, unicode_errors
|
||||
cdef size_t max_buffer_size
|
||||
cdef Py_ssize_t max_buffer_size
|
||||
|
||||
def __cinit__(self):
|
||||
self.buf = NULL
|
||||
|
|
@ -325,10 +325,10 @@ cdef class Unpacker(object):
|
|||
cdef:
|
||||
char* buf = self.buf
|
||||
char* new_buf
|
||||
size_t head = self.buf_head
|
||||
size_t tail = self.buf_tail
|
||||
size_t buf_size = self.buf_size
|
||||
size_t new_size
|
||||
Py_ssize_t head = self.buf_head
|
||||
Py_ssize_t tail = self.buf_tail
|
||||
Py_ssize_t buf_size = self.buf_size
|
||||
Py_ssize_t new_size
|
||||
|
||||
if tail + _buf_len > buf_size:
|
||||
if ((tail - head) + _buf_len) <= buf_size:
|
||||
|
|
@ -374,7 +374,7 @@ cdef class Unpacker(object):
|
|||
cdef object _unpack(self, execute_fn execute, object write_bytes, bint iter=0):
|
||||
cdef int ret
|
||||
cdef object obj
|
||||
cdef size_t prev_head
|
||||
cdef Py_ssize_t prev_head
|
||||
|
||||
if self.buf_head >= self.buf_tail and self.file_like is not None:
|
||||
self.read_from_file()
|
||||
|
|
@ -408,7 +408,7 @@ cdef class Unpacker(object):
|
|||
|
||||
def read_bytes(self, Py_ssize_t nbytes):
|
||||
"""Read a specified number of raw bytes from the stream"""
|
||||
cdef size_t nread
|
||||
cdef Py_ssize_t nread
|
||||
nread = min(self.buf_tail - self.buf_head, nbytes)
|
||||
ret = PyBytes_FromStringAndSize(self.buf + self.buf_head, nread)
|
||||
self.buf_head += nread
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ typedef struct unpack_user {
|
|||
typedef PyObject* msgpack_unpack_object;
|
||||
struct unpack_context;
|
||||
typedef struct unpack_context unpack_context;
|
||||
typedef int (*execute_fn)(unpack_context *ctx, const char* data, size_t len, size_t* off);
|
||||
typedef int (*execute_fn)(unpack_context *ctx, const char* data, Py_ssize_t len, Py_ssize_t* off);
|
||||
|
||||
static inline msgpack_unpack_object unpack_callback_root(unpack_user* u)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
|
||||
typedef struct unpack_stack {
|
||||
PyObject* obj;
|
||||
size_t size;
|
||||
size_t count;
|
||||
Py_ssize_t size;
|
||||
Py_ssize_t count;
|
||||
unsigned int ct;
|
||||
PyObject* map_key;
|
||||
} unpack_stack;
|
||||
|
|
@ -72,7 +72,7 @@ static inline PyObject* unpack_data(unpack_context* ctx)
|
|||
|
||||
|
||||
template <bool construct>
|
||||
static inline int unpack_execute(unpack_context* ctx, const char* data, size_t len, size_t* off)
|
||||
static inline int unpack_execute(unpack_context* ctx, const char* data, Py_ssize_t len, Py_ssize_t* off)
|
||||
{
|
||||
assert(len >= *off);
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ static inline int unpack_execute(unpack_context* ctx, const char* data, size_t l
|
|||
*/
|
||||
unpack_user* user = &ctx->user;
|
||||
|
||||
PyObject* obj;
|
||||
PyObject* obj = NULL;
|
||||
unpack_stack* c = NULL;
|
||||
|
||||
int ret;
|
||||
|
|
@ -409,7 +409,7 @@ _end:
|
|||
#undef start_container
|
||||
|
||||
template <unsigned int fixed_offset, unsigned int var_offset>
|
||||
static inline int unpack_container_header(unpack_context* ctx, const char* data, size_t len, size_t* off)
|
||||
static inline int unpack_container_header(unpack_context* ctx, const char* data, Py_ssize_t len, Py_ssize_t* off)
|
||||
{
|
||||
assert(len >= *off);
|
||||
uint32_t size;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue