Merge "libcutils: cleanups for -fsanitize=integer"
This commit is contained in:
commit
532e6cde99
3 changed files with 11 additions and 1 deletions
|
|
@ -71,7 +71,7 @@ __BEGIN_DECLS
|
||||||
#define ATRACE_TAG_LAST ATRACE_TAG_PACKAGE_MANAGER
|
#define ATRACE_TAG_LAST ATRACE_TAG_PACKAGE_MANAGER
|
||||||
|
|
||||||
// Reserved for initialization.
|
// Reserved for initialization.
|
||||||
#define ATRACE_TAG_NOT_READY (1LL<<63)
|
#define ATRACE_TAG_NOT_READY (1ULL<<63)
|
||||||
|
|
||||||
#define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST)
|
#define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ Hashmap* hashmapCreate(size_t initialCapacity,
|
||||||
/**
|
/**
|
||||||
* Hashes the given key.
|
* Hashes the given key.
|
||||||
*/
|
*/
|
||||||
|
#ifdef __clang__
|
||||||
|
__attribute__((no_sanitize("integer")))
|
||||||
|
#endif
|
||||||
static inline int hashKey(Hashmap* map, void* key) {
|
static inline int hashKey(Hashmap* map, void* key) {
|
||||||
int h = map->hash(key);
|
int h = map->hash(key);
|
||||||
|
|
||||||
|
|
@ -152,6 +155,10 @@ void hashmapFree(Hashmap* map) {
|
||||||
free(map);
|
free(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
__attribute__((no_sanitize("integer")))
|
||||||
|
#endif
|
||||||
|
/* FIXME: relies on signed integer overflow, which is undefined behavior */
|
||||||
int hashmapHash(void* key, size_t keySize) {
|
int hashmapHash(void* key, size_t keySize) {
|
||||||
int h = keySize;
|
int h = keySize;
|
||||||
char* data = (char*) key;
|
char* data = (char*) key;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ static bool str_eq(void *key_a, void *key_b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use djb hash unless we find it inadequate */
|
/* use djb hash unless we find it inadequate */
|
||||||
|
#ifdef __clang__
|
||||||
|
__attribute__((no_sanitize("integer")))
|
||||||
|
#endif
|
||||||
static int str_hash_fn(void *str)
|
static int str_hash_fn(void *str)
|
||||||
{
|
{
|
||||||
uint32_t hash = 5381;
|
uint32_t hash = 5381;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue