* [PULL v2 44/61] hw/sensor/tmp105: Coding style fixes
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 45/61] hw/sensor/tmp105: Use registerfields API Philippe Mathieu-Daudé
` (12 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Guenter Roeck <linux@roeck-us.net>
Coding style asks for no space between variable and "++". The next patch
in this series will change one of those assignments. Instead of changing
just one with that patch, change all of them for consistency.
While at it, also fix other coding style problems reported by checkpatch.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20240906154911.86803-2-philmd@linaro.org>
---
hw/sensor/tmp105.c | 44 ++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index a8730d0b7f..ad97c9684c 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -29,16 +29,17 @@
static void tmp105_interrupt_update(TMP105State *s)
{
- qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */
+ qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */
}
static void tmp105_alarm_update(TMP105State *s)
{
- if ((s->config >> 0) & 1) { /* SD */
- if ((s->config >> 7) & 1) /* OS */
- s->config &= ~(1 << 7); /* OS */
- else
+ if ((s->config >> 0) & 1) { /* SD */
+ if ((s->config >> 7) & 1) { /* OS */
+ s->config &= ~(1 << 7); /* OS */
+ } else {
return;
+ }
}
if (s->config >> 1 & 1) {
@@ -89,7 +90,8 @@ static void tmp105_get_temperature(Object *obj, Visitor *v, const char *name,
visit_type_int(v, name, &value, errp);
}
-/* Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8
+/*
+ * Units are 0.001 centigrades relative to 0 C. s->temperature is 8.8
* fixed point, so units are 1/256 centigrades. A simple ratio will do.
*/
static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name,
@@ -118,30 +120,30 @@ static void tmp105_read(TMP105State *s)
{
s->len = 0;
- if ((s->config >> 1) & 1) { /* TM */
+ if ((s->config >> 1) & 1) { /* TM */
s->alarm = 0;
tmp105_interrupt_update(s);
}
switch (s->pointer & 3) {
case TMP105_REG_TEMPERATURE:
- s->buf[s->len ++] = (((uint16_t) s->temperature) >> 8);
- s->buf[s->len ++] = (((uint16_t) s->temperature) >> 0) &
- (0xf0 << ((~s->config >> 5) & 3)); /* R */
+ s->buf[s->len++] = (((uint16_t) s->temperature) >> 8);
+ s->buf[s->len++] = (((uint16_t) s->temperature) >> 0) &
+ (0xf0 << ((~s->config >> 5) & 3)); /* R */
break;
case TMP105_REG_CONFIG:
- s->buf[s->len ++] = s->config;
+ s->buf[s->len++] = s->config;
break;
case TMP105_REG_T_LOW:
- s->buf[s->len ++] = ((uint16_t) s->limit[0]) >> 8;
- s->buf[s->len ++] = ((uint16_t) s->limit[0]) >> 0;
+ s->buf[s->len++] = ((uint16_t) s->limit[0]) >> 8;
+ s->buf[s->len++] = ((uint16_t) s->limit[0]) >> 0;
break;
case TMP105_REG_T_HIGH:
- s->buf[s->len ++] = ((uint16_t) s->limit[1]) >> 8;
- s->buf[s->len ++] = ((uint16_t) s->limit[1]) >> 0;
+ s->buf[s->len++] = ((uint16_t) s->limit[1]) >> 8;
+ s->buf[s->len++] = ((uint16_t) s->limit[1]) >> 0;
break;
}
}
@@ -153,18 +155,20 @@ static void tmp105_write(TMP105State *s)
break;
case TMP105_REG_CONFIG:
- if (s->buf[0] & ~s->config & (1 << 0)) /* SD */
+ if (s->buf[0] & ~s->config & (1 << 0)) { /* SD */
printf("%s: TMP105 shutdown\n", __func__);
+ }
s->config = s->buf[0];
- s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
+ s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
tmp105_alarm_update(s);
break;
case TMP105_REG_T_LOW:
case TMP105_REG_T_HIGH:
- if (s->len >= 3)
+ if (s->len >= 3) {
s->limit[s->pointer & 1] = (int16_t)
((((uint16_t) s->buf[0]) << 8) | s->buf[1]);
+ }
tmp105_alarm_update(s);
break;
}
@@ -175,7 +179,7 @@ static uint8_t tmp105_rx(I2CSlave *i2c)
TMP105State *s = TMP105(i2c);
if (s->len < 2) {
- return s->buf[s->len ++];
+ return s->buf[s->len++];
} else {
return 0xff;
}
@@ -215,7 +219,7 @@ static int tmp105_post_load(void *opaque, int version_id)
{
TMP105State *s = opaque;
- s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
+ s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
tmp105_interrupt_update(s);
return 0;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 45/61] hw/sensor/tmp105: Use registerfields API
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 44/61] hw/sensor/tmp105: Coding style fixes Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 46/61] hw/sensor/tmp105: Pass 'oneshot' argument to tmp105_alarm_update() Philippe Mathieu-Daudé
` (11 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
To improve readability, use the registerfields API.
Define the register bits with FIELD(), and use the
FIELD_EX8() and FIELD_DP8() macros. Remove the
abbreviations in comments.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Message-Id: <20240906154911.86803-3-philmd@linaro.org>
---
hw/sensor/tmp105.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index ad97c9684c..150d09b278 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -26,23 +26,31 @@
#include "qapi/error.h"
#include "qapi/visitor.h"
#include "qemu/module.h"
+#include "hw/registerfields.h"
+
+FIELD(CONFIG, SHUTDOWN_MODE, 0, 1)
+FIELD(CONFIG, THERMOSTAT_MODE, 1, 1)
+FIELD(CONFIG, POLARITY, 2, 1)
+FIELD(CONFIG, FAULT_QUEUE, 3, 2)
+FIELD(CONFIG, CONVERTER_RESOLUTION, 5, 2)
+FIELD(CONFIG, ONE_SHOT, 7, 1)
static void tmp105_interrupt_update(TMP105State *s)
{
- qemu_set_irq(s->pin, s->alarm ^ ((~s->config >> 2) & 1)); /* POL */
+ qemu_set_irq(s->pin, s->alarm ^ FIELD_EX8(~s->config, CONFIG, POLARITY));
}
static void tmp105_alarm_update(TMP105State *s)
{
- if ((s->config >> 0) & 1) { /* SD */
- if ((s->config >> 7) & 1) { /* OS */
- s->config &= ~(1 << 7); /* OS */
+ if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) {
+ if (FIELD_EX8(s->config, CONFIG, ONE_SHOT)) {
+ s->config = FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0);
} else {
return;
}
}
- if (s->config >> 1 & 1) {
+ if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) {
/*
* TM == 1 : Interrupt mode. We signal Alert when the
* temperature rises above T_high, and expect the guest to clear
@@ -120,7 +128,7 @@ static void tmp105_read(TMP105State *s)
{
s->len = 0;
- if ((s->config >> 1) & 1) { /* TM */
+ if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) {
s->alarm = 0;
tmp105_interrupt_update(s);
}
@@ -129,7 +137,7 @@ static void tmp105_read(TMP105State *s)
case TMP105_REG_TEMPERATURE:
s->buf[s->len++] = (((uint16_t) s->temperature) >> 8);
s->buf[s->len++] = (((uint16_t) s->temperature) >> 0) &
- (0xf0 << ((~s->config >> 5) & 3)); /* R */
+ (0xf0 << (FIELD_EX8(~s->config, CONFIG, CONVERTER_RESOLUTION)));
break;
case TMP105_REG_CONFIG:
@@ -155,11 +163,11 @@ static void tmp105_write(TMP105State *s)
break;
case TMP105_REG_CONFIG:
- if (s->buf[0] & ~s->config & (1 << 0)) { /* SD */
+ if (FIELD_EX8(s->buf[0] & ~s->config, CONFIG, SHUTDOWN_MODE)) {
printf("%s: TMP105 shutdown\n", __func__);
}
s->config = s->buf[0];
- s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
+ s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
tmp105_alarm_update(s);
break;
@@ -219,7 +227,7 @@ static int tmp105_post_load(void *opaque, int version_id)
{
TMP105State *s = opaque;
- s->faults = tmp105_faultq[(s->config >> 3) & 3]; /* F */
+ s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
tmp105_interrupt_update(s);
return 0;
@@ -277,7 +285,7 @@ static void tmp105_reset(I2CSlave *i2c)
s->temperature = 0;
s->pointer = 0;
s->config = 0;
- s->faults = tmp105_faultq[(s->config >> 3) & 3];
+ s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
s->alarm = 0;
s->detect_falling = false;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 46/61] hw/sensor/tmp105: Pass 'oneshot' argument to tmp105_alarm_update()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 44/61] hw/sensor/tmp105: Coding style fixes Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 45/61] hw/sensor/tmp105: Use registerfields API Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 47/61] hw/sensor/tmp105: OS (one-shot) bit in config register always returns 0 Philippe Mathieu-Daudé
` (10 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
The next commit will clear the ONE_SHOT bit in the WRITE
path (to keep the READ path trivial). As a preliminary step,
pass the 'oneshot' value as argument to tmp105_alarm_update().
No logical change intended.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Message-Id: <20240906154911.86803-4-philmd@linaro.org>
---
hw/sensor/tmp105.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index 150d09b278..6740200aea 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -40,10 +40,10 @@ static void tmp105_interrupt_update(TMP105State *s)
qemu_set_irq(s->pin, s->alarm ^ FIELD_EX8(~s->config, CONFIG, POLARITY));
}
-static void tmp105_alarm_update(TMP105State *s)
+static void tmp105_alarm_update(TMP105State *s, bool one_shot)
{
if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) {
- if (FIELD_EX8(s->config, CONFIG, ONE_SHOT)) {
+ if (one_shot) {
s->config = FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0);
} else {
return;
@@ -119,7 +119,7 @@ static void tmp105_set_temperature(Object *obj, Visitor *v, const char *name,
s->temperature = (int16_t) (temp * 256 / 1000);
- tmp105_alarm_update(s);
+ tmp105_alarm_update(s, false);
}
static const int tmp105_faultq[4] = { 1, 2, 4, 6 };
@@ -168,7 +168,7 @@ static void tmp105_write(TMP105State *s)
}
s->config = s->buf[0];
s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
- tmp105_alarm_update(s);
+ tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT));
break;
case TMP105_REG_T_LOW:
@@ -177,7 +177,7 @@ static void tmp105_write(TMP105State *s)
s->limit[s->pointer & 1] = (int16_t)
((((uint16_t) s->buf[0]) << 8) | s->buf[1]);
}
- tmp105_alarm_update(s);
+ tmp105_alarm_update(s, false);
break;
}
}
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 47/61] hw/sensor/tmp105: OS (one-shot) bit in config register always returns 0
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 46/61] hw/sensor/tmp105: Pass 'oneshot' argument to tmp105_alarm_update() Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 48/61] hw/sensor/tmp105: Lower 4 bit of limit registers are always 0 Philippe Mathieu-Daudé
` (9 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
Per datasheet, "ONE-SHOT (OS)", the OS bit always returns 0 when reading
the configuration register.
Clear the ONE_SHOT bit in the WRITE path. Now than the READ path is
simpler, we can also simplify tmp105_alarm_update().
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20240906154911.86803-5-philmd@linaro.org>
---
hw/sensor/tmp105.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index 6740200aea..f5101af919 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -42,12 +42,8 @@ static void tmp105_interrupt_update(TMP105State *s)
static void tmp105_alarm_update(TMP105State *s, bool one_shot)
{
- if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE)) {
- if (one_shot) {
- s->config = FIELD_DP8(s->config, CONFIG, ONE_SHOT, 0);
- } else {
- return;
- }
+ if (FIELD_EX8(s->config, CONFIG, SHUTDOWN_MODE) && !one_shot) {
+ return;
}
if (FIELD_EX8(s->config, CONFIG, THERMOSTAT_MODE)) {
@@ -166,7 +162,7 @@ static void tmp105_write(TMP105State *s)
if (FIELD_EX8(s->buf[0] & ~s->config, CONFIG, SHUTDOWN_MODE)) {
printf("%s: TMP105 shutdown\n", __func__);
}
- s->config = s->buf[0];
+ s->config = FIELD_DP8(s->buf[0], CONFIG, ONE_SHOT, 0);
s->faults = tmp105_faultq[FIELD_EX8(s->config, CONFIG, FAULT_QUEUE)];
tmp105_alarm_update(s, FIELD_EX8(s->buf[0], CONFIG, ONE_SHOT));
break;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 48/61] hw/sensor/tmp105: Lower 4 bit of limit registers are always 0
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 47/61] hw/sensor/tmp105: OS (one-shot) bit in config register always returns 0 Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 51/61] hw/char: replace assert(0) with g_assert_not_reached() Philippe Mathieu-Daudé
` (8 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Guenter Roeck <linux@roeck-us.net>
Per datasheet, "HIGH AND LOW LIMIT REGISTERS", the lower 4 bit
of the limit registers are unused and always report 0.
The lower 4 bit should not be used for temperature comparisons,
so mask the unused bits before storing the limits.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20240906154911.86803-6-philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/sensor/tmp105.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/sensor/tmp105.c b/hw/sensor/tmp105.c
index f5101af919..9d7b911f59 100644
--- a/hw/sensor/tmp105.c
+++ b/hw/sensor/tmp105.c
@@ -171,7 +171,7 @@ static void tmp105_write(TMP105State *s)
case TMP105_REG_T_HIGH:
if (s->len >= 3) {
s->limit[s->pointer & 1] = (int16_t)
- ((((uint16_t) s->buf[0]) << 8) | s->buf[1]);
+ ((((uint16_t) s->buf[0]) << 8) | (s->buf[1] & 0xf0));
}
tmp105_alarm_update(s, false);
break;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 51/61] hw/char: replace assert(0) with g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 48/61] hw/sensor/tmp105: Lower 4 bit of limit registers are always 0 Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 52/61] hw/core: " Philippe Mathieu-Daudé
` (7 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
assert(0);
| }
| ^
Solve that by unifying the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-5-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/avr_usart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/char/avr_usart.c b/hw/char/avr_usart.c
index 5bcf9db0b7..e738a2ca97 100644
--- a/hw/char/avr_usart.c
+++ b/hw/char/avr_usart.c
@@ -86,7 +86,7 @@ static void update_char_mask(AVRUsartState *usart)
usart->char_mask = 0b11111111;
break;
default:
- assert(0);
+ g_assert_not_reached();
}
}
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 52/61] hw/core: replace assert(0) with g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 51/61] hw/char: replace assert(0) with g_assert_not_reached() Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 53/61] hw/watchdog: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
assert(0);
| }
| ^
Solve that by unifying the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-6-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/core/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/core/numa.c b/hw/core/numa.c
index fb81c1ed51..1b5f44baea 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -380,7 +380,7 @@ void parse_numa_hmat_lb(NumaState *numa_state, NumaHmatLBOptions *node,
}
lb_data.data = node->bandwidth;
} else {
- assert(0);
+ g_assert_not_reached();
}
g_array_append_val(hmat_lb->list, lb_data);
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 53/61] hw/watchdog: replace assert(0) with g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 52/61] hw/core: " Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 54/61] hw/gpio: remove break after g_assert_not_reached() Philippe Mathieu-Daudé
` (5 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
assert(0);
| }
| ^
Solve that by unifying the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-ID: <20240910221606.1817478-8-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/watchdog/watchdog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 955046161b..d0ce3c4ac5 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -85,7 +85,7 @@ void watchdog_perform_action(void)
break;
default:
- assert(0);
+ g_assert_not_reached();
}
}
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 54/61] hw/gpio: remove break after g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 53/61] hw/watchdog: " Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 55/61] hw/misc: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
g_assert_not_reached();
break;
| ^^^^^
Solve that by removing the unreachable 'break' statement, unifying
the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-28-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/gpio/nrf51_gpio.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/hw/gpio/nrf51_gpio.c b/hw/gpio/nrf51_gpio.c
index ffc7dff796..f259be651e 100644
--- a/hw/gpio/nrf51_gpio.c
+++ b/hw/gpio/nrf51_gpio.c
@@ -40,7 +40,6 @@ static bool is_connected(uint32_t config, uint32_t level)
break;
default:
g_assert_not_reached();
- break;
}
return state;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 55/61] hw/misc: remove break after g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 54/61] hw/gpio: remove break after g_assert_not_reached() Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 56/61] hw/pci-host: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
g_assert_not_reached();
break;
| ^^^^^
Solve that by removing the unreachable 'break' statement, unifying
the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-29-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/misc/imx6_ccm.c | 1 -
hw/misc/mac_via.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
index b1def7f05b..fd5d7ce482 100644
--- a/hw/misc/imx6_ccm.c
+++ b/hw/misc/imx6_ccm.c
@@ -301,7 +301,6 @@ static uint64_t imx6_analog_get_periph_clk(IMX6CCMState *dev)
default:
/* We should never get there */
g_assert_not_reached();
- break;
}
trace_imx6_analog_get_periph_clk(freq);
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
index 652395b84f..af2b2b1af3 100644
--- a/hw/misc/mac_via.c
+++ b/hw/misc/mac_via.c
@@ -495,7 +495,6 @@ static void via1_rtc_update(MOS6522Q800VIA1State *v1s)
break;
default:
g_assert_not_reached();
- break;
}
return;
}
@@ -556,7 +555,6 @@ static void via1_rtc_update(MOS6522Q800VIA1State *v1s)
break;
default:
g_assert_not_reached();
- break;
}
return;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 56/61] hw/pci-host: remove break after g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 55/61] hw/misc: " Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 57/61] system: replace assert(0) with g_assert_not_reached() Philippe Mathieu-Daudé
` (2 subsequent siblings)
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
g_assert_not_reached();
break;
| ^^^^^
Solve that by removing the unreachable 'break' statement, unifying
the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-31-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/pci-host/gt64120.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/hw/pci-host/gt64120.c b/hw/pci-host/gt64120.c
index 33607dfbec..5855741662 100644
--- a/hw/pci-host/gt64120.c
+++ b/hw/pci-host/gt64120.c
@@ -689,7 +689,6 @@ static void gt64120_writel(void *opaque, hwaddr addr,
case GT_PCI0_CFGDATA:
/* Mapped via in gt64120_pci_mapping() */
g_assert_not_reached();
- break;
/* Interrupts */
case GT_INTRCAUSE:
@@ -933,7 +932,6 @@ static uint64_t gt64120_readl(void *opaque,
case GT_PCI0_CFGDATA:
/* Mapped via in gt64120_pci_mapping() */
g_assert_not_reached();
- break;
case GT_PCI0_CMD:
case GT_PCI0_TOR:
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 57/61] system: replace assert(0) with g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 56/61] hw/pci-host: " Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-12 6:52 ` [PULL v2 61/61] ui: remove break after g_assert_not_reached() Philippe Mathieu-Daudé
2024-09-13 14:30 ` [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Peter Maydell
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
assert(0);
| }
| ^
Solve that by unifying the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-11-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
system/rtc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/rtc.c b/system/rtc.c
index dc44576686..216d2aee3a 100644
--- a/system/rtc.c
+++ b/system/rtc.c
@@ -62,7 +62,7 @@ static time_t qemu_ref_timedate(QEMUClockType clock)
}
break;
default:
- assert(0);
+ g_assert_not_reached();
}
return value;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PULL v2 61/61] ui: remove break after g_assert_not_reached()
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 57/61] system: replace assert(0) with g_assert_not_reached() Philippe Mathieu-Daudé
@ 2024-09-12 6:52 ` Philippe Mathieu-Daudé
2024-09-13 14:30 ` [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Peter Maydell
13 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-12 6:52 UTC (permalink / raw)
To: qemu-devel
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Use of assert(false) can trip spurious control flow warnings from
some versions of GCC (i.e. using -fsanitize=thread with gcc-12):
error: control reaches end of non-void function [-Werror=return-type]
default:
g_assert_not_reached();
break;
| ^^^^^
Solve that by removing the unreachable 'break' statement, unifying
the code base on g_assert_not_reached() instead.
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240910221606.1817478-37-pierrick.bouvier@linaro.org>
[PMD: Add description suggested by Eric Blake]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
ui/qemu-pixman.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c
index 5ca55dd199..6cada8b45e 100644
--- a/ui/qemu-pixman.c
+++ b/ui/qemu-pixman.c
@@ -49,7 +49,6 @@ PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format)
break;
default:
g_assert_not_reached();
- break;
}
pf.amax = (1 << pf.abits) - 1;
--
2.45.2
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PULL v2 00/61] Misc HW & UI patches for 2024-09-12
2024-09-12 6:52 [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2024-09-12 6:52 ` [PULL v2 61/61] ui: remove break after g_assert_not_reached() Philippe Mathieu-Daudé
@ 2024-09-13 14:30 ` Peter Maydell
2024-09-13 17:04 ` Philippe Mathieu-Daudé
13 siblings, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2024-09-13 14:30 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Thu, 12 Sept 2024 at 07:53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> v2:
> - Fill Pierrick's commit description suggested by Eric Blake
> - Include TMP105 fixes from Guenter
>
> The following changes since commit a4eb31c678400472de0b4915b9154a7c20d8332f:
>
> Merge tag 'pull-testing-gdbstub-oct-100924-1' of https://gitlab.com/stsquad/qemu into staging (2024-09-11 13:17:29 +0100)
>
> are available in the Git repository at:
>
> https://github.com/philmd/qemu.git tags/hw-misc-20240912
>
> for you to fetch changes up to bd480a2baab659abe90da878bc955670691f53a8:
>
> ui: remove break after g_assert_not_reached() (2024-09-12 08:44:48 +0200)
>
> ----------------------------------------------------------------
> Misc HW & UI patches
>
> - Remove deprecated SH4 SHIX machine TC58128 NAND EEPROM (Phil)
> - Remove deprecated CRIS target (Phil)
> - Remove deprecated RISC-V 'any' CPU type (Phil)
> - Add fifo8_peek_buf() to correctly handle FIFO wraparound (Mark)
> - Minor cleanups in Designware PCIe, PL011 and loongson IPI models (Phil)
> - Fixes in TI TMP105 temperature (Guenter)
> - Convert Sun ESCC and ADB mouses to QemuInputHandler (Mark)
> - Prevent heap overflow in VIRTIO sound device (Volker)
> - Cleanups around g_assert_not_reached() call (Pierrick)
> - Add Clément as VT-d reviewer (Clément)
> - Prevent stuck modifier keys and unexpected text input on Windows (Volker)
> - Explicitly set SDL2 swap interval when OpenGL is enabled (Gert)
Fails tests on some CI configs:
https://gitlab.com/qemu-project/qemu/-/jobs/7820098438
ERROR:../tests/qtest/tmp105-test.c:103:send_and_receive: assertion
failed (i2c_get16(i2cdev, TMP105_REG_T_LOW) == 0x1234): (0x00001230 ==
0x00001234)
(test program exited with status code -6)
https://gitlab.com/qemu-project/qemu/-/jobs/7820098228
ERROR:../tests/qtest/bcm2835-i2c-test.c:84:test_i2c_read_write:
assertion failed (i2cdata == 0xad): (160 == 173)
(test program exited with status code -6)
-- PMM
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PULL v2 00/61] Misc HW & UI patches for 2024-09-12
2024-09-13 14:30 ` [PULL v2 00/61] Misc HW & UI patches for 2024-09-12 Peter Maydell
@ 2024-09-13 17:04 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-09-13 17:04 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Guenter Roeck
On 13/9/24 16:30, Peter Maydell wrote:
> On Thu, 12 Sept 2024 at 07:53, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> v2:
>> - Fill Pierrick's commit description suggested by Eric Blake
>> - Include TMP105 fixes from Guenter
>>
>> The following changes since commit a4eb31c678400472de0b4915b9154a7c20d8332f:
>>
>> Merge tag 'pull-testing-gdbstub-oct-100924-1' of https://gitlab.com/stsquad/qemu into staging (2024-09-11 13:17:29 +0100)
>>
>> are available in the Git repository at:
>>
>> https://github.com/philmd/qemu.git tags/hw-misc-20240912
>>
>> for you to fetch changes up to bd480a2baab659abe90da878bc955670691f53a8:
>>
>> ui: remove break after g_assert_not_reached() (2024-09-12 08:44:48 +0200)
>>
>> ----------------------------------------------------------------
>> Misc HW & UI patches
>>
>> - Remove deprecated SH4 SHIX machine TC58128 NAND EEPROM (Phil)
>> - Remove deprecated CRIS target (Phil)
>> - Remove deprecated RISC-V 'any' CPU type (Phil)
>> - Add fifo8_peek_buf() to correctly handle FIFO wraparound (Mark)
>> - Minor cleanups in Designware PCIe, PL011 and loongson IPI models (Phil)
>> - Fixes in TI TMP105 temperature (Guenter)
>> - Convert Sun ESCC and ADB mouses to QemuInputHandler (Mark)
>> - Prevent heap overflow in VIRTIO sound device (Volker)
>> - Cleanups around g_assert_not_reached() call (Pierrick)
>> - Add Clément as VT-d reviewer (Clément)
>> - Prevent stuck modifier keys and unexpected text input on Windows (Volker)
>> - Explicitly set SDL2 swap interval when OpenGL is enabled (Gert)
>
> Fails tests on some CI configs:
>
> https://gitlab.com/qemu-project/qemu/-/jobs/7820098438
>
> ERROR:../tests/qtest/tmp105-test.c:103:send_and_receive: assertion
> failed (i2c_get16(i2cdev, TMP105_REG_T_LOW) == 0x1234): (0x00001230 ==
> 0x00001234)
> (test program exited with status code -6)
>
> https://gitlab.com/qemu-project/qemu/-/jobs/7820098228
>
> ERROR:../tests/qtest/bcm2835-i2c-test.c:84:test_i2c_read_write:
> assertion failed (i2cdata == 0xad): (160 == 173)
> (test program exited with status code -6)
Sorry, I neglected to test the tmp105 patches on CI before posting v2.
Guenter I'll squash on patch #48 (lower 4 bits):
-- >8 --
diff --git a/tests/qtest/bcm2835-i2c-test.c b/tests/qtest/bcm2835-i2c-test.c
index 513ecce61d..1599194926 100644
--- a/tests/qtest/bcm2835-i2c-test.c
+++ b/tests/qtest/bcm2835-i2c-test.c
@@ -81,7 +81,7 @@ static void test_i2c_read_write(gconstpointer data)
g_assert_cmpint(i2cdata, ==, 0xde);
i2cdata = readl(base_addr + BCM2835_I2C_FIFO);
- g_assert_cmpint(i2cdata, ==, 0xad);
+ g_assert_cmpint(i2cdata, ==, 0xa0);
/* Clear flags */
writel(base_addr + BCM2835_I2C_S, BCM2835_I2C_S_DONE |
BCM2835_I2C_S_ERR |
diff --git a/tests/qtest/tmp105-test.c b/tests/qtest/tmp105-test.c
index 3678646df5..85ad4eed85 100644
--- a/tests/qtest/tmp105-test.c
+++ b/tests/qtest/tmp105-test.c
@@ -100,9 +100,9 @@ static void send_and_receive(void *obj, void *data,
QGuestAllocator *alloc)
g_assert_cmphex(value, ==, 0x14f0);
i2c_set16(i2cdev, TMP105_REG_T_LOW, 0x1234);
- g_assert_cmphex(i2c_get16(i2cdev, TMP105_REG_T_LOW), ==, 0x1234);
+ g_assert_cmphex(i2c_get16(i2cdev, TMP105_REG_T_LOW), ==, 0x1230);
i2c_set16(i2cdev, TMP105_REG_T_HIGH, 0x4231);
- g_assert_cmphex(i2c_get16(i2cdev, TMP105_REG_T_HIGH), ==, 0x4231);
+ g_assert_cmphex(i2c_get16(i2cdev, TMP105_REG_T_HIGH), ==, 0x4230);
}
---
Regards,
Phil.
^ permalink raw reply related [flat|nested] 16+ messages in thread