From 094c0b74fcc554ec856f69032ccc0c95fe383183 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 3 Mar 2009 20:28:32 +0000 Subject: [PATCH] Branch HEAD NUL terminate hash table names, or garbage is printed in the /proc stats. --- lustre/obdclass/class_hash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lustre/obdclass/class_hash.c b/lustre/obdclass/class_hash.c index 0befb37..99998a8 100644 --- a/lustre/obdclass/class_hash.c +++ b/lustre/obdclass/class_hash.c @@ -84,6 +84,7 @@ lustre_hash_init(char *name, unsigned int cur_bits, unsigned int max_bits, RETURN(NULL); strncpy(lh->lh_name, name, sizeof(lh->lh_name)); + lh->lh_name[sizeof(lh->lh_name) - 1] = '\0'; atomic_set(&lh->lh_rehash_count, 0); atomic_set(&lh->lh_count, 0); rwlock_init(&lh->lh_rwlock); @@ -691,7 +692,7 @@ EXPORT_SYMBOL(lustre_hash_rehash_key); int lustre_hash_debug_header(char *str, int size) { return snprintf(str, size, - "%-36s%6s%6s%6s%6s%6s%6s%6s%7s%6s%s\n", + "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%6s%s\n", LUSTRE_MAX_HASH_NAME, "name", "cur", "min", "max", "theta", "t-min", "t-max", "flags", "rehash", "count", " distribution"); } @@ -711,7 +712,8 @@ int lustre_hash_debug_str(lustre_hash_t *lh, char *str, int size) read_lock(&lh->lh_rwlock); theta = __lustre_hash_theta(lh); - c += snprintf(str + c, size - c, "%-36s ", lh->lh_name); + c += snprintf(str + c, size - c, "%-*s ", + LUSTRE_MAX_HASH_NAME, lh->lh_name); c += snprintf(str + c, size - c, "%5d ", 1 << lh->lh_cur_bits); c += snprintf(str + c, size - c, "%5d ", 1 << lh->lh_min_bits); c += snprintf(str + c, size - c, "%5d ", 1 << lh->lh_max_bits); -- 1.8.3.1