[Libreoffice] [PATCH] [Janitor] remove 'precedence' warnings

Caolán McNamara caolanm at redhat.com
Thu Sep 30 01:24:09 PDT 2010


On Thu, 2010-09-30 at 01:43 -0500, Norbert Thiebaud wrote:

>      if(rSel.A() == rSel.B() &&
> -        !rSel.A() || rSel.A() == nTextLen )
> +       (!rSel.A() || rSel.A() == nTextLen ))
>      {


Careful here now, 

Original is: 
if (rSel.A() == rSel.B() && !rSel.A() || rSel.A() == nTextLen)
by operator precedence this results in...
if ((rSel.A() == rSel.B() && !rSel.A()) || (rSel.A() == nTextLen))
i.e. && before ||
your patch makes it
if (rSel.A() == rSel.B() && (!rSel.A() || rSel.A() == nTextLen))
which changes the logic. Are we sure that's the intention here.


>      sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pEdit);
> -    if(nPos && !pEdit->IsNextControl() ||
> -        nPos < aControlList.Count() - 1 && pEdit->IsNextControl())
> +    if((nPos && !pEdit->IsNextControl()) ||
> +       (nPos < aControlList.Count() - 1 && pEdit->IsNextControl()))
>      {

This looks good.

>  {
>      sal_uInt16 nPos = (sal_uInt16)aControlList.GetPos(pBtn);
> -    if(nPos && !pBtn->IsNextControl() ||
> -        nPos < aControlList.Count() - 1 && pBtn->IsNextControl())
> +    if((nPos && !pBtn->IsNextControl()) ||
> +       (nPos < aControlList.Count() - 1 && pBtn->IsNextControl()))

This looks good.

C.



More information about the LibreOffice mailing list