Skip to content

fix compiler warnings #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
sudo: false
cache:
directories:
- wheelhouse

cache: pip
language: python
python:
- 2.7
Expand All @@ -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
24 changes: 12 additions & 12 deletions msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion msgpack/unpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 5 additions & 5 deletions msgpack/unpack_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -409,7 +409,7 @@ static inline int unpack_execute(unpack_context* ctx, const char* data, size_t l
#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;
Expand Down