summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 13:02:58 -0800
committerDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 13:03:01 -0800
commitb3b8e04e127b4333f3acf61f7a0fbcc770581db7 (patch)
treecc32269b7dbc8e102376992c8f65094c1a47f4dd
parentd715685ae7f5a26ee90a23db5832e4243ce3af45 (diff)
downloadpycrypto-b3b8e04e127b4333f3acf61f7a0fbcc770581db7.tar.gz
Counter: Fix compiler warning about signed-unsigned comparison
-rw-r--r--src/_counter.c1
-rw-r--r--src/_counter.h2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/_counter.c b/src/_counter.c
index a29b0ce..6579a5f 100644
--- a/src/_counter.c
+++ b/src/_counter.c
@@ -106,6 +106,7 @@ CounterObject_init(PCT_CounterObject *self, PyObject *args, PyObject *kwargs)
/* Sanity-check pointers */
assert(self->val <= self->p);
+ assert(self->buf_size >= 0);
assert(self->p + self->nbytes <= self->val + self->buf_size);
assert(self->val + PyBytes_GET_SIZE(self->prefix) == self->p);
assert(PyBytes_GET_SIZE(self->prefix) + self->nbytes + PyBytes_GET_SIZE(self->suffix) == self->buf_size);
diff --git a/src/_counter.h b/src/_counter.h
index fc3e24e..f671094 100644
--- a/src/_counter.h
+++ b/src/_counter.h
@@ -38,7 +38,7 @@ typedef struct {
PyBytesObject *prefix; /* Prefix (useful for a nonce) */
PyBytesObject *suffix; /* Suffix (useful for a nonce) */
uint8_t *val; /* Buffer for our output string */
- uint32_t buf_size; /* Size of the buffer */
+ Py_ssize_t buf_size;/* Size of the buffer */
uint8_t *p; /* Pointer to the part of the buffer that we're allowed to update */
uint16_t nbytes; /* The number of bytes that from .p that are part of the counter */
void (*inc_func)(void *); /* Pointer to the counter increment function */