efl - fix many bounds over/underflow where we use int for ptr cmp

this addresses more things brought up in comments in

fixes T3638 commentd

@fix
This commit is contained in:
Carsten Haitzler 2016-05-26 12:17:07 +09:00
parent 7241b7375d
commit 41842ca9f9
3 changed files with 20 additions and 7 deletions

View File

@ -153,8 +153,15 @@ int
eina_file_map_key_cmp(const unsigned long long int *key1, int key1_length EINA_UNUSED,
const unsigned long long int *key2, int key2_length EINA_UNUSED)
{
if (key1[0] - key2[0] == 0) return key1[1] - key2[1];
return key1[0] - key2[0];
if (key1[0] == key2[0])
{
if (key1[1] == key2[1]) return 0;
if (key1[1] > key2[1]) return 1;
return -1;
}
if (key1[0] == key2[0]) return 0;
if (key1[0] > key2[0]) return 1;
return -1;
}
int

View File

@ -536,20 +536,24 @@ static int
_eina_int32_key_cmp(const uint32_t *key1, EINA_UNUSED int key1_length,
const uint32_t *key2, EINA_UNUSED int key2_length)
{
return *key1 - *key2;
if (*key1 == *key2) return 0;
if (*key1 > *key2) return 1;
return -1;
}
static unsigned int
_eina_int64_key_length(EINA_UNUSED const uint32_t *key)
_eina_int64_key_length(EINA_UNUSED const uint64_t *key)
{
return 8;
return sizeof(int64_t);
}
static int
_eina_int64_key_cmp(const uint64_t *key1, EINA_UNUSED int key1_length,
const uint64_t *key2, EINA_UNUSED int key2_length)
{
return *key1 - *key2;
if (*key1 == *key2) return 0;
if (*key1 > *key2) return 1;
return -1;
}
static Eina_Bool

View File

@ -167,7 +167,9 @@ _eina_quadtree_item_cmp(const void *a, const void *b)
const Eina_QuadTree_Item *i = a;
const Eina_QuadTree_Item *j = b;
return i->index - j->index;
if (i->index == j->index) return 0;
if (i->index > j->index) return 1;
return -1;
}
static Eina_QuadTree_Root *