From 8b6ce11d0239d6927ea4c9ec6b3b1f519ed106a4 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 10 Mar 2011 12:48:40 +0000 Subject: [PATCH] Use void pointer instead of char for binary key dm_hash binary functions takes void* key - so there is no need to cast pointers to char* (also the hash key does not have trailing '\0'). This is slight API change, but presents no change for the API user side it just allows to write code easier as the casting could be removed. --- WHATS_NEW_DM | 1 + libdm/datastruct/hash.c | 12 ++++++------ libdm/libdevmapper.h | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 4c3ac0aa2..45004d195 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.64 - =================================== + Change dm_hash API for binary data to accept const void *key. Fix memory access of empty params string in _reload_with_suppression_v4(). Lower severity of selabel_lookup and matchpathcon failure to log_debug. Accept multiple mapped device names on many dmsetup command lines. diff --git a/libdm/datastruct/hash.c b/libdm/datastruct/hash.c index d4543df5b..30b4a97ad 100644 --- a/libdm/datastruct/hash.c +++ b/libdm/datastruct/hash.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * @@ -133,7 +133,7 @@ void dm_hash_destroy(struct dm_hash_table *t) dm_free(t); } -static struct dm_hash_node **_find(struct dm_hash_table *t, const char *key, +static struct dm_hash_node **_find(struct dm_hash_table *t, const void *key, uint32_t len) { unsigned h = _hash(key, len) & (t->num_slots - 1); @@ -150,15 +150,15 @@ static struct dm_hash_node **_find(struct dm_hash_table *t, const char *key, return c; } -void *dm_hash_lookup_binary(struct dm_hash_table *t, const char *key, - uint32_t len) +void *dm_hash_lookup_binary(struct dm_hash_table *t, const void *key, + uint32_t len) { struct dm_hash_node **c = _find(t, key, len); return *c ? (*c)->data : 0; } -int dm_hash_insert_binary(struct dm_hash_table *t, const char *key, +int dm_hash_insert_binary(struct dm_hash_table *t, const void *key, uint32_t len, void *data) { struct dm_hash_node **c = _find(t, key, len); @@ -180,7 +180,7 @@ int dm_hash_insert_binary(struct dm_hash_table *t, const char *key, return 1; } -void dm_hash_remove_binary(struct dm_hash_table *t, const char *key, +void dm_hash_remove_binary(struct dm_hash_table *t, const void *key, uint32_t len) { struct dm_hash_node **c = _find(t, key, len); diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index ac403e8b0..88bddb104 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of the device-mapper userspace tools. * @@ -713,10 +713,10 @@ void *dm_hash_lookup(struct dm_hash_table *t, const char *key); int dm_hash_insert(struct dm_hash_table *t, const char *key, void *data); void dm_hash_remove(struct dm_hash_table *t, const char *key); -void *dm_hash_lookup_binary(struct dm_hash_table *t, const char *key, uint32_t len); -int dm_hash_insert_binary(struct dm_hash_table *t, const char *key, uint32_t len, +void *dm_hash_lookup_binary(struct dm_hash_table *t, const void *key, uint32_t len); +int dm_hash_insert_binary(struct dm_hash_table *t, const void *key, uint32_t len, void *data); -void dm_hash_remove_binary(struct dm_hash_table *t, const char *key, uint32_t len); +void dm_hash_remove_binary(struct dm_hash_table *t, const void *key, uint32_t len); unsigned dm_hash_get_num_entries(struct dm_hash_table *t); void dm_hash_iter(struct dm_hash_table *t, dm_hash_iterate_fn f);