[openib-general] [PATCH][dapl] cleanup dapl_cookie

Bernhard Fischer rep.nop at aon.at
Mon Jun 27 10:39:51 PDT 2005


Hi James,

untested.

- cleanup dapl_cookie.c: remove unneeded local variables and simplify
  branches to be consistent with dapl_rmr_cookie_alloc().

Signed-off-by: Bernhard Fischer <rep.nop at aon.at>

thank you,
Bernhard
-------------- next part --------------
Index: users/jlentini/linux-kernel/dat-provider/dapl_cookie.c
===================================================================
--- users/jlentini/linux-kernel/dat-provider/dapl_cookie.c	(revision 2715)
+++ users/jlentini/linux-kernel/dat-provider/dapl_cookie.c	(working copy)
@@ -1,6 +1,7 @@
 /*
  * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright (c) 2005 Bernhard Fischer, All rights reserved.
  *
  * This Software is licensed under one of the following licenses:
  *
@@ -136,8 +137,8 @@ u32 dapl_cb_create(struct dapl_cookie_bu
 		}
 
 		return DAT_SUCCESS;
-	} else
-		return DAT_INSUFFICIENT_RESOURCES;
+	}
+	return DAT_INSUFFICIENT_RESOURCES;
 }
 
 /*
@@ -157,8 +158,7 @@ u32 dapl_cb_create(struct dapl_cookie_bu
  */
 void dapl_cb_free(struct dapl_cookie_buffer *buffer)
 {
-	if (NULL != buffer->pool) 
-		kfree(buffer->pool);
+	kfree(buffer->pool);
 }
 
 /*
@@ -181,24 +181,19 @@ void dapl_cb_free(struct dapl_cookie_buf
 u32 dapl_cb_get(struct dapl_cookie_buffer *buffer,
 		struct dapl_cookie **cookie_ptr)
 {
-	u32 dat_status;
 	int new_head;
 
 	BUG_ON(cookie_ptr == NULL);
 
 	new_head = (atomic_read(&buffer->head) + 1) % buffer->pool_size;
 
-	if (new_head == atomic_read(&buffer->tail)) {
-		dat_status = DAT_INSUFFICIENT_RESOURCES;
-		goto bail;
-	} else {
-		atomic_set(&buffer->head, new_head);
+	if (new_head == atomic_read(&buffer->tail))
+		return DAT_INSUFFICIENT_RESOURCES;
 
-		*cookie_ptr = &buffer->pool[atomic_read(&buffer->head)];
-		dat_status = DAT_SUCCESS;
-	}
-bail:
-	return dat_status;
+	atomic_set(&buffer->head, new_head);
+
+	*cookie_ptr = &buffer->pool[atomic_read(&buffer->head)];
+	return DAT_SUCCESS;
 }
 
 /*
@@ -224,24 +219,19 @@ u32 dapl_rmr_cookie_alloc(struct dapl_co
 			  struct dapl_cookie **cookie_ptr)
 {
 	struct dapl_cookie *cookie;
-	u32 dat_status;
 
 	if (DAT_SUCCESS != dapl_cb_get(buffer, &cookie)) {
 		*cookie_ptr = NULL;
-		dat_status =
-		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-		goto bail;
+		return DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
+				 DAT_RESOURCE_MEMORY);
 	}
 
-	dat_status = DAT_SUCCESS;
 	cookie->type = DAPL_COOKIE_TYPE_RMR;
 	cookie->val.rmr.rmr = rmr;
 	cookie->val.rmr.cookie = user_cookie;
 
 	*cookie_ptr = cookie;
-
-bail:
-	return dat_status;
+	return DAT_SUCCESS;
 }
 
 /*


More information about the general mailing list