Skip to contentSkip to conversation

Staging: lustre: Remove print statement on function failure

PATCH New Bhumika Goyal 1 participant 1 message Feb 28, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: lustre: Remove print statement on function failure

The memory allocation functions generates a call stack containing all the context information on failure, so print statements can be removed on failure of these functions. Also remove unwanted {} around if block after removal of these statements. Done using coccinelle:

@@
expression e,e1,e2;
identifier x;
@@
e=\(kmalloc\|kmalloc_array\|kzalloc\|
devm_kzalloc\)(...);
...when!=e=e1
if(!e)
-{
- \(printk\|DBG_8723A\|pr_err\|CERROR\|DBG_88E\)(...); (
goto x;
|
return e2;
|
return;
)
-}

---
Changes in v2:
* Improve the semantic patch and use special case in this case as there are only two stataments in if condition.

 drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c | 4 +---
 drivers/staging/lustre/lustre/obdclass/llog.c             | 4 +---
 drivers/staging/lustre/lustre/obdecho/echo_client.c       | 5 +----
 3 files changed, 3 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +1 -3
index ec75801..1d2f70f 100644
@@ -251,10 +251,8 @@ static int cfs_crypto_test_hashes(void)
 	unsigned int	    data_len = 1 * 128 * 1024;
 
 	data = kmalloc(data_len, 0);
-	if (!data) {
-		CERROR("Failed to allocate mem\n");
+	if (!data)
 		return -ENOMEM;
-	}
 
 	for (j = 0; j < data_len; j++)
 		data[j] = j & 0xff;
drivers/staging/lustre/lustre/obdclass/llog.c +1 -3
index f7ee605..992573e 100644
@@ -365,10 +365,8 @@ int llog_process_or_fork(const struct lu_env *env,
 	int		      rc;
 
 	lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
-	if (!lpi) {
-		CERROR("cannot alloc pointer\n");
+	if (!lpi)
 		return -ENOMEM;
-	}
 	lpi->lpi_loghandle = loghandle;
 	lpi->lpi_cb	= cb;
 	lpi->lpi_cbdata    = data;
drivers/staging/lustre/lustre/obdecho/echo_client.c +1 -4
index 2b13aa2..1d4b3a9 100644
@@ -1766,11 +1766,8 @@ static int echo_client_setup(const struct lu_env *env,
 	ec->ec_unique = 0;
 
 	ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
-	if (!ocd) {
-		CERROR("Can't alloc ocd connecting to %s\n",
-		       lustre_cfg_string(lcfg, 1));
+	if (!ocd)
 		return -ENOMEM;
-	}
 
 	ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_REQPORTAL |
 				 OBD_CONNECT_BRW_SIZE |
Signature · 1 line
1.9.1