diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2020-05-22 13:06:26 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2020-05-22 13:06:26 +0200 |
commit | 3d9e87aadacf3f8f8a93ad09432c67a257b51633 (patch) | |
tree | bc19a0afa54f137a6e88808e8589dd8140cc4666 /type_decoder.c | |
parent | 9e3ed17732bfee95dd17fbd74ad82195a992eb2f (diff) | |
download | libsigrokdecode-3d9e87aadacf3f8f8a93ad09432c67a257b51633.tar.gz libsigrokdecode-3d9e87aadacf3f8f8a93ad09432c67a257b51633.zip |
Use PyLong_FromUnsignedLongLong() where needed.
There were a few places where PyLong_FromLong() was used for uint64_t
numbers. Properly use PyLong_FromUnsignedLongLong() there, and also
fix a few additional size/signedness issues while we're here.
Reported (and partial patch provided) by "The Count" on Bugzilla, thanks!
This fixes bug #1499.
Diffstat (limited to 'type_decoder.c')
-rw-r--r-- | type_decoder.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/type_decoder.c b/type_decoder.c index 983400b..1b378f1 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -605,13 +605,13 @@ static PyObject *get_current_pinvalues(const struct srd_decoder_inst *di) /* A channelmap value of -1 means "unused optional channel". */ if (di->dec_channelmap[i] == -1) { /* Value of unused channel is 0xff, instead of 0 or 1. */ - PyTuple_SetItem(py_pinvalues, i, PyLong_FromLong(0xff)); + PyTuple_SetItem(py_pinvalues, i, PyLong_FromUnsignedLong(0xff)); } else { sample_pos = di->inbuf + ((di->abs_cur_samplenum - di->abs_start_samplenum) * di->data_unitsize); byte_offset = di->dec_channelmap[i] / 8; bit_offset = di->dec_channelmap[i] % 8; sample = *(sample_pos + byte_offset) & (1 << bit_offset) ? 1 : 0; - PyTuple_SetItem(py_pinvalues, i, PyLong_FromLong(sample)); + PyTuple_SetItem(py_pinvalues, i, PyLong_FromUnsignedLong(sample)); } } @@ -922,7 +922,7 @@ static PyObject *Decoder_wait(PyObject *self, PyObject *args) /* If there's a match, set self.samplenum etc. and return. */ if (found_match) { /* Set self.samplenum to the (absolute) sample number that matched. */ - py_samplenum = PyLong_FromLong(di->abs_cur_samplenum); + py_samplenum = PyLong_FromUnsignedLongLong(di->abs_cur_samplenum); PyObject_SetAttrString(di->py_inst, "samplenum", py_samplenum); Py_DECREF(py_samplenum); |