diff options
author | Kirill A. Shutemov <kirill@shutemov.name> | 2011-08-30 23:06:04 +0300 |
---|---|---|
committer | Kirill A. Shutemov <kirill@shutemov.name> | 2011-08-30 23:06:04 +0300 |
commit | 0b2c4061878bc5b437b1a9e9b5f43c357283980e (patch) | |
tree | d65e4af25c301e525040941d24c3a98abcaab547 /src/cache.c | |
parent | 2fcf9c82735cec8874d5e12ed18380c77d629706 (diff) | |
download | libgit2-0b2c4061878bc5b437b1a9e9b5f43c357283980e.tar.gz |
CMakefile: add -Wstrict-aliasing=2 and fix warnings
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c index 433fc3d9c..fca7e1236 100644 --- a/src/cache.c +++ b/src/cache.c @@ -76,12 +76,12 @@ void git_cache_free(git_cache *cache) void *git_cache_get(git_cache *cache, const git_oid *oid) { - const uint32_t *hash; + uint32_t hash; cache_node *node = NULL; void *result = NULL; - hash = (const uint32_t *)oid->id; - node = &cache->nodes[hash[0] & cache->size_mask]; + memcpy(&hash, oid->id, sizeof(hash)); + node = &cache->nodes[hash & cache->size_mask]; git_mutex_lock(&node->lock); { @@ -97,13 +97,13 @@ void *git_cache_get(git_cache *cache, const git_oid *oid) void *git_cache_try_store(git_cache *cache, void *entry) { - const uint32_t *hash; + uint32_t hash; const git_oid *oid; cache_node *node = NULL; oid = &((git_cached_obj*)entry)->oid; - hash = (const uint32_t *)oid->id; - node = &cache->nodes[hash[0] & cache->size_mask]; + memcpy(&hash, oid->id, sizeof(hash)); + node = &cache->nodes[hash & cache->size_mask]; /* increase the refcount on this object, because * the cache now owns it */ |