qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation
@ 2012-02-17 16:23 Meador Inge
  2012-02-17 16:28 ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Meador Inge @ 2012-02-17 16:23 UTC (permalink / raw)
  To: qemu-devel

Fix a bug introduced by commit 1ec9b909ff207a44d5ef2609cb4a2e3d449d485f
where 'watch_mem_write' was modified to fall-through to 'abort' on
every input.

Signed-off-by: Meador Inge <meadori@codesourcery.com>
---
 exec.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/exec.c b/exec.c
index b81677a..fe8b2d1 100644
--- a/exec.c
+++ b/exec.c
@@ -3289,9 +3289,9 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
 {
     check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
     switch (size) {
-    case 1: stb_phys(addr, val);
-    case 2: stw_phys(addr, val);
-    case 4: stl_phys(addr, val);
+    case 1: return stb_phys(addr, val);
+    case 2: return stw_phys(addr, val);
+    case 4: return stl_phys(addr, val);
     default: abort();
     }
 }
-- 
1.7.7.6

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

* Re: [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation
  2012-02-17 16:23 [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation Meador Inge
@ 2012-02-17 16:28 ` Jan Kiszka
  2012-02-17 16:36   ` Meador Inge
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2012-02-17 16:28 UTC (permalink / raw)
  To: Meador Inge; +Cc: qemu-devel

On 2012-02-17 17:23, Meador Inge wrote:
> Fix a bug introduced by commit 1ec9b909ff207a44d5ef2609cb4a2e3d449d485f
> where 'watch_mem_write' was modified to fall-through to 'abort' on
> every input.
> 
> Signed-off-by: Meador Inge <meadori@codesourcery.com>
> ---
>  exec.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index b81677a..fe8b2d1 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3289,9 +3289,9 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
>  {
>      check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
>      switch (size) {
> -    case 1: stb_phys(addr, val);
> -    case 2: stw_phys(addr, val);
> -    case 4: stl_phys(addr, val);
> +    case 1: return stb_phys(addr, val);
> +    case 2: return stw_phys(addr, val);
> +    case 4: return stl_phys(addr, val);
>      default: abort();
>      }
>  }

You likely wanted to introduce breaks here, no...?

At this chance, please indent the code properly according to our coding
style:

    switch ...
    case ...
        xxx;
        break;

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

* Re: [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation
  2012-02-17 16:28 ` Jan Kiszka
@ 2012-02-17 16:36   ` Meador Inge
  2012-02-17 16:44     ` Jan Kiszka
  0 siblings, 1 reply; 4+ messages in thread
From: Meador Inge @ 2012-02-17 16:36 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel

On 02/17/2012 10:28 AM, Jan Kiszka wrote:

> On 2012-02-17 17:23, Meador Inge wrote:
>> Fix a bug introduced by commit 1ec9b909ff207a44d5ef2609cb4a2e3d449d485f
>> where 'watch_mem_write' was modified to fall-through to 'abort' on
>> every input.
>>
>> Signed-off-by: Meador Inge <meadori@codesourcery.com>
>> ---
>>  exec.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/exec.c b/exec.c
>> index b81677a..fe8b2d1 100644
>> --- a/exec.c
>> +++ b/exec.c
>> @@ -3289,9 +3289,9 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
>>  {
>>      check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
>>      switch (size) {
>> -    case 1: stb_phys(addr, val);
>> -    case 2: stw_phys(addr, val);
>> -    case 4: stl_phys(addr, val);
>> +    case 1: return stb_phys(addr, val);
>> +    case 2: return stw_phys(addr, val);
>> +    case 4: return stl_phys(addr, val);
>>      default: abort();
>>      }
>>  }
> 
> You likely wanted to introduce breaks here, no...?

I see both styles in 'exec.c'.  An example similar to the above is:

static void subpage_ram_write(void *opaque, target_phys_addr_t addr,
                              uint64_t value, unsigned size)
{
    ram_addr_t raddr = addr;
    void *ptr = qemu_get_ram_ptr(raddr);
    switch (size) {
    case 1: return stb_p(ptr, value);
    case 2: return stw_p(ptr, value);
    case 4: return stl_p(ptr, value);
    default: abort();
    }
}

I will switch to the 'break' style if that is more consistent with the general
coding convention.

-- 
Meador Inge
CodeSourcery / Mentor Embedded
http://www.mentor.com/embedded-software

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

* Re: [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation
  2012-02-17 16:36   ` Meador Inge
@ 2012-02-17 16:44     ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2012-02-17 16:44 UTC (permalink / raw)
  To: Meador Inge; +Cc: qemu-devel@nongnu.org

On 2012-02-17 17:36, Meador Inge wrote:
> On 02/17/2012 10:28 AM, Jan Kiszka wrote:
> 
>> On 2012-02-17 17:23, Meador Inge wrote:
>>> Fix a bug introduced by commit 1ec9b909ff207a44d5ef2609cb4a2e3d449d485f
>>> where 'watch_mem_write' was modified to fall-through to 'abort' on
>>> every input.
>>>
>>> Signed-off-by: Meador Inge <meadori@codesourcery.com>
>>> ---
>>>  exec.c |    6 +++---
>>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/exec.c b/exec.c
>>> index b81677a..fe8b2d1 100644
>>> --- a/exec.c
>>> +++ b/exec.c
>>> @@ -3289,9 +3289,9 @@ static void watch_mem_write(void *opaque, target_phys_addr_t addr,
>>>  {
>>>      check_watchpoint(addr & ~TARGET_PAGE_MASK, ~(size - 1), BP_MEM_WRITE);
>>>      switch (size) {
>>> -    case 1: stb_phys(addr, val);
>>> -    case 2: stw_phys(addr, val);
>>> -    case 4: stl_phys(addr, val);
>>> +    case 1: return stb_phys(addr, val);
>>> +    case 2: return stw_phys(addr, val);
>>> +    case 4: return stl_phys(addr, val);
>>>      default: abort();
>>>      }
>>>  }
>>
>> You likely wanted to introduce breaks here, no...?
> 
> I see both styles in 'exec.c'.  An example similar to the above is:

There is a lot of legacy code in QEMU. Better look at CODING_STYLE when
in doubt.

> 
> static void subpage_ram_write(void *opaque, target_phys_addr_t addr,
>                               uint64_t value, unsigned size)
> {
>     ram_addr_t raddr = addr;
>     void *ptr = qemu_get_ram_ptr(raddr);
>     switch (size) {
>     case 1: return stb_p(ptr, value);
>     case 2: return stw_p(ptr, value);
>     case 4: return stl_p(ptr, value);
>     default: abort();
>     }
> }
> 
> I will switch to the 'break' style if that is more consistent with the general
> coding convention.

That's also nonsense: neither st*_p nor st*_phys return anything else
than void.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

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

end of thread, other threads:[~2012-02-17 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 16:23 [Qemu-devel] [PATCH v1 1/1] exec: Fix watchpoint implementation Meador Inge
2012-02-17 16:28 ` Jan Kiszka
2012-02-17 16:36   ` Meador Inge
2012-02-17 16:44     ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).