Fixed sign-compare warnings
This commit is contained in:
parent
4c2028e285
commit
29741ca849
@ -364,7 +364,8 @@ unsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* fil
|
|||||||
if(size && (*out)) (*outsize) = fread(*out, 1, (size_t)size, file);
|
if(size && (*out)) (*outsize) = fread(*out, 1, (size_t)size, file);
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
if (*outsize != size) return 91;
|
if (size < 0) return 91;
|
||||||
|
if (*outsize != (size_t)size) return 91;
|
||||||
if(!(*out) && size) return 83; /*the above malloc failed*/
|
if(!(*out) && size) return 83; /*the above malloc failed*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,12 @@
|
|||||||
|
|
||||||
int TestArrayList(int argc, char* argv[])
|
int TestArrayList(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int index;
|
size_t index;
|
||||||
int count;
|
int count;
|
||||||
|
int rc;
|
||||||
size_t val;
|
size_t val;
|
||||||
wArrayList* arrayList;
|
wArrayList* arrayList;
|
||||||
const int elemsToInsert = 10;
|
const size_t elemsToInsert = 10;
|
||||||
|
|
||||||
arrayList = ArrayList_New(TRUE);
|
arrayList = ArrayList_New(TRUE);
|
||||||
if (!arrayList)
|
if (!arrayList)
|
||||||
@ -17,7 +18,7 @@ int TestArrayList(int argc, char* argv[])
|
|||||||
|
|
||||||
for (index = 0; index < elemsToInsert; index++)
|
for (index = 0; index < elemsToInsert; index++)
|
||||||
{
|
{
|
||||||
if (ArrayList_Add(arrayList, (void*) (size_t) index) < 0)
|
if (ArrayList_Add(arrayList, (void*) index) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ int TestArrayList(int argc, char* argv[])
|
|||||||
|
|
||||||
index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
||||||
|
|
||||||
printf("ArrayList index: %d\n", index);
|
printf("ArrayList index: %"PRIdz"\n", index);
|
||||||
|
|
||||||
if (index != 6)
|
if (index != 6)
|
||||||
return -1;
|
return -1;
|
||||||
@ -35,22 +36,23 @@ int TestArrayList(int argc, char* argv[])
|
|||||||
ArrayList_Insert(arrayList, 5, (void*) (size_t) 100);
|
ArrayList_Insert(arrayList, 5, (void*) (size_t) 100);
|
||||||
|
|
||||||
index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
||||||
printf("ArrayList index: %d\n", index);
|
printf("ArrayList index: %"PRIdz"\n", index);
|
||||||
|
|
||||||
if (index != 7)
|
if (index != 7)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
ArrayList_Remove(arrayList, (void*) (size_t) 100);
|
ArrayList_Remove(arrayList, (void*) (size_t) 100);
|
||||||
|
|
||||||
index = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
rc = ArrayList_IndexOf(arrayList, (void*) (size_t) 6, -1, -1);
|
||||||
printf("ArrayList index: %d\n", index);
|
printf("ArrayList index: %d\n", rc);
|
||||||
|
|
||||||
if (index != 6)
|
if (rc != 6)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (index = 0; index < elemsToInsert; index++) {
|
for (index = 0; index < elemsToInsert; index++) {
|
||||||
val = (size_t)ArrayList_GetItem(arrayList, 0);
|
val = (size_t)ArrayList_GetItem(arrayList, 0);
|
||||||
ArrayList_RemoveAt(arrayList, 0);
|
if (!ArrayList_RemoveAt(arrayList, 0))
|
||||||
|
return -1;
|
||||||
if (val != index)
|
if (val != index)
|
||||||
{
|
{
|
||||||
printf("ArrayList: shifted %"PRIdz" entries, expected value %"PRIdz", got %"PRIdz"\n", index, index, val);
|
printf("ArrayList: shifted %"PRIdz" entries, expected value %"PRIdz", got %"PRIdz"\n", index, index, val);
|
||||||
@ -58,9 +60,9 @@ int TestArrayList(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index = ArrayList_IndexOf(arrayList, (void*) (size_t) elemsToInsert, -1, -1);
|
rc = ArrayList_IndexOf(arrayList, (void*) (size_t) elemsToInsert, -1, -1);
|
||||||
printf("ArrayList index: %d\n", index);
|
printf("ArrayList index: %d\n", rc);
|
||||||
if (index != -1)
|
if (rc != -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
count = ArrayList_Count(arrayList);
|
count = ArrayList_Count(arrayList);
|
||||||
|
@ -9,7 +9,7 @@ int TestBufferPool(int argc, char* argv[])
|
|||||||
int BufferSize;
|
int BufferSize;
|
||||||
wBufferPool* pool;
|
wBufferPool* pool;
|
||||||
BYTE* Buffers[10];
|
BYTE* Buffers[10];
|
||||||
DWORD DefaultSize = 1234;
|
int DefaultSize = 1234;
|
||||||
|
|
||||||
pool = BufferPool_New(TRUE, -1, 16);
|
pool = BufferPool_New(TRUE, -1, 16);
|
||||||
if (!pool)
|
if (!pool)
|
||||||
|
@ -29,14 +29,18 @@ static void* read_image(const char* src, size_t* size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
src_size = _ftelli64(fsrc);
|
src_size = _ftelli64(fsrc);
|
||||||
|
if (src_size < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid file position %"PRId64"\n", src_size);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (_fseeki64(fsrc, 0, SEEK_SET))
|
if (_fseeki64(fsrc, 0, SEEK_SET))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to seek to SEEK_SET\n");
|
fprintf(stderr, "Failed to seek to SEEK_SET\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = malloc(src_size);
|
a = malloc((size_t)src_size);
|
||||||
|
|
||||||
if (!a)
|
if (!a)
|
||||||
{
|
{
|
||||||
@ -44,7 +48,7 @@ static void* read_image(const char* src, size_t* size)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fread(a, sizeof(char), src_size, fsrc) != src_size)
|
if (fread(a, sizeof(char), (size_t)src_size, fsrc) != (size_t)src_size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed read %"PRId64" bytes\n", src_size);
|
fprintf(stderr, "Failed read %"PRId64" bytes\n", src_size);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user