diff mbox

[6/9] Fix bit test to use & instead of && and enable -Wlogical-op warning

Message ID 1333363816-1691-7-git-send-email-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé April 2, 2012, 10:50 a.m. UTC
From: "Daniel P. Berrange" <berrange@redhat.com>

* configure: Enable -Wlogical-op
* hw/exynos4210_uart.c: s/&&/&/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 configure            |    1 +
 hw/exynos4210_uart.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Peter Maydell April 2, 2012, 12:27 p.m. UTC | #1
On 2 April 2012 11:50, Daniel P. Berrange <berrange@redhat.com> wrote:
> diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
> index 73a9c18..4b20105 100644
> --- a/hw/exynos4210_uart.c
> +++ b/hw/exynos4210_uart.c
> @@ -246,7 +246,7 @@ static uint32_t exynos4210_uart_Tx_FIFO_trigger_level(Exynos4210UartState *s)
>     uint32_t level = 0;
>     uint32_t reg;
>
> -    reg = (s->reg[I_(UFCON)] && UFCON_Tx_FIFO_TRIGGER_LEVEL) >>
> +    reg = (s->reg[I_(UFCON)] & UFCON_Tx_FIFO_TRIGGER_LEVEL) >>
>             UFCON_Tx_FIFO_TRIGGER_LEVEL_SHIFT;
>
>     switch (s->channel) {
> @@ -277,7 +277,7 @@ static void exynos4210_uart_update_irq(Exynos4210UartState *s)
>      */
>     if (s->reg[I_(UFCON)] && UFCON_FIFO_ENABLE) {
>
> -        uint32_t count = (s->reg[I_(UFSTAT)] && UFSTAT_Tx_FIFO_COUNT) >>
> +        uint32_t count = (s->reg[I_(UFSTAT)] & UFSTAT_Tx_FIFO_COUNT) >>
>                 UFSTAT_Tx_FIFO_COUNT_SHIFT;
>
>         if (count <= exynos4210_uart_Tx_FIFO_trigger_level(s)) {

Nice catch. Note that the '&& UFCON_FIFO_ENABLE' you can see in the context
to the second hunk is also wrong and needs fixing.

I'll take the exynos changes via arm-devs.next, but not the configure
change. Please can you submit a version of the patch that only fixes
the bugs and doesn't also change the gcc warning flags?

thanks
-- PMM
Maksim E. Kozlov April 2, 2012, 4:02 p.m. UTC | #2
02.04.2012 16:27, Peter Maydell пишет:
> On 2 April 2012 11:50, Daniel P. Berrange<berrange@redhat.com>  wrote:
>> diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
>> index 73a9c18..4b20105 100644
>> --- a/hw/exynos4210_uart.c
>> +++ b/hw/exynos4210_uart.c
>> @@ -246,7 +246,7 @@ static uint32_t exynos4210_uart_Tx_FIFO_trigger_level(Exynos4210UartState *s)
>>      uint32_t level = 0;
>>      uint32_t reg;
>>
>> -    reg = (s->reg[I_(UFCON)]&&  UFCON_Tx_FIFO_TRIGGER_LEVEL)>>
>> +    reg = (s->reg[I_(UFCON)]&  UFCON_Tx_FIFO_TRIGGER_LEVEL)>>
>>              UFCON_Tx_FIFO_TRIGGER_LEVEL_SHIFT;
>>
>>      switch (s->channel) {
>> @@ -277,7 +277,7 @@ static void exynos4210_uart_update_irq(Exynos4210UartState *s)
>>       */
>>      if (s->reg[I_(UFCON)]&&  UFCON_FIFO_ENABLE) {
>>
>> -        uint32_t count = (s->reg[I_(UFSTAT)]&&  UFSTAT_Tx_FIFO_COUNT)>>
>> +        uint32_t count = (s->reg[I_(UFSTAT)]&  UFSTAT_Tx_FIFO_COUNT)>>
>>                  UFSTAT_Tx_FIFO_COUNT_SHIFT;
>>
>>          if (count<= exynos4210_uart_Tx_FIFO_trigger_level(s)) {
>
> Nice catch. Note that the '&&  UFCON_FIFO_ENABLE' you can see in the context
> to the second hunk is also wrong and needs fixing.
>
really nice catch :) ridiculous mistake

> I'll take the exynos changes via arm-devs.next, but not the configure
> change. Please can you submit a version of the patch that only fixes
> the bugs and doesn't also change the gcc warning flags?
>
> thanks
> -- PMM
>
>
diff mbox

Patch

diff --git a/configure b/configure
index 524458c..8ee6cdb 100755
--- a/configure
+++ b/configure
@@ -1192,6 +1192,7 @@  gcc_flags="$gcc_flags -Wpragmas"
 gcc_flags="$gcc_flags -Wtrampolines"
 gcc_flags="$gcc_flags -Wmissing-parameter-type"
 gcc_flags="$gcc_flags -Wuninitialized"
+gcc_flags="$gcc_flags -Wlogical-op"
 
 cat > $TMPC << EOF
 int main(void) { return 0; }
diff --git a/hw/exynos4210_uart.c b/hw/exynos4210_uart.c
index 73a9c18..4b20105 100644
--- a/hw/exynos4210_uart.c
+++ b/hw/exynos4210_uart.c
@@ -246,7 +246,7 @@  static uint32_t exynos4210_uart_Tx_FIFO_trigger_level(Exynos4210UartState *s)
     uint32_t level = 0;
     uint32_t reg;
 
-    reg = (s->reg[I_(UFCON)] && UFCON_Tx_FIFO_TRIGGER_LEVEL) >>
+    reg = (s->reg[I_(UFCON)] & UFCON_Tx_FIFO_TRIGGER_LEVEL) >>
             UFCON_Tx_FIFO_TRIGGER_LEVEL_SHIFT;
 
     switch (s->channel) {
@@ -277,7 +277,7 @@  static void exynos4210_uart_update_irq(Exynos4210UartState *s)
      */
     if (s->reg[I_(UFCON)] && UFCON_FIFO_ENABLE) {
 
-        uint32_t count = (s->reg[I_(UFSTAT)] && UFSTAT_Tx_FIFO_COUNT) >>
+        uint32_t count = (s->reg[I_(UFSTAT)] & UFSTAT_Tx_FIFO_COUNT) >>
                 UFSTAT_Tx_FIFO_COUNT_SHIFT;
 
         if (count <= exynos4210_uart_Tx_FIFO_trigger_level(s)) {