compiler warnings in the Modules/ subdirectory.
if (action == BZ_FINISH && bzerror == BZ_STREAM_END)
break;
}
- if (data_size != PyBytes_GET_SIZE(result))
+ if (data_size != (size_t)PyBytes_GET_SIZE(result))
if (_PyBytes_Resize(&result, data_size) < 0)
goto error;
return result;
d->bzs.avail_out = (unsigned int)Py_MIN(buffer_left, UINT_MAX);
}
}
- if (data_size != PyBytes_GET_SIZE(result))
+ if (data_size != (size_t)PyBytes_GET_SIZE(result))
if (_PyBytes_Resize(&result, data_size) < 0)
goto error;
return result;
StyleDesc *qs;
for (qs = quote_styles; qs->name; qs++) {
- if (qs->style == quoting)
+ if ((int)qs->style == quoting)
return 0;
}
PyErr_Format(PyExc_TypeError, "bad \"quoting\" value");
"Memory cannot be resized because this object doesn't own it");
return NULL;
}
- if (size <= sizeof(obj->b_value)) {
+ if ((size_t)size <= sizeof(obj->b_value)) {
/* internal default buffer is large enough */
obj->b_size = size;
goto done;
if (expat_capi) {
/* check that it's usable */
if (strcmp(expat_capi->magic, PyExpat_CAPI_MAGIC) != 0 ||
- expat_capi->size < sizeof(struct PyExpat_CAPI) ||
+ (size_t)expat_capi->size < sizeof(struct PyExpat_CAPI) ||
expat_capi->MAJOR_VERSION != XML_MAJOR_VERSION ||
expat_capi->MINOR_VERSION != XML_MINOR_VERSION ||
expat_capi->MICRO_VERSION != XML_MICRO_VERSION) {
Py_ssize_t copy_size;
char *new_buf;
- if((! truncate) && preferred_size < self->string_size) {
+ if((! truncate) && preferred_size < (size_t)self->string_size) {
preferred_size = self->string_size;
}
+ /* PyMem_Malloc() returns NULL if preferred_size is bigger
+ than PY_SSIZE_T_MAX */
new_buf = (char *)PyMem_Malloc(preferred_size);
if (new_buf == NULL) {
PyErr_NoMemory();
}
copy_size = self->string_size;
- if (copy_size > preferred_size) {
+ if ((size_t)copy_size > preferred_size) {
copy_size = preferred_size;
}
else {
/* Non-universal mode. */
Py_ssize_t readnl_len = PyUnicode_GET_LENGTH(readnl);
- char *nl = PyUnicode_DATA(readnl);
+ Py_UCS1 *nl = PyUnicode_1BYTE_DATA(readnl);
/* Assume that readnl is an ASCII character. */
assert(PyUnicode_KIND(readnl) == PyUnicode_1BYTE_KIND);
if (readnl_len == 1) {
};
PyObject *result = NULL;
PyObject *flag_items;
- int i;
+ size_t i;
int flags = obj->flags;
/* Omit re.UNICODE for valid string patterns. */
const char *s;
const char *fmt;
char c;
- Py_ssize_t size, len, ncodes, num, itemsize;
+ Py_ssize_t size, len, num, itemsize;
+ size_t ncodes;
fmt = PyBytes_AS_STRING(self->s_format);
}
/* check for overflow */
- if ((ncodes + 1) > (PY_SSIZE_T_MAX / sizeof(formatcode))) {
+ if ((ncodes + 1) > ((size_t)PY_SSIZE_T_MAX / sizeof(formatcode))) {
PyErr_NoMemory();
return -1;
}
{-0xffffL, 16, -1},
{0xfffffffL, 28, 1},
{-0xfffffffL, 28, -1}};
- int i;
+ size_t i;
for (i = 0; i < Py_ARRAY_LENGTH(testcases); ++i) {
size_t nbits;
return 0;
}
s = PyBytes_AsString(in);
- if (strlen(s) != PyBytes_Size(in)) {
+ if (strlen(s) != (size_t)PyBytes_Size(in)) {
PyErr_SetString(PyExc_ValueError, "null byte in bytes object");
return 0;
}
PyErr_SetString(PyExc_OverflowError, "string is too long");
return 0;
}
- if (strlen(s) != size) {
+ if (strlen(s) != (size_t)size) {
PyErr_SetString(PyExc_ValueError, "null character in string");
return 0;
}
(sizeof(traceback_t) + sizeof(frame_t) * (NFRAME - 1))
#define MAX_NFRAME \
- ((INT_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1)
+ (((size_t)INT_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1)
static PyObject *unknown_filename = NULL;
static traceback_t tracemalloc_empty_traceback;
return 0;
}
- assert(1 <= max_nframe && max_nframe <= MAX_NFRAME);
+ assert(1 <= max_nframe && (size_t)max_nframe <= MAX_NFRAME);
tracemalloc_config.max_nframe = max_nframe;
/* allocate a buffer to store a new traceback */
if (!PyArg_ParseTuple(args, "|n:start", &nframe))
return NULL;
- if (nframe < 1 || nframe > MAX_NFRAME) {
+ if (nframe < 1 || (size_t)nframe > MAX_NFRAME) {
PyErr_Format(PyExc_ValueError,
"the number of frames must be in range [1; %i]",
(int)MAX_NFRAME);
if (nframe == -1 && PyErr_Occurred())
return -1;
- if (nframe < 1 || nframe > MAX_NFRAME)
+ if (nframe < 1 || (size_t)nframe > MAX_NFRAME)
return -1;
return Py_SAFE_DOWNCAST(nframe, long, int);
value = strtol(p, &endptr, 10);
if (*endptr != '\0'
|| value < 1
- || value > MAX_NFRAME
+ || (size_t)value > MAX_NFRAME
|| errno == ERANGE)
{
Py_FatalError("PYTHONTRACEMALLOC: invalid number of frames");
*/
for (descr = descriptors; descr->typecode != '\0'; descr++) {
if (descr->is_integer_type &&
- descr->itemsize == mf_descr.size &&
+ (size_t)descr->itemsize == mf_descr.size &&
descr->is_signed == mf_descr.is_signed)
typecode = descr->typecode;
}
#endif
narrow = PyBytes_AS_STRING(bytes);
- if (length != strlen(narrow)) {
+ if ((size_t)length != strlen(narrow)) {
FORMAT_EXCEPTION(PyExc_ValueError, "embedded NUL character in %s");
Py_DECREF(bytes);
return 0;