Issue 113181 - sw: && || ambiguity in docfld.cxx
Summary: sw: && || ambiguity in docfld.cxx
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: DEV300m84
Hardware: All Linux, all
: P3 Trivial (vote)
Target Milestone: 3.4.0
Assignee: caolanm
QA Contact: issues@sw
URL:
Keywords:
Depends on:
Blocks: 96084
  Show dependency tree
 
Reported: 2010-07-16 11:03 UTC by caolanm
Modified: 2017-05-20 10:22 UTC (History)
3 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
version 1, keep logic silence gcc warnings (1.80 KB, patch)
2010-07-16 11:04 UTC, caolanm
no flags Details | Diff
version 2, change logic, small possibility that is what was intended (1.62 KB, patch)
2010-07-16 11:04 UTC, caolanm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description caolanm 2010-07-16 11:03:28 UTC
in docfld.cxx we have...

if( bIsDBMgr &&
        rDoc.GetNewDBMgr()->OpenDataSource( aDBData.sDataSource,
aDBData.sCommand )&&
        GETFLD_ALL == eGetMode ||       
        ( GETFLD_CALC & eGetMode &&     
                ((SwDBNextSetField*)pFld)->IsCondValid() ))
        pFormel = &pFld->GetPar1();   

precedence rules for this results in ...

if (
     (
       bIsDBMgr && rDoc.GetNewDBMgr()->OpenDataSource(aDBData.sDataSource,
aDBData.sCommand) &&
       GETFLD_ALL == eGetMode
     )
     ||
     (GETFLD_CALC & eGetMode && ((SwDBNumSetField*)pFld)->IsCondValid())
   )
{
    pFormel = &pFld->GetPar1();
}

maybe that's what we intended, but there's a chance we intended...

if (
     (bIsDBMgr && rDoc.GetNewDBMgr()->OpenDataSource(aDBData.sDataSource,
aDBData.sCommand)) &&
     (GETFLD_ALL == eGetMode || (GETFLD_CALC & eGetMode &&
((SwDBNumSetField*)pFld)->IsCondValid()))
   )
{
    pFormel = &pFld->GetPar1();
}
Comment 1 caolanm 2010-07-16 11:04:11 UTC
Created attachment 70640 [details]
version 1, keep logic silence gcc warnings
Comment 2 caolanm 2010-07-16 11:04:37 UTC
Created attachment 70641 [details]
version 2, change logic, small possibility that is what was intended
Comment 3 mst.ooo 2010-07-20 18:00:50 UTC
.
Comment 4 mst.ooo 2010-07-20 18:04:51 UTC
the conditional is indeed buggy.

fixed in cws sw34bf01
http://hg.services.openoffice.org/hg/cws/sw34bf01/rev/cf200e1ce857
Comment 5 mst.ooo 2010-10-07 11:06:09 UTC
please verify
Comment 6 caolanm 2010-10-07 11:12:13 UTC
verified