From e7cb6b009184b95cb002ca771732348c7d9fb329 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 13 Jan 2003 04:15:07 -0800 Subject: [PATCH] [PATCH] namespace pollution in irda_irias From: Arnd Bergmann A global variable should not be named 'objects' like in irias_object.c. This patch puts it into the right namespace. Also, strndup() is made static. --- include/net/irda/irias_object.h | 4 +--- net/irda/iriap.c | 21 +++++++++++---------- net/irda/irias_object.c | 12 ++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/include/net/irda/irias_object.h b/include/net/irda/irias_object.h index 36ad1d897867..0a210380e549 100644 --- a/include/net/irda/irias_object.h +++ b/include/net/irda/irias_object.h @@ -78,8 +78,6 @@ struct ias_attrib { struct ias_value *value; /* Attribute value */ }; -char *strndup(char *str, int max); - struct ias_object *irias_new_object(char *name, int id); void irias_insert_object(struct ias_object *obj); int irias_delete_object(struct ias_object *obj); @@ -104,6 +102,6 @@ struct ias_value *irias_new_missing_value(void); void irias_delete_value(struct ias_value *value); extern struct ias_value missing; -extern hashbin_t *objects; +extern hashbin_t *irias_objects; #endif diff --git a/net/irda/iriap.c b/net/irda/iriap.c index 6641a492d37f..edf9a77c078c 100644 --- a/net/irda/iriap.c +++ b/net/irda/iriap.c @@ -96,9 +96,10 @@ int __init iriap_init(void) return -ENOMEM; /* Object repository - defined in irias_object.c */ - objects = hashbin_new(HB_LOCK); - if (!objects) { - WARNING("%s: Can't allocate objects hashbin!\n", __FUNCTION__); + irias_objects = hashbin_new(HB_LOCK); + if (!irias_objects) { + WARNING("%s: Can't allocate irias_objects hashbin!\n", + __FUNCTION__); return -ENOMEM; } @@ -147,7 +148,7 @@ void __exit iriap_cleanup(void) irlmp_unregister_service(service_handle); hashbin_delete(iriap, (FREE_FUNC) __iriap_close); - hashbin_delete(objects, (FREE_FUNC) __irias_delete_object); + hashbin_delete(irias_objects, (FREE_FUNC) __irias_delete_object); } /* @@ -971,16 +972,16 @@ int irias_proc_read(char *buf, char **start, off_t offset, int len) struct ias_attrib *attrib; unsigned long flags; - ASSERT( objects != NULL, return 0;); + ASSERT( irias_objects != NULL, return 0;); len = 0; len += sprintf(buf+len, "LM-IAS Objects:\n"); - spin_lock_irqsave(&objects->hb_spinlock, flags); + spin_lock_irqsave(&irias_objects->hb_spinlock, flags); - /* List all objects */ - obj = (struct ias_object *) hashbin_get_first(objects); + /* List all irias_objects */ + obj = (struct ias_object *) hashbin_get_first(irias_objects); while ( obj != NULL) { ASSERT(obj->magic == IAS_OBJECT_MAGIC, return 0;); @@ -1031,9 +1032,9 @@ int irias_proc_read(char *buf, char **start, off_t offset, int len) } spin_unlock(&obj->attribs->hb_spinlock); - obj = (struct ias_object *) hashbin_get_next(objects); + obj = (struct ias_object *) hashbin_get_next(irias_objects); } - spin_unlock_irqrestore(&objects->hb_spinlock, flags); + spin_unlock_irqrestore(&irias_objects->hb_spinlock, flags); return len; } diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c index 2c838482b70e..622b780b93bf 100644 --- a/net/irda/irias_object.c +++ b/net/irda/irias_object.c @@ -28,7 +28,7 @@ #include #include -hashbin_t *objects = NULL; +hashbin_t *irias_objects; /* * Used when a missing value needs to be returned @@ -42,7 +42,7 @@ struct ias_value missing = { IAS_MISSING, 0, 0, 0, {0}}; * * Faster, check boundary... Jean II */ -char *strndup(char *str, int max) +static char *strndup(char *str, int max) { char *new_str; int len; @@ -151,7 +151,7 @@ int irias_delete_object(struct ias_object *obj) ASSERT(obj != NULL, return -1;); ASSERT(obj->magic == IAS_OBJECT_MAGIC, return -1;); - node = hashbin_remove_this(objects, (irda_queue_t *) obj); + node = hashbin_remove_this(irias_objects, (irda_queue_t *) obj); if (!node) return 0; /* Already removed */ @@ -202,7 +202,7 @@ void irias_insert_object(struct ias_object *obj) ASSERT(obj != NULL, return;); ASSERT(obj->magic == IAS_OBJECT_MAGIC, return;); - hashbin_insert(objects, (irda_queue_t *) obj, 0, obj->name); + hashbin_insert(irias_objects, (irda_queue_t *) obj, 0, obj->name); } /* @@ -216,7 +216,7 @@ struct ias_object *irias_find_object(char *name) ASSERT(name != NULL, return NULL;); /* Unsafe (locking), object might change */ - return hashbin_lock_find(objects, 0, name); + return hashbin_lock_find(irias_objects, 0, name); } /* @@ -276,7 +276,7 @@ int irias_object_change_attribute(char *obj_name, char *attrib_name, unsigned long flags; /* Find object */ - obj = hashbin_lock_find(objects, 0, obj_name); + obj = hashbin_lock_find(irias_objects, 0, obj_name); if (obj == NULL) { WARNING("%s: Unable to find object: %s\n", __FUNCTION__, obj_name); -- 2.39.5