From: Paul Brossier Date: Tue, 10 Dec 2013 22:57:30 +0000 (-0500) Subject: ext/py-source.c: fix size checks X-Git-Tag: 0.4.0~26 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=18e22f9553c239cfbe915cce1998025784e87ed8;p=aubio.git ext/py-source.c: fix size checks Signed-off-by: Paul Brossier --- diff --git a/python/ext/py-source.c b/python/ext/py-source.c index d35f3d9b..82cab06d 100644 --- a/python/ext/py-source.c +++ b/python/ext/py-source.c @@ -40,21 +40,21 @@ Py_source_new (PyTypeObject * pytype, PyObject * args, PyObject * kwds) } self->samplerate = 0; - if (samplerate > 0) { + if ((sint_t)samplerate > 0) { self->samplerate = samplerate; - //} else if (samplerate < 0) { - // PyErr_SetString (PyExc_ValueError, - // "can not use negative value for samplerate"); - // return NULL; + } else if ((sint_t)samplerate < 0) { + PyErr_SetString (PyExc_ValueError, + "can not use negative value for samplerate"); + return NULL; } self->hop_size = Py_default_vector_length / 2; - if (hop_size > 0) { + if ((sint_t)hop_size > 0) { self->hop_size = hop_size; - //} else if (hop_size < 0) { - // PyErr_SetString (PyExc_ValueError, - // "can not use negative value for hop_size"); - // return NULL; + } else if ((sint_t)hop_size < 0) { + PyErr_SetString (PyExc_ValueError, + "can not use negative value for hop_size"); + return NULL; } return (PyObject *) self;