Skip to contentSkip to conversation

Staging: android: ion: ion.c: Compression of lines for

PATCH In review Nadim almas 2 participants 2 messages Jul 30, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 33/33 Staging: android: ion: ion.c: Compression of lines for

This patch compresses two lines in to a single line in file rtw_android.c if immediate return statement is found. It also removes variable bytes_written as it is no longer needed.

It is done using script Coccinelle. And coccinelle uses following semantic patch for this compression function:

@@
expression e, ret;
@@

-ret =
+return

     e;

-return ret;

---
 drivers/staging/android/ion/ion.c          | 8 +++-----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/android/ion/ion.c +3 -6
index 52345df..271395b 100644
@@ -391,9 +391,7 @@ static int ion_handle_put_nolock(struct ion_handle *handle)
 {
-	int ret;
 
-	ret = kref_put(&handle->ref, ion_handle_destroy);
-
-	return ret;
+        return kref_put(&handle->ref, ion_handle_destroy);
 }
 
 static int ion_handle_put(struct ion_handle *handle)
@@ -597,8 +595,8 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle,
 		return -ENODEV;
 	}
 	mutex_unlock(&client->lock);
-	ret = buffer->heap->ops->phys(buffer->heap, buffer, addr, len);
-	return ret;
+	
+        return buffer->heap->ops->phys(buffer->heap, buffer, addr, len);
 }
 EXPORT_SYMBOL(ion_phys);
 
#1 lore raw

drivers/staging/android/ion/ion.c

Quoted 23 lines · Nadim almas

This patch compresses two lines in to a single line in file rtw_android.c if immediate return statement is found. It also removes variable bytes_written as it is no longer needed.

It is done using script Coccinelle. And coccinelle uses following semantic patch for this compression function:

@@
expression e, ret;
@@

(quoted diff) +1 -1
-ret =
+return

     e;
-return ret;

---
 drivers/staging/android/ion/ion.c          | 8 +++-----

 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/android/ion/ion.c +0 -0

[]

drivers/staging/android/ion/ion.c int ion_phys(struct ion_client *client, struct ion_handle *handle, · line 601

Quoted 10 lines
drivers/staging/android/ion/ion.c +2 -2
@@ -597,8 +595,8 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle,
  		return -ENODEV;
  	}
  	mutex_unlock(&client->lock);
-	ret = buffer->heap->ops->phys(buffer->heap, buffer, addr, len);
-	return ret;
+	
+        return buffer->heap->ops->phys(buffer->heap, buffer, addr, len);
  }
  EXPORT_SYMBOL(ion_phys);

How unfortunate you didn't heed the advice given.. I'll bet you didn't compile this.