* [Qemu-devel] [PATCH] hw/xics: Fix one-bit signed bitfields
@ 2012-09-04 20:30 Stefan Weil
2012-09-04 20:53 ` Peter Maydell
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Weil @ 2012-09-04 20:30 UTC (permalink / raw)
To: qemu-trivial; +Cc: Stefan Weil, qemu-devel
Report from smatch:
xics.c:169:19: error: dubious one-bit signed bitfield
xics.c:170:15: error: dubious one-bit signed bitfield
xics.c:171:19: error: dubious one-bit signed bitfield
xics.c:172:25: error: dubious one-bit signed bitfield
Instead of replacing 'int' by 'unsigned', 'bool' was used because
all 4 values are boolean values.
Replacing 0 and 1 in the assignments by false and true
looks better for those boolean values.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
hw/xics.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/hw/xics.c b/hw/xics.c
index b674771..8a2f70f 100644
--- a/hw/xics.c
+++ b/hw/xics.c
@@ -166,10 +166,10 @@ struct ics_irq_state {
uint8_t priority;
uint8_t saved_priority;
enum xics_irq_type type;
- int asserted:1;
- int sent:1;
- int rejected:1;
- int masked_pending:1;
+ bool asserted:1;
+ bool sent:1;
+ bool rejected:1;
+ bool masked_pending:1;
};
struct ics_state {
@@ -192,7 +192,7 @@ static void resend_msi(struct ics_state *ics, int srcno)
/* FIXME: filter by server#? */
if (irq->rejected) {
- irq->rejected = 0;
+ irq->rejected = false;
if (irq->priority != 0xff) {
icp_irq(ics->icp, irq->server, srcno + ics->offset,
irq->priority);
@@ -205,7 +205,7 @@ static void resend_lsi(struct ics_state *ics, int srcno)
struct ics_irq_state *irq = ics->irqs + srcno;
if ((irq->priority != 0xff) && irq->asserted && !irq->sent) {
- irq->sent = 1;
+ irq->sent = true;
icp_irq(ics->icp, irq->server, srcno + ics->offset, irq->priority);
}
}
@@ -216,7 +216,7 @@ static void set_irq_msi(struct ics_state *ics, int srcno, int val)
if (val) {
if (irq->priority == 0xff) {
- irq->masked_pending = 1;
+ irq->masked_pending = true;
/* masked pending */ ;
} else {
icp_irq(ics->icp, irq->server, srcno + ics->offset, irq->priority);
@@ -252,7 +252,7 @@ static void write_xive_msi(struct ics_state *ics, int srcno)
return;
}
- irq->masked_pending = 0;
+ irq->masked_pending = false;
icp_irq(ics->icp, irq->server, srcno + ics->offset, irq->priority);
}
@@ -281,8 +281,8 @@ static void ics_reject(struct ics_state *ics, int nr)
{
struct ics_irq_state *irq = ics->irqs + nr - ics->offset;
- irq->rejected = 1; /* Irrelevant but harmless for LSI */
- irq->sent = 0; /* Irrelevant but harmless for MSI */
+ irq->rejected = true; /* Irrelevant but harmless for LSI */
+ irq->sent = false; /* Irrelevant but harmless for MSI */
}
static void ics_resend(struct ics_state *ics)
@@ -307,7 +307,7 @@ static void ics_eoi(struct ics_state *ics, int nr)
struct ics_irq_state *irq = ics->irqs + srcno;
if (irq->type == XICS_LSI) {
- irq->sent = 0;
+ irq->sent = false;
}
}
--
1.7.10
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/xics: Fix one-bit signed bitfields
2012-09-04 20:30 [Qemu-devel] [PATCH] hw/xics: Fix one-bit signed bitfields Stefan Weil
@ 2012-09-04 20:53 ` Peter Maydell
2012-09-22 21:34 ` Stefan Weil
0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2012-09-04 20:53 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel
On 4 September 2012 21:30, Stefan Weil <sw@weilnetz.de> wrote:
> Report from smatch:
>
> xics.c:169:19: error: dubious one-bit signed bitfield
> xics.c:170:15: error: dubious one-bit signed bitfield
> xics.c:171:19: error: dubious one-bit signed bitfield
> xics.c:172:25: error: dubious one-bit signed bitfield
>
> Instead of replacing 'int' by 'unsigned', 'bool' was used because
> all 4 values are boolean values.
>
> Replacing 0 and 1 in the assignments by false and true
> looks better for those boolean values.
If we're changing this we should just drop the bitfield usage
entirely and use plain bool, I think.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/xics: Fix one-bit signed bitfields
2012-09-04 20:53 ` Peter Maydell
@ 2012-09-22 21:34 ` Stefan Weil
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Weil @ 2012-09-22 21:34 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel, David Gibson
Am 04.09.2012 22:53, schrieb Peter Maydell:
> On 4 September 2012 21:30, Stefan Weil<sw@weilnetz.de> wrote:
>> Report from smatch:
>>
>> xics.c:169:19: error: dubious one-bit signed bitfield
>> xics.c:170:15: error: dubious one-bit signed bitfield
>> xics.c:171:19: error: dubious one-bit signed bitfield
>> xics.c:172:25: error: dubious one-bit signed bitfield
>>
>> Instead of replacing 'int' by 'unsigned', 'bool' was used because
>> all 4 values are boolean values.
>>
>> Replacing 0 and 1 in the assignments by false and true
>> looks better for those boolean values.
>
> If we're changing this we should just drop the bitfield usage
> entirely and use plain bool, I think.
>
> -- PMM
David, could you please review the patch and Peter's suggestion?
See also http://patchwork.ozlabs.org/patch/181671/
Thanks,
Stefan Weil
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-09-22 21:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-04 20:30 [Qemu-devel] [PATCH] hw/xics: Fix one-bit signed bitfields Stefan Weil
2012-09-04 20:53 ` Peter Maydell
2012-09-22 21:34 ` Stefan Weil
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).