Skip to content
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

Fix a number of compiler warnings #239

Merged
merged 4 commits into from
Jun 6, 2024
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
1 change: 1 addition & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This library adheres to `Semantic Versioning <http://semver.org/>`_.
**UNRELEASED**

- Fixed compilation of C extension failing on GCC 14
- Fixed compiler warnings when building C extension
agronholm marked this conversation as resolved.
Show resolved Hide resolved

**5.6.3** (2024-04-11)

Expand Down
7 changes: 4 additions & 3 deletions source/decoder.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <datetime.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <limits.h>
Expand Down Expand Up @@ -694,7 +695,7 @@ decode_bytestring(CBORDecoderObject *self, uint8_t subtype)
return NULL;

if (length > (uint64_t)PY_SSIZE_T_MAX - (uint64_t)PyBytesObject_SIZE) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive bytestring size 0x%s", length_hex);
Expand Down Expand Up @@ -894,7 +895,7 @@ decode_string(CBORDecoderObject *self, uint8_t subtype)
if (decode_length(self, subtype, &length, &indefinite) == -1)
return NULL;
if (length > (uint64_t)PY_SSIZE_T_MAX - (uint64_t)PyBytesObject_SIZE) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive string size 0x%s", length_hex);
Expand Down Expand Up @@ -1057,7 +1058,7 @@ decode_array(CBORDecoderObject *self, uint8_t subtype)
if (indefinite)
return decode_indefinite_array(self);
if (length > (uint64_t)PY_SSIZE_T_MAX) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive array size 0x%s", length_hex);
Expand Down
4 changes: 1 addition & 3 deletions source/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,6 @@ CBOREncoder_encode_date(CBOREncoderObject *self, PyObject *value)
// semantic type 100 or 1004

PyObject *tmp, *ret = NULL;
const char *buf;
Py_ssize_t length;
if (self->date_as_datetime) {
tmp = PyDateTimeAPI->DateTime_FromDateAndTime(
PyDateTime_GET_YEAR(value),
Expand Down Expand Up @@ -1120,7 +1118,7 @@ decimal_negative(PyObject *value)
static PyObject *
encode_decimal_digits(CBOREncoderObject *self, PyObject *value)
{
PyObject *tuple, *digits, *exp, *sig, *ten, *tmp, *ret = NULL;
PyObject *tuple, *digits, *exp, *sig, *ten, *tmp = NULL, *ret = NULL;
int sign = 0;
bool sharing;

Expand Down
Loading