Skip to contentSkip to conversation

hashbin_cleanup

PATCH New Jean Tourrilhes 1 participant 1 message Feb 26, 2004 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hashbin_cleanup

irXXX_hashbin_cleanup.diff :
~~~~~~~~~~~~~~~~~~~~~~~~~~
<Patch from Stephen Hemminger>
o [FEATURE] remove unused code
o [FEATURE] add const where needed

include/net/irda/irqueue.h +5 -5
diff -Nru a/include/net/irda/irqueue.h b/include/net/irda/irqueue.h
@@ -81,13 +81,13 @@
 int      hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
 int      hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
 void     hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, 
-			char* name);
-void*    hashbin_remove(hashbin_t* hashbin, long hashv, char* name);
+			const char* name);
+void*    hashbin_remove(hashbin_t* hashbin, long hashv, const char* name);
 void*    hashbin_remove_first(hashbin_t *hashbin);
 void*	 hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry);
-void*    hashbin_find(hashbin_t* hashbin, long hashv, char* name);
-void*    hashbin_lock_find(hashbin_t* hashbin, long hashv, char* name);
-void*    hashbin_find_next(hashbin_t* hashbin, long hashv, char* name,
+void*    hashbin_find(hashbin_t* hashbin, long hashv, const char* name);
+void*    hashbin_lock_find(hashbin_t* hashbin, long hashv, const char* name);
+void*    hashbin_find_next(hashbin_t* hashbin, long hashv, const char* name,
 			   void ** pnext);
 irda_queue_t *hashbin_get_first(hashbin_t *hashbin);
 irda_queue_t *hashbin_get_next(hashbin_t *hashbin);
net/irda/irqueue.c +7 -6
diff -Nru a/net/irda/irqueue.c b/net/irda/irqueue.c
@@ -208,7 +208,7 @@
  *    This function hash the input string 'name' using the ELF hash
  *    function for strings.
  */
-static __u32 hash( char* name)
+static __u32 hash( const char* name)
 {
 	__u32 h = 0;
 	__u32 g;
@@ -567,7 +567,8 @@
  *    Insert an entry into the hashbin
  *
  */
-void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, char* name)
+void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, 
+		    const char* name)
 {
 	unsigned long flags = 0;
 	int bin;
@@ -683,7 +684,7 @@
  *  In other case, you must think hard to guarantee unicity of the index.
  *  Jean II
  */
-void* hashbin_remove( hashbin_t* hashbin, long hashv, char* name)
+void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
 {
 	int bin, found = FALSE;
 	unsigned long flags = 0;
@@ -834,7 +835,7 @@
  *    Find item with the given hashv or name
  *
  */
-void* hashbin_find( hashbin_t* hashbin, long hashv, char* name )
+void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name )
 {
 	int bin;
 	irda_queue_t* entry;
@@ -888,7 +889,7 @@
  * I call it safe, but it's only safe with respect to the hashbin, not its
  * content. - Jean II
  */
-void* hashbin_lock_find( hashbin_t* hashbin, long hashv, char* name )
+void* hashbin_lock_find( hashbin_t* hashbin, long hashv, const char* name )
 {
 	unsigned long flags = 0;
 	irda_queue_t* entry;
@@ -917,7 +918,7 @@
  * context of the search. On the other hand, it might fail and return
  * NULL if the entry is removed. - Jean II
  */
-void* hashbin_find_next( hashbin_t* hashbin, long hashv, char* name,
+void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name,
 			 void ** pnext)
 {
 	unsigned long flags = 0;
include/net/irda/irqueue.h +0 -1
diff -Nru a/include/net/irda/irqueue.h b/include/net/irda/irqueue.h
@@ -41,7 +41,6 @@
  */
 #define HB_NOLOCK	0	/* No concurent access prevention */
 #define HB_LOCK		1	/* Prevent concurent write with global lock */
-#define HB_SORTED	4	/* Not yet supported */
 
 /*
  * Hash defines
net/irda/irqueue.c +2 -7
diff -Nru a/net/irda/irqueue.c b/net/irda/irqueue.c
@@ -599,14 +599,9 @@
 	
 	/*
 	 * Insert new entry first
-	 * TODO: Perhaps allow sorted lists?
-	 *       -> Merge sort if a sorted list should be created
 	 */
-	if ( hashbin->hb_type & HB_SORTED) {
-	} else {
-		enqueue_first( (irda_queue_t**) &hashbin->hb_queue[ bin ],
-			       entry);
-	}
+	enqueue_first( (irda_queue_t**) &hashbin->hb_queue[ bin ],
+		       entry);
 	hashbin->hb_size++;
 
 	/* Release lock */
net/irda/irqueue.c +0 -131

143 lines not on this page · raw message