diff mbox

[3/5] hw/input/tsc210x: Remove superfluous memset

Message ID 1444332916-16476-4-git-send-email-thuth@redhat.com
State New
Headers show

Commit Message

Thomas Huth Oct. 8, 2015, 7:35 p.m. UTC
g_malloc0 already clears the memory, so no need for additional
memsets here. And while we're at it, let's also remove the
superfluous typecasts for the return values of g_malloc0.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/input/tsc210x.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Eric Blake Oct. 8, 2015, 11:34 p.m. UTC | #1
On 10/08/2015 01:35 PM, Thomas Huth wrote:
> g_malloc0 already clears the memory, so no need for additional
> memsets here. And while we're at it, let's also remove the
> superfluous typecasts for the return values of g_malloc0.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/input/tsc210x.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
> index fae3385..92b076a 100644
> --- a/hw/input/tsc210x.c
> +++ b/hw/input/tsc210x.c
> @@ -1086,9 +1086,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)
>  {
>      TSC210xState *s;
>  
> -    s = (TSC210xState *)
> -            g_malloc0(sizeof(TSC210xState));
> -    memset(s, 0, sizeof(TSC210xState));
> +    s = g_malloc0(sizeof(TSC210xState));

This should probably be g_new0(TSC210xState, 1), consistent with Markus'
recent cleanup patches.

>      s->x = 160;
>      s->y = 160;
>      s->pressure = 0;
> @@ -1135,9 +1133,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
>  {
>      TSC210xState *s;
>  
> -    s = (TSC210xState *)
> -            g_malloc0(sizeof(TSC210xState));
> -    memset(s, 0, sizeof(TSC210xState));
> +    s = g_malloc0(sizeof(TSC210xState));

Likewise.
Thomas Huth Oct. 9, 2015, 6:40 a.m. UTC | #2
On 09/10/15 01:34, Eric Blake wrote:
> On 10/08/2015 01:35 PM, Thomas Huth wrote:
>> g_malloc0 already clears the memory, so no need for additional
>> memsets here. And while we're at it, let's also remove the
>> superfluous typecasts for the return values of g_malloc0.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  hw/input/tsc210x.c | 8 ++------
>>  1 file changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
>> index fae3385..92b076a 100644
>> --- a/hw/input/tsc210x.c
>> +++ b/hw/input/tsc210x.c
>> @@ -1086,9 +1086,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)
>>  {
>>      TSC210xState *s;
>>  
>> -    s = (TSC210xState *)
>> -            g_malloc0(sizeof(TSC210xState));
>> -    memset(s, 0, sizeof(TSC210xState));
>> +    s = g_malloc0(sizeof(TSC210xState));
> 
> This should probably be g_new0(TSC210xState, 1), consistent with Markus'
> recent cleanup patches.

Ok, I'll change my patch.

 Thomas
diff mbox

Patch

diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
index fae3385..92b076a 100644
--- a/hw/input/tsc210x.c
+++ b/hw/input/tsc210x.c
@@ -1086,9 +1086,7 @@  uWireSlave *tsc2102_init(qemu_irq pint)
 {
     TSC210xState *s;
 
-    s = (TSC210xState *)
-            g_malloc0(sizeof(TSC210xState));
-    memset(s, 0, sizeof(TSC210xState));
+    s = g_malloc0(sizeof(TSC210xState));
     s->x = 160;
     s->y = 160;
     s->pressure = 0;
@@ -1135,9 +1133,7 @@  uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)
 {
     TSC210xState *s;
 
-    s = (TSC210xState *)
-            g_malloc0(sizeof(TSC210xState));
-    memset(s, 0, sizeof(TSC210xState));
+    s = g_malloc0(sizeof(TSC210xState));
     s->x = 400;
     s->y = 240;
     s->pressure = 0;