public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] VMCI: Remove redundant error check
@ 2014-05-17 18:22 Peter Senna Tschudin
  2014-05-17 19:54 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Senna Tschudin @ 2014-05-17 18:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Peter Senna Tschudin, kernel-janitors

Remove double checks, and move the call to pr_devel to the
first check. The simplified version of the coccinelle semantic
patch that fixes this issue is as follows:

// <smpl>
@@
expression E; identifier pr; expression list es;
@@
for(...;...;...){
...
-	if (E) break;
+	if (E){
+		pr(es);
+		break;
+	}
...
}
- if(E) pr(es);
// </smpl>

Tested by compilation only.

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>

---
 drivers/misc/vmw_vmci/vmci_context.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
index f866a4b..3995e64 100644
--- a/drivers/misc/vmw_vmci/vmci_context.c
+++ b/drivers/misc/vmw_vmci/vmci_context.c
@@ -836,12 +836,12 @@ int vmci_ctx_set_chkpt_state(u32 context_id,
 	for (i = 0; i < num_ids && result = VMCI_SUCCESS; i++) {
 		current_id = ((u32 *)cpt_buf)[i];
 		result = vmci_ctx_add_notification(context_id, current_id);
-		if (result != VMCI_SUCCESS)
+		if (result != VMCI_SUCCESS) {
+			pr_devel("Failed to set cpt state (type=%d) (error=%d)\n",
+				 cpt_type, result);
 			break;
+		}
 	}
-	if (result != VMCI_SUCCESS)
-		pr_devel("Failed to set cpt state (type=%d) (error=%d)\n",
-			 cpt_type, result);
 
 	return result;
 }


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-17 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-17 18:22 [PATCH 1/4] VMCI: Remove redundant error check Peter Senna Tschudin
2014-05-17 19:54 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox