Just a note: GCC also detects this type of programming mistake with the 
following warning message:

warning: suggest parentheses around assignment used as truth value 
[-Wparentheses]

I.e. unfortunately the way to suppress the GCC warning is to surround 
the assignment with parentheses, just like in the code below. So it 
could be a good idea to NOT use parentheses in Boolean expressions when 
it isn't necessary. Of course, then you need to be careful with operator 
precedence, but the && and || operators have very low precedence so you 
usually don't need parentheses around expressions separated by && or ||.

Table of operator precedences: 
http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B

/ Anders Widell

On 09/16/2014 09:23 AM, Anders Bjornerstedt wrote:
>   osaf/services/saf/immsv/immnd/immnd_evt.c |  2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
>
> Error detected by coverity.
>
> diff --git a/osaf/services/saf/immsv/immnd/immnd_evt.c 
> b/osaf/services/saf/immsv/immnd/immnd_evt.c
> --- a/osaf/services/saf/immsv/immnd/immnd_evt.c
> +++ b/osaf/services/saf/immsv/immnd/immnd_evt.c
> @@ -7091,7 +7091,7 @@ static void immnd_evt_proc_rt_object_del
>               }
>       }
>   
> -        if(spApplConn && (err = SA_AIS_OK) && !delayedReply) {
> +        if(spApplConn && (err == SA_AIS_OK) && !delayedReply) {
>               int ix = 0;
>               /* Indicates object is marked with SA_IMM_ATTR_NOTIFY and
>                  special applier is present at this node and we dont need to
>
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce.
> Perforce version control. Predictably reliable.
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> _______________________________________________
> Opensaf-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
>
>


------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce.
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to