From: Markus Elfring <[email protected]>
Date: Sat, 10 Sep 2016 15:50:25 +0200

1. Return an error code without storing it in a local variable.

2. Do not use curly brackets at one source code place
   where a single statement should be sufficient.

3. Delete the local variable "ret" which became unnecessary with
   this refactoring.

Signed-off-by: Markus Elfring <[email protected]>
---
 drivers/auxdisplay/cfag12864b.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index b471b28..b2533e2 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -329,8 +329,6 @@ EXPORT_SYMBOL_GPL(cfag12864b_isinited);
 
 static int __init cfag12864b_init(void)
 {
-       int ret;
-
        /* ks0108_init() must be called first */
        if (!ks0108_isinited()) {
                printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
@@ -349,10 +347,8 @@ static int __init cfag12864b_init(void)
        cfag12864b_cache = kmalloc_array(CFAG12864B_SIZE,
                                         sizeof(*cfag12864b_cache),
                                         GFP_KERNEL);
-       if (cfag12864b_cache == NULL) {
-               ret = -ENOMEM;
+       if (!cfag12864b_cache)
                goto free_buffer;
-       }
 
        cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
        if (cfag12864b_workqueue == NULL)
@@ -367,7 +363,7 @@ static int __init cfag12864b_init(void)
        kfree(cfag12864b_cache);
  free_buffer:
        free_page((unsigned long) cfag12864b_buffer);
-       return ret;
+       return -ENOMEM;
 }
 
 static void __exit cfag12864b_exit(void)
-- 
2.10.0

Reply via email to