diff mbox series

[3/3] hw/qdev-clock: Display error hint when clock is missing from device

Message ID 20200927090820.61859-4-f4bug@amsat.org (mailing list archive)
State New, archived
Headers show
Series qdev-clock: Minor improvements to the Clock API | expand

Commit Message

Philippe Mathieu-Daudé Sept. 27, 2020, 9:08 a.m. UTC
Instead of directly aborting, display a hint to help the developer
figure out the problem (likely trying to connect a clock to a device
pre-dating the Clock API, thus not expecting clocks).

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/core/qdev-clock.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Luc Michel Sept. 28, 2020, 7:53 a.m. UTC | #1
On 11:08 Sun 27 Sep     , Philippe Mathieu-Daudé wrote:
> Instead of directly aborting, display a hint to help the developer
> figure out the problem (likely trying to connect a clock to a device
> pre-dating the Clock API, thus not expecting clocks).
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Reviewed-by: Luc Michel <luc@lmichel.fr>

> ---
>  hw/core/qdev-clock.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
> index 47ecb5b4fae..33bd4a9d520 100644
> --- a/hw/core/qdev-clock.c
> +++ b/hw/core/qdev-clock.c
> @@ -12,6 +12,7 @@
>   */
>  
>  #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
>  #include "hw/qdev-clock.h"
>  #include "hw/qdev-core.h"
>  #include "qapi/error.h"
> @@ -153,6 +154,11 @@ Clock *qdev_get_clock_in(DeviceState *dev, const char *name)
>      assert(name);
>  
>      ncl = qdev_get_clocklist(dev, name);
> +    if (!ncl) {
> +        error_report("can not find clock-in '%s' for device type '%s'",
> +                     name, object_get_typename(OBJECT(dev)));
> +        abort();
> +    }
>      assert(!ncl->output);
>  
>      return ncl->clock;
> @@ -165,6 +171,11 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name)
>      assert(name);
>  
>      ncl = qdev_get_clocklist(dev, name);
> +    if (!ncl) {
> +        error_report("can not find clock-out '%s' for device type '%s'",
> +                     name, object_get_typename(OBJECT(dev)));
> +        abort();
> +    }
>      assert(ncl->output);
>  
>      return ncl->clock;
> -- 
> 2.26.2
>
Damien Hedde Sept. 28, 2020, 10:45 a.m. UTC | #2
On 9/28/20 9:53 AM, Luc Michel wrote:
> On 11:08 Sun 27 Sep     , Philippe Mathieu-Daudé wrote:
>> Instead of directly aborting, display a hint to help the developer
>> figure out the problem (likely trying to connect a clock to a device
>> pre-dating the Clock API, thus not expecting clocks).
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Reviewed-by: Luc Michel <luc@lmichel.fr>

Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>

> 
>> ---
>>  hw/core/qdev-clock.c | 11 +++++++++++
>>  1 file changed, 11 insertions(+)
>>
>> diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
>> index 47ecb5b4fae..33bd4a9d520 100644
>> --- a/hw/core/qdev-clock.c
>> +++ b/hw/core/qdev-clock.c
>> @@ -12,6 +12,7 @@
>>   */
>>  
>>  #include "qemu/osdep.h"
>> +#include "qemu/error-report.h"
>>  #include "hw/qdev-clock.h"
>>  #include "hw/qdev-core.h"
>>  #include "qapi/error.h"
>> @@ -153,6 +154,11 @@ Clock *qdev_get_clock_in(DeviceState *dev, const char *name)
>>      assert(name);
>>  
>>      ncl = qdev_get_clocklist(dev, name);
>> +    if (!ncl) {
>> +        error_report("can not find clock-in '%s' for device type '%s'",
>> +                     name, object_get_typename(OBJECT(dev)));
>> +        abort();
>> +    }
>>      assert(!ncl->output);
>>  
>>      return ncl->clock;
>> @@ -165,6 +171,11 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name)
>>      assert(name);
>>  
>>      ncl = qdev_get_clocklist(dev, name);
>> +    if (!ncl) {
>> +        error_report("can not find clock-out '%s' for device type '%s'",
>> +                     name, object_get_typename(OBJECT(dev)));
>> +        abort();
>> +    }
>>      assert(ncl->output);
>>  
>>      return ncl->clock;
>> -- 
>> 2.26.2
>>
Edgar E. Iglesias Sept. 28, 2020, 10:48 a.m. UTC | #3
On Mon, Sep 28, 2020 at 12:45:15PM +0200, Damien Hedde wrote:
> 
> 
> On 9/28/20 9:53 AM, Luc Michel wrote:
> > On 11:08 Sun 27 Sep     , Philippe Mathieu-Daudé wrote:
> >> Instead of directly aborting, display a hint to help the developer
> >> figure out the problem (likely trying to connect a clock to a device
> >> pre-dating the Clock API, thus not expecting clocks).
> >>
> >> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> > 
> > Reviewed-by: Luc Michel <luc@lmichel.fr>
> 
> Reviewed-by: Damien Hedde <damien.hedde@greensocs.com>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> 
> > 
> >> ---
> >>  hw/core/qdev-clock.c | 11 +++++++++++
> >>  1 file changed, 11 insertions(+)
> >>
> >> diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
> >> index 47ecb5b4fae..33bd4a9d520 100644
> >> --- a/hw/core/qdev-clock.c
> >> +++ b/hw/core/qdev-clock.c
> >> @@ -12,6 +12,7 @@
> >>   */
> >>  
> >>  #include "qemu/osdep.h"
> >> +#include "qemu/error-report.h"
> >>  #include "hw/qdev-clock.h"
> >>  #include "hw/qdev-core.h"
> >>  #include "qapi/error.h"
> >> @@ -153,6 +154,11 @@ Clock *qdev_get_clock_in(DeviceState *dev, const char *name)
> >>      assert(name);
> >>  
> >>      ncl = qdev_get_clocklist(dev, name);
> >> +    if (!ncl) {
> >> +        error_report("can not find clock-in '%s' for device type '%s'",
> >> +                     name, object_get_typename(OBJECT(dev)));
> >> +        abort();
> >> +    }
> >>      assert(!ncl->output);
> >>  
> >>      return ncl->clock;
> >> @@ -165,6 +171,11 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name)
> >>      assert(name);
> >>  
> >>      ncl = qdev_get_clocklist(dev, name);
> >> +    if (!ncl) {
> >> +        error_report("can not find clock-out '%s' for device type '%s'",
> >> +                     name, object_get_typename(OBJECT(dev)));
> >> +        abort();
> >> +    }
> >>      assert(ncl->output);
> >>  
> >>      return ncl->clock;
> >> -- 
> >> 2.26.2
> >>
diff mbox series

Patch

diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
index 47ecb5b4fae..33bd4a9d520 100644
--- a/hw/core/qdev-clock.c
+++ b/hw/core/qdev-clock.c
@@ -12,6 +12,7 @@ 
  */
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
 #include "hw/qdev-clock.h"
 #include "hw/qdev-core.h"
 #include "qapi/error.h"
@@ -153,6 +154,11 @@  Clock *qdev_get_clock_in(DeviceState *dev, const char *name)
     assert(name);
 
     ncl = qdev_get_clocklist(dev, name);
+    if (!ncl) {
+        error_report("can not find clock-in '%s' for device type '%s'",
+                     name, object_get_typename(OBJECT(dev)));
+        abort();
+    }
     assert(!ncl->output);
 
     return ncl->clock;
@@ -165,6 +171,11 @@  Clock *qdev_get_clock_out(DeviceState *dev, const char *name)
     assert(name);
 
     ncl = qdev_get_clocklist(dev, name);
+    if (!ncl) {
+        error_report("can not find clock-out '%s' for device type '%s'",
+                     name, object_get_typename(OBJECT(dev)));
+        abort();
+    }
     assert(ncl->output);
 
     return ncl->clock;