diff mbox

[3/3] Target-ppc: Remove unnecessary variable

Message ID 1443170278-9318-3-git-send-email-shraddha.6596@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shraddha Barke Sept. 25, 2015, 8:37 a.m. UTC
Compress lines and remove the variable.

Change made using Coccinelle script

@@
expression ret;
@@
- if (ret) return ret;
- return 0;
+ return ret;
@@
local idexpression ret;
expression e;
@@
- ret = e;
- return ret;
+ return e;
@@
type T; identifier i;
@@
- T i;
... when != i

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
 target-ppc/kvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Eric Blake Sept. 26, 2015, 4:15 p.m. UTC | #1
On 09/25/2015 02:37 AM, Shraddha Barke wrote:
> Compress lines and remove the variable.
> 

> +++ b/target-ppc/kvm.c
> @@ -1782,8 +1782,7 @@ uint32_t kvmppc_get_tbfreq(void)
>  
>      ns++;
>  
> -    retval = atoi(ns);
> -    return retval;
> +    return atoi(ns);

atoi() is lousy; it cannot properly detect user input errors.  This
should probably be converted to use the appropriate qemu_strtol variant
instead.
Paolo Bonzini Sept. 28, 2015, 10:56 a.m. UTC | #2
On 26/09/2015 18:15, Eric Blake wrote:
> On 09/25/2015 02:37 AM, Shraddha Barke wrote:
>> Compress lines and remove the variable.
>>
> 
>> +++ b/target-ppc/kvm.c
>> @@ -1782,8 +1782,7 @@ uint32_t kvmppc_get_tbfreq(void)
>>  
>>      ns++;
>>  
>> -    retval = atoi(ns);
>> -    return retval;
>> +    return atoi(ns);
> 
> atoi() is lousy; it cannot properly detect user input errors.  This
> should probably be converted to use the appropriate qemu_strtol variant
> instead.

But it's more or less okay here, it's parsing /proc/cpuinfo.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michael Tokarev Oct. 3, 2015, 4:50 p.m. UTC | #3
25.09.2015 11:37, Shraddha Barke wrote:
> Compress lines and remove the variable.

Applied to -trivial, removing this piece of commit message:

---
> Change made using Coccinelle script
> 
> @@
> expression ret;
> @@
> - if (ret) return ret;
> - return 0;
> + return ret;
> @@
> local idexpression ret;
> expression e;
> @@
> - ret = e;
> - return ret;
> + return e;
> @@
> type T; identifier i;
> @@
> - T i;
> ... when != i
---

Thanks,

/mjt
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 110436d..a3fb4c0 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1782,8 +1782,7 @@  uint32_t kvmppc_get_tbfreq(void)
 
     ns++;
 
-    retval = atoi(ns);
-    return retval;
+    return atoi(ns);
 }
 
 bool kvmppc_get_host_serial(char **value)