Merge pull request #4308 from radarhere/warnings

Fixed Quant sign comparison warnings
This commit is contained in:
Andrew Murray 2020-02-15 23:28:26 +11:00 committed by GitHub
commit 6c8880bf36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -26,8 +26,8 @@
struct _Heap { struct _Heap {
void **heap; void **heap;
int heapsize; unsigned int heapsize;
int heapcount; unsigned int heapcount;
HeapCmpFunc cf; HeapCmpFunc cf;
}; };
@ -44,7 +44,7 @@ void ImagingQuantHeapFree(Heap *h) {
free(h); free(h);
} }
static int _heap_grow(Heap *h,int newsize) { static int _heap_grow(Heap *h,unsigned int newsize) {
void *newheap; void *newheap;
if (!newsize) newsize=h->heapsize<<1; if (!newsize) newsize=h->heapsize<<1;
if (newsize<h->heapsize) return 0; if (newsize<h->heapsize) return 0;
@ -64,7 +64,7 @@ static int _heap_grow(Heap *h,int newsize) {
#ifdef DEBUG #ifdef DEBUG
static int _heap_test(Heap *h) { static int _heap_test(Heap *h) {
int k; unsigned int k;
for (k=1;k*2<=h->heapcount;k++) { for (k=1;k*2<=h->heapcount;k++) {
if (h->cf(h,h->heap[k],h->heap[k*2])<0) { if (h->cf(h,h->heap[k],h->heap[k*2])<0) {
printf ("heap is bad\n"); printf ("heap is bad\n");
@ -80,7 +80,7 @@ static int _heap_test(Heap *h) {
#endif #endif
int ImagingQuantHeapRemove(Heap* h,void **r) { int ImagingQuantHeapRemove(Heap* h,void **r) {
int k,l; unsigned int k,l;
void *v; void *v;
if (!h->heapcount) { if (!h->heapcount) {

View File

@ -44,7 +44,7 @@ typedef struct _ColorCube{
unsigned int rWidth, gWidth, bWidth, aWidth; unsigned int rWidth, gWidth, bWidth, aWidth;
unsigned int rOffset, gOffset, bOffset, aOffset; unsigned int rOffset, gOffset, bOffset, aOffset;
long size; unsigned long size;
ColorBucket buckets; ColorBucket buckets;
} *ColorCube; } *ColorCube;
@ -134,10 +134,10 @@ add_color_to_color_cube(const ColorCube cube, const Pixel *p) {
bucket->a += p->c.a; bucket->a += p->c.a;
} }
static long static unsigned long
count_used_color_buckets(const ColorCube cube) { count_used_color_buckets(const ColorCube cube) {
long usedBuckets = 0; unsigned long usedBuckets = 0;
long i; unsigned long i;
for (i=0; i < cube->size; i++) { for (i=0; i < cube->size; i++) {
if (cube->buckets[i].count > 0) { if (cube->buckets[i].count > 0) {
usedBuckets += 1; usedBuckets += 1;
@ -194,7 +194,7 @@ void add_bucket_values(ColorBucket src, ColorBucket dst) {
/* expand or shrink a given cube to level */ /* expand or shrink a given cube to level */
static ColorCube copy_color_cube(const ColorCube cube, static ColorCube copy_color_cube(const ColorCube cube,
int rBits, int gBits, int bBits, int aBits) unsigned int rBits, unsigned int gBits, unsigned int bBits, unsigned int aBits)
{ {
unsigned int r, g, b, a; unsigned int r, g, b, a;
long src_pos, dst_pos; long src_pos, dst_pos;
@ -302,7 +302,7 @@ void add_lookup_buckets(ColorCube cube, ColorBucket palette, long nColors, long
} }
ColorBucket ColorBucket
combined_palette(ColorBucket bucketsA, long nBucketsA, ColorBucket bucketsB, long nBucketsB) { combined_palette(ColorBucket bucketsA, unsigned long nBucketsA, ColorBucket bucketsB, unsigned long nBucketsB) {
ColorBucket result; ColorBucket result;
if (nBucketsA > LONG_MAX - nBucketsB || if (nBucketsA > LONG_MAX - nBucketsB ||
(nBucketsA+nBucketsB) > LONG_MAX / sizeof(struct _ColorBucket)) { (nBucketsA+nBucketsB) > LONG_MAX / sizeof(struct _ColorBucket)) {
@ -345,8 +345,8 @@ map_image_pixels(const Pixel *pixelData,
} }
} }
const int CUBE_LEVELS[8] = {4, 4, 4, 0, 2, 2, 2, 0}; const unsigned int CUBE_LEVELS[8] = {4, 4, 4, 0, 2, 2, 2, 0};
const int CUBE_LEVELS_ALPHA[8] = {3, 4, 3, 3, 2, 2, 2, 2}; const unsigned int CUBE_LEVELS_ALPHA[8] = {3, 4, 3, 3, 2, 2, 2, 2};
int quantize_octree(Pixel *pixelData, int quantize_octree(Pixel *pixelData,
uint32_t nPixels, uint32_t nPixels,
@ -365,8 +365,8 @@ int quantize_octree(Pixel *pixelData,
ColorBucket paletteBuckets = NULL; ColorBucket paletteBuckets = NULL;
uint32_t *qp = NULL; uint32_t *qp = NULL;
long i; long i;
long nCoarseColors, nFineColors, nAlreadySubtracted; unsigned long nCoarseColors, nFineColors, nAlreadySubtracted;
const int *cubeBits; const unsigned int *cubeBits;
if (withAlpha) { if (withAlpha) {
cubeBits = CUBE_LEVELS_ALPHA; cubeBits = CUBE_LEVELS_ALPHA;