diff --git a/src/calibre/gui2/pictureflow/pictureflow.cpp b/src/calibre/gui2/pictureflow/pictureflow.cpp index 9b0e094ee4..9fe3301fbe 100644 --- a/src/calibre/gui2/pictureflow/pictureflow.cpp +++ b/src/calibre/gui2/pictureflow/pictureflow.cpp @@ -587,7 +587,7 @@ void PictureFlowPrivate::resetSlides() { SlideInfo& si = leftSlides[i]; si.angle = itilt; - si.cx = -(offsetX + spacing*i*PFREAL_ONE); + si.cx = -(offsetX + (long)spacing*i*PFREAL_ONE); si.cy = offsetY; si.slideIndex = centerIndex-1-i; //qDebug() << "Left[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; @@ -599,7 +599,7 @@ void PictureFlowPrivate::resetSlides() { SlideInfo& si = rightSlides[i]; si.angle = -itilt; - si.cx = offsetX + spacing*i*PFREAL_ONE; + si.cx = offsetX + (long)spacing*i*PFREAL_ONE; si.cy = offsetY; si.slideIndex = centerIndex+1+i; //qDebug() << "Right[" << i << "] x=" << fixedToFloat(si.cx) << ", y=" << fixedToFloat(si.cy) ; @@ -1118,7 +1118,7 @@ void PictureFlowPrivate::updateAnimation() speed = 512 + 16384 * (PFREAL_ONE+fsin(ia))/PFREAL_ONE; } - slideFrame += speed*step; + slideFrame += (long long)speed*step; int index = slideFrame >> 16; int pos = slideFrame & 0xffff; @@ -1161,7 +1161,7 @@ void PictureFlowPrivate::updateAnimation() { SlideInfo& si = leftSlides[i]; si.angle = itilt; - si.cx = -(offsetX + spacing*i*PFREAL_ONE + step*spacing*ftick); + si.cx = -(offsetX + (long)spacing*i*PFREAL_ONE + (long)step*spacing*ftick); si.cy = offsetY; } @@ -1169,7 +1169,7 @@ void PictureFlowPrivate::updateAnimation() { SlideInfo& si = rightSlides[i]; si.angle = -itilt; - si.cx = offsetX + spacing*i*PFREAL_ONE - step*spacing*ftick; + si.cx = offsetX + (long)spacing*i*PFREAL_ONE - (long)step*spacing*ftick; si.cy = offsetY; } diff --git a/src/calibre/utils/ffmpeg.c b/src/calibre/utils/ffmpeg.c index 616eab94e4..db9091f40a 100644 --- a/src/calibre/utils/ffmpeg.c +++ b/src/calibre/utils/ffmpeg.c @@ -510,7 +510,7 @@ resample_raw_audio_16bit(PyObject *self, PyObject *args) { ); Py_END_ALLOW_THREADS if (ret < 0) { free_resources; return averror_as_python_with_gil_held(ret, __LINE__); } - output_size = ret * output_num_channels * bytes_per_sample; + output_size = (int64_t)ret * (int64_t)output_num_channels * bytes_per_sample; PyObject *ans = PyBytes_FromStringAndSize((char*)output, output_size); free_resources; #undef free_resources diff --git a/src/calibre/utils/imageops/imageops.cpp b/src/calibre/utils/imageops/imageops.cpp index 2330fb4196..7524f6dcc0 100644 --- a/src/calibre/utils/imageops/imageops.cpp +++ b/src/calibre/utils/imageops/imageops.cpp @@ -174,7 +174,7 @@ static QImage convolve(const QImage &image, int matrix_size, float *matrix) { if (buffer.isNull()) throw std::bad_alloc(); buf1.resize(matrix_size); scanblock = buf1.data(); - buf2.resize(matrix_size * matrix_size); + buf2.resize((qsizetype)matrix_size * matrix_size); normalize_matrix = buf2.data(); // create normalized matrix diff --git a/src/calibre/utils/lzx/lzxc.c b/src/calibre/utils/lzx/lzxc.c index 4014224b5e..f0d5c8152d 100644 --- a/src/calibre/utils/lzx/lzxc.c +++ b/src/calibre/utils/lzx/lzxc.c @@ -18,7 +18,6 @@ #define LZ_ONEBUFFER 1 #define LAZY 1 -#include #include #include #include /* for memset on Linux */ @@ -1143,7 +1142,7 @@ int lzxc_compress_block(lzxc_data *lzxd, int block_size, int subdivide) build_huffman_tree(LZX_ALIGNED_SIZE, 7, lzxd->aligned_freq_table, lzxd->aligned_tree); for (i = 0; i < LZX_ALIGNED_SIZE; i++) { uncomp_bits += lzxd->aligned_freq_table[i]* 3; - comp_bits += lzxd->aligned_freq_table[i]* lzxd->aligned_tree[i].codelength; + comp_bits += (long)lzxd->aligned_freq_table[i]* lzxd->aligned_tree[i].codelength; } comp_bits_ovh = comp_bits + LZX_ALIGNED_SIZE * 3; if (comp_bits_ovh < uncomp_bits) diff --git a/src/calibre/utils/lzx/lzxd.c b/src/calibre/utils/lzx/lzxd.c index b416a9b6ed..67d6aecbbf 100644 --- a/src/calibre/utils/lzx/lzxd.c +++ b/src/calibre/utils/lzx/lzxd.c @@ -224,8 +224,8 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits, unsigned int next_symbol = bit_mask; /* base of allocation for long codes */ /* fill entries for codes short enough for a direct mapping */ - for (bit_num = 1; bit_num <= nbits; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { + for (bit_num = 1; (unsigned)bit_num <= nbits; bit_num++) { + for (sym = 0; (unsigned)sym < nsyms; sym++) { if (length[sym] != bit_num) continue; leaf = pos; if((pos += bit_mask) > table_mask) return 1; /* table overrun */ @@ -239,7 +239,7 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits, if (pos == table_mask) return 0; /* clear the remainder of the table */ - for (sym = pos; sym < table_mask; sym++) table[sym] = 0xFFFF; + for (sym = pos; (unsigned)sym < table_mask; sym++) table[sym] = 0xFFFF; /* allow codes to be up to nbits+16 long, instead of nbits */ pos <<= 16; @@ -247,7 +247,7 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits, bit_mask = 1 << 15; for (bit_num = nbits+1; bit_num <= 16; bit_num++) { - for (sym = 0; sym < nsyms; sym++) { + for (sym = 0; (unsigned)sym < nsyms; sym++) { if (length[sym] != bit_num) continue; leaf = pos >> 16; @@ -273,7 +273,7 @@ static int make_decode_table(unsigned int nsyms, unsigned int nbits, if (pos == table_mask) return 0; /* either erroneous table, or all elements are 0 - let's find out. */ - for (sym = 0; sym < nsyms; sym++) if (length[sym]) return 1; + for (sym = 0; (unsigned)sym < nsyms; sym++) if (length[sym]) return 1; return 0; } diff --git a/src/calibre/utils/matcher.c b/src/calibre/utils/matcher.c index af19fad158..77a87aa6a1 100644 --- a/src/calibre/utils/matcher.c +++ b/src/calibre/utils/matcher.c @@ -27,7 +27,7 @@ typedef struct { static MemoryItem*** alloc_memory(int32_t needle_len, int32_t max_haystack_len) { MemoryItem ***ans = NULL, **d1 = NULL, *d2 = NULL; - size_t num = max_haystack_len * max_haystack_len * needle_len; + size_t num = (size_t)max_haystack_len * (size_t)max_haystack_len * needle_len; size_t position_sz = needle_len * sizeof(int32_t); size_t sz = (num * (sizeof(MemoryItem) + position_sz)) + (max_haystack_len * sizeof(MemoryItem**)) + (needle_len * sizeof(MemoryItem*)); int32_t hidx, nidx, last_idx, i, j; @@ -85,7 +85,7 @@ typedef struct { static void alloc_stack(Stack *stack, int32_t needle_len, int32_t max_haystack_len) { StackItem *ans = NULL; char *base = NULL; - size_t num = max_haystack_len * needle_len; + size_t num = (size_t)max_haystack_len * needle_len; size_t position_sz = needle_len * sizeof(int32_t); size_t sz = sizeof(StackItem) + position_sz; size_t i = 0; @@ -416,7 +416,7 @@ Matcher_calculate_scores(Matcher *self, PyObject *args) { items = PyTuple_New(self->item_count); positions = PyTuple_New(self->item_count); matches = (Match*)calloc(self->item_count, sizeof(Match)); - final_positions = (int32_t*) calloc(needle_char_len * self->item_count, sizeof(int32_t)); + final_positions = (int32_t*) calloc((size_t)needle_char_len * self->item_count, sizeof(int32_t)); if (items == NULL || matches == NULL || final_positions == NULL || positions == NULL) {PyErr_NoMemory(); goto end;} for (i = 0; i < self->item_count; i++) {