1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-12-27 00:23:49 +03:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Alasdair Kergon
6bb20ee09e Fix (rare) cache bug on machines with large /dev directories. 2003-01-10 19:14:01 +00:00
Alasdair Kergon
541356430c Fix segfault in uuid display (substitution missed during bulk change) 2003-01-09 19:35:17 +00:00
4 changed files with 19 additions and 22 deletions

View File

@@ -1 +1 @@
1.95.14-cvs (2003-01-08)
1.95.15-cvs (2003-01-09)

13
lib/cache/cache.c vendored
View File

@@ -63,11 +63,16 @@ const struct format_type *fmt_from_vgname(const char *vgname)
struct cache_vginfo *vginfo_from_vgid(const char *vgid)
{
struct cache_vginfo *vginfo;
char id[ID_LEN + 1];
if (!_vgid_hash || !vgid)
return NULL;
if (!(vginfo = hash_lookup_fixed(_vgid_hash, vgid, ID_LEN)))
/* vgid not necessarily NULL-terminated */
strncpy(&id[0], vgid, ID_LEN);
id[ID_LEN] = '\0';
if (!(vginfo = hash_lookup(_vgid_hash, id)))
return NULL;
return vginfo;
@@ -76,11 +81,15 @@ struct cache_vginfo *vginfo_from_vgid(const char *vgid)
struct cache_info *info_from_pvid(const char *pvid)
{
struct cache_info *info;
char id[ID_LEN + 1];
if (!_pvid_hash || !pvid)
return NULL;
if (!(info = hash_lookup_fixed(_pvid_hash, pvid, ID_LEN)))
strncpy(&id[0], pvid, ID_LEN);
id[ID_LEN] = '\0';
if (!(info = hash_lookup(_pvid_hash, id)))
return NULL;
return info;

View File

@@ -59,10 +59,10 @@ static struct hash_node *_create_node(const char *str)
return n;
}
static unsigned _hash(const char *str, unsigned len)
static unsigned _hash(const char *str)
{
unsigned long h = 0, g;
while (*str && len--) {
while (*str) {
h <<= 4;
h += _nums[(int) *str++];
g = h & ((unsigned long) 0xf << 16u);
@@ -125,30 +125,18 @@ void hash_destroy(struct hash_table *t)
dbg_free(t);
}
static inline struct hash_node **_find_fixed(struct hash_table *t,
const char *key, unsigned len)
static inline struct hash_node **_find(struct hash_table *t, const char *key)
{
unsigned h = _hash(key, len) & (t->num_slots - 1);
unsigned h = _hash(key) & (t->num_slots - 1);
struct hash_node **c;
for (c = &t->slots[h]; *c; c = &((*c)->next))
if (!strncmp(key, (*c)->key, len))
if (!strcmp(key, (*c)->key))
break;
return c;
}
static inline struct hash_node **_find(struct hash_table *t, const char *key)
{
return _find_fixed(t, key, strlen(key));
}
void *hash_lookup_fixed(struct hash_table *t, const char *key, unsigned len)
{
struct hash_node **c = _find_fixed(t, key, len);
return *c ? (*c)->data : 0;
}
void *hash_lookup(struct hash_table *t, const char *key)
{
struct hash_node **c = _find(t, key);
@@ -238,6 +226,6 @@ struct hash_node *hash_get_first(struct hash_table *t)
struct hash_node *hash_get_next(struct hash_table *t, struct hash_node *n)
{
unsigned h = _hash(n->key, strlen(n->key)) & (t->num_slots - 1);
unsigned h = _hash(n->key) & (t->num_slots - 1);
return n->next ? n->next : _next_slot(t, h + 1);
}

View File

@@ -456,7 +456,7 @@ static int _uuid_disp(struct report_handle *rh, struct field *field,
{
char *repstr = NULL;
if (!(field->report_string = pool_alloc(rh->mem, 40))) {
if (!(repstr = pool_alloc(rh->mem, 40))) {
log_error("pool_alloc failed");
return 0;
}