From b6b34d538398f8214daa5b160f764dc8b82ff9c5 Mon Sep 17 00:00:00 2001 From: Muhammet Kara Date: Mon, 30 May 2016 17:20:50 +0300 Subject: Clarify calculation precedence tdf#39440 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use parentheses to clarify the code. Change-Id: I864dc6dacadb5b9ba9dca8e0abd9fa4e6db1eddc Reviewed-on: https://gerrit.libreoffice.org/25677 Tested-by: Jenkins Reviewed-by: jan iversen Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx | 2 +- filter/source/msfilter/msdffimp.cxx | 10 +++++----- sal/osl/unx/file.cxx | 18 +++++++++--------- .../OGLTrans/generic/OGLTrans_TransitionImpl.cxx | 2 +- sw/source/core/doc/DocumentStylePoolManager.cxx | 2 +- sw/source/filter/ww8/ww8atr.cxx | 2 +- sw/source/ui/dbui/dbinsdlg.cxx | 2 +- sw/source/uibase/app/docstyle.cxx | 4 ++-- sw/source/uibase/docvw/edtwin.cxx | 2 +- sw/source/uibase/uiview/viewdlg2.cxx | 8 ++++---- sw/source/uibase/uiview/viewtab.cxx | 2 +- tools/source/fsys/urlobj.cxx | 16 ++++++++-------- ucb/source/ucp/ftp/ftpcontent.cxx | 2 +- vcl/source/outdev/rect.cxx | 2 +- 14 files changed, 37 insertions(+), 37 deletions(-) diff --git a/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx index 949912276d39..5d534051dbe7 100644 --- a/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_solaris_sparc/cpp2uno.cxx @@ -373,7 +373,7 @@ static void cpp_vtable_call() // fprintf(stderr,"cpp_mediate nFunctionIndex=%x\n",nFunctionIndex); // fflush(stderr); - sal_Bool bComplex = nFunctionIndex & 0x80000000 ? sal_True : sal_False; + sal_Bool bComplex = (nFunctionIndex & 0x80000000) ? sal_True : sal_False; typelib_TypeClass aType = cpp_mediate( nFunctionIndex, vTableOffset, pCallStack+17, (sal_Int64*)&nRegReturn ); diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 90c02fa9b929..88900c50f759 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -1832,7 +1832,7 @@ void DffPropertyReader::ApplyCustomShapeGeometryAttributes( SvStream& rIn, SfxIt } // "ProjectionMode" const OUString sExtrusionProjectionMode( "ProjectionMode" ); - ProjectionMode eProjectionMode = GetPropertyValue( DFF_Prop_fc3DFillHarsh, 0 ) & 4 ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE; + ProjectionMode eProjectionMode = (GetPropertyValue( DFF_Prop_fc3DFillHarsh, 0 ) & 4) ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE; aProp.Name = sExtrusionProjectionMode; aProp.Value <<= eProjectionMode; aExtrusionPropVec.push_back( aProp ); @@ -2577,17 +2577,17 @@ void DffPropertyReader::ApplyAttributes( SvStream& rIn, SfxItemSet& rSet, DffObj rSet.Put( SvxFontHeightItem( rManager.ScalePt( GetPropertyValue( DFF_Prop_gtextSize, 0 ) ), 100, EE_CHAR_FONTHEIGHT ) ); sal_uInt32 nFontAttributes = GetPropertyValue( DFF_Prop_gtextFStrikethrough, 0 ); if ( nFontAttributes & 0x20 ) - rSet.Put( SvxWeightItem( nFontAttributes & 0x20 ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) ); + rSet.Put( SvxWeightItem( (nFontAttributes & 0x20) ? WEIGHT_BOLD : WEIGHT_NORMAL, EE_CHAR_WEIGHT ) ); if ( nFontAttributes & 0x10 ) - rSet.Put( SvxPostureItem( nFontAttributes & 0x10 ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) ); + rSet.Put( SvxPostureItem( (nFontAttributes & 0x10) ? ITALIC_NORMAL : ITALIC_NONE, EE_CHAR_ITALIC ) ); if ( nFontAttributes & 0x08 ) - rSet.Put( SvxUnderlineItem( nFontAttributes & 0x08 ? LINESTYLE_SINGLE : LINESTYLE_NONE, EE_CHAR_UNDERLINE ) ); + rSet.Put( SvxUnderlineItem( (nFontAttributes & 0x08) ? LINESTYLE_SINGLE : LINESTYLE_NONE, EE_CHAR_UNDERLINE ) ); if ( nFontAttributes & 0x40 ) rSet.Put( SvxShadowedItem( (nFontAttributes & 0x40) != 0, EE_CHAR_SHADOW ) ); // if ( nFontAttributes & 0x02 ) // rSet.Put( SvxCaseMapItem( nFontAttributes & 0x02 ? SVX_CASEMAP_KAPITAELCHEN : SVX_CASEMAP_NOT_MAPPED ) ); if ( nFontAttributes & 0x01 ) - rSet.Put( SvxCrossedOutItem( nFontAttributes & 0x01 ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) ); + rSet.Put( SvxCrossedOutItem( (nFontAttributes & 0x01) ? STRIKEOUT_SINGLE : STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ) ); if ( IsProperty( DFF_Prop_fillColor ) ) rSet.Put( XFillColorItem( OUString(), rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor, 0 ), DFF_Prop_fillColor ) ) ); if ( IsProperty( DFF_Prop_shadowColor ) ) diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index 2938e0e1da37..b9b7e6fd5581 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -883,18 +883,18 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, #endif /* set mode and flags */ - int defmode = uFlags & osl_File_OpenFlag_Private + int defmode = (uFlags & osl_File_OpenFlag_Private) ? S_IRUSR : S_IRUSR | S_IRGRP | S_IROTH; int flags = O_RDONLY; if (uFlags & osl_File_OpenFlag_Write) { - defmode |= uFlags & osl_File_OpenFlag_Private + defmode |= (uFlags & osl_File_OpenFlag_Private) ? S_IWUSR : S_IWUSR | S_IWGRP | S_IWOTH; flags = OPEN_WRITE_FLAGS; } if (uFlags & osl_File_OpenFlag_Create) { - defmode |= uFlags & osl_File_OpenFlag_Private + defmode |= (uFlags & osl_File_OpenFlag_Private) ? S_IWUSR : S_IWUSR | S_IWGRP | S_IWOTH; flags = OPEN_CREATE_FLAGS; } @@ -938,7 +938,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, if (-1 == fd) { int saved_errno = errno; - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << ") failed: " << strerror(saved_errno)); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << ") failed: " << strerror(saved_errno)); return oslTranslateFileError (OSL_FET_ERROR, saved_errno); } @@ -950,7 +950,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, if (-1 == f) { int saved_errno = errno; - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << "): fcntl(" << fd << ", F_GETFL) failed: " << strerror(saved_errno)); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << "): fcntl(" << fd << ", F_GETFL) failed: " << strerror(saved_errno)); eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; @@ -958,7 +958,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, if (-1 == fcntl (fd, F_SETFL, (f & ~O_NONBLOCK))) { int saved_errno = errno; - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << "): fcntl(" << fd << ", F_SETFL) failed: " << strerror(saved_errno)); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << "): fcntl(" << fd << ", F_SETFL) failed: " << strerror(saved_errno)); eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; @@ -970,7 +970,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, if (-1 == fstat (fd, &aFileStat)) { int saved_errno = errno; - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << "): fstat(" << fd << ") failed: " << strerror(saved_errno)); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << "): fstat(" << fd << ") failed: " << strerror(saved_errno)); eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; @@ -1008,7 +1008,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, if (-1 == fcntl (fd, F_SETLK, &aflock)) { int saved_errno = errno; - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << "): fcntl(" << fd << ", F_SETLK) failed: " << strerror(saved_errno)); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << "): fcntl(" << fd << ", F_SETLK) failed: " << strerror(saved_errno)); eRet = oslTranslateFileError (OSL_FET_ERROR, saved_errno); (void) close(fd); return eRet; @@ -1029,7 +1029,7 @@ openFilePath( const char *cpFilePath, oslFileHandle* pHandle, sal_uInt32 uFlags, pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE; pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size); - SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << (flags & O_RDWR ? "writeable":"readonly") << ") => " << pImpl->m_fd); + SAL_INFO("sal.file", "osl_openFile(" << cpFilePath << ", " << ((flags & O_RDWR) ? "writeable":"readonly") << ") => " << pImpl->m_fd); *pHandle = static_cast(pImpl); return osl_File_E_None; diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index 6b7cd6011dc2..cd43fedac4a3 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -2186,7 +2186,7 @@ std::shared_ptr makeHoneycomb() Primitive aHexagon; for (int y = 0; y < NY+2; y+=2) for (int x = 0; x < NX+2; x+=2) - aHexagon.pushTriangle(glm::vec2(y % 4 ? fdiv(x, NX) : fdiv(x + 1, NX), fdiv(y, NY)), glm::vec2(1, 0), glm::vec2(0, 0)); + aHexagon.pushTriangle(glm::vec2((y % 4) ? fdiv(x, NX) : fdiv(x + 1, NX), fdiv(y, NY)), glm::vec2(1, 0), glm::vec2(0, 0)); aSlide.push_back(aHexagon); return makeHoneycombTransition(aSlide, aSlide, aSettings); diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 1845f86d6e3a..8bda2586c9ac 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -1992,7 +1992,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId ) for (sal_uInt16 n = 0; n < MAXLEVEL; ++n) { - aFormat.SetBulletChar( ( n & 1 ? 0x25a1 : 0x2611 ) ); + aFormat.SetBulletChar( ( (n & 1) ? 0x25a1 : 0x2611 ) ); if ( eNumberFormatPositionAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 7efb44de269d..c6290b70c3bd 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2545,7 +2545,7 @@ void AttributeOutputBase::TextField( const SwFormatField& rField ) case RES_AUTHORFLD: { ww::eField eField = - (AF_SHORTCUT & pField->GetFormat() ? ww::eUSERINITIALS : ww::eUSERNAME); + ((AF_SHORTCUT & pField->GetFormat()) ? ww::eUSERINITIALS : ww::eUSERNAME); GetExport().OutputField(pField, eField, FieldString(eField)); } break; diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 049f2f90cc7e..a75a08b1f4b5 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -715,7 +715,7 @@ IMPL_LINK_TYPED( SwInsertDBColAutoPilot, TableFormatHdl, Button*, pButton, void } else nWidth = rSh.GetAnyCurRect( - FrameTypeFlags::FLY_ANY & rSh.GetFrameType( nullptr, true ) + (FrameTypeFlags::FLY_ANY & rSh.GetFrameType( nullptr, true )) ? RECT_FLY_PRT_EMBEDDED : RECT_PAGE_PRT ).Width(); diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx index 11f7e957c564..33b78477fd3f 100644 --- a/sw/source/uibase/app/docstyle.cxx +++ b/sw/source/uibase/app/docstyle.cxx @@ -1949,7 +1949,7 @@ bool SwDocStyleSheet::FillStyleSheet( } else if( !bCreate ) nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC ); - SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 ); + SetMask( (USER_FMT & nPoolId) ? SFXSTYLEBIT_USERDEF : 0 ); bRet = nullptr != pDesc || USHRT_MAX != nPoolId; if( bDeleteInfo ) @@ -1978,7 +1978,7 @@ bool SwDocStyleSheet::FillStyleSheet( } else if( !bCreate ) nPoolId = SwStyleNameMapper::GetPoolIdFromUIName( aName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE ); - SetMask( USER_FMT & nPoolId ? SFXSTYLEBIT_USERDEF : 0 ); + SetMask( (USER_FMT & nPoolId) ? SFXSTYLEBIT_USERDEF : 0 ); bRet = nullptr != pNumRule || USHRT_MAX != nPoolId; diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index fedbd8bed1e1..1631ffac5110 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2242,7 +2242,7 @@ KEYINPUT_CHECKTABLE_INSDEL: nsSelectionType::SEL_DRW_FORM)) { - eKeyState = rKeyCode.GetModifier() & KEY_SHIFT ? + eKeyState = (rKeyCode.GetModifier() & KEY_SHIFT) ? KS_PrevObject : KS_NextObject; } else if ( !rSh.IsMultiSelection() && rSh.CursorInsideInputField() ) diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index 4a0273185357..e1797bb7e832 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -118,10 +118,10 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt) if (eType & nsSelectionType::SEL_OLE) eType = nsSelectionType::SEL_GRF; - const SwLabelType eT = eType & nsSelectionType::SEL_TBL ? LTYPE_TABLE : - eType & nsSelectionType::SEL_FRM ? LTYPE_FLY : - eType == nsSelectionType::SEL_TXT ? LTYPE_FLY : - eType & nsSelectionType::SEL_DRW ? LTYPE_DRAW : + const SwLabelType eT = (eType & nsSelectionType::SEL_TBL) ? LTYPE_TABLE : + (eType & nsSelectionType::SEL_FRM) ? LTYPE_FLY : + (eType == nsSelectionType::SEL_TXT) ? LTYPE_FLY : + (eType & nsSelectionType::SEL_DRW) ? LTYPE_DRAW : LTYPE_OBJECT; SwFieldMgr aMgr(&rSh); diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 6f50300ac3a6..25a848c733d4 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -1271,7 +1271,7 @@ void SwView::StateTabWin(SfxItemSet& rSet) if ( ( nFrameType & FrameTypeFlags::HEADER || nFrameType & FrameTypeFlags::FOOTER ) && !(nFrameType & FrameTypeFlags::COLSECT) ) { - SwFrameFormat *pFormat = const_cast(nFrameType & FrameTypeFlags::HEADER ? + SwFrameFormat *pFormat = const_cast((nFrameType & FrameTypeFlags::HEADER) ? rDesc.GetMaster().GetHeader().GetHeaderFormat() : rDesc.GetMaster().GetFooter().GetFooterFormat()); if( pFormat )// #i80890# if rDesc is not the one belonging to the current page is might crash diff --git a/tools/source/fsys/urlobj.cxx b/tools/source/fsys/urlobj.cxx index c31e61a429a1..9061bf19a981 100644 --- a/tools/source/fsys/urlobj.cxx +++ b/tools/source/fsys/urlobj.cxx @@ -626,10 +626,10 @@ INetURLObject::FSysStyle guessFSysStyleByCounting(sal_Unicode const * pBegin, && pEnd - pBegin <= std::numeric_limits< sal_Int32 >::max(), "guessFSysStyleByCounting(): Too big"); sal_Int32 nSlashCount - = eStyle & INetURLObject::FSYS_UNX ? + = (eStyle & INetURLObject::FSYS_UNX) ? 0 : std::numeric_limits< sal_Int32 >::min(); sal_Int32 nBackslashCount - = eStyle & INetURLObject::FSYS_DOS ? + = (eStyle & INetURLObject::FSYS_DOS) ? 0 : std::numeric_limits< sal_Int32 >::min(); while (pBegin != pEnd) switch (*pBegin++) @@ -4262,9 +4262,9 @@ bool INetURLObject::setFSysPath(OUString const & rFSysPath, sal_Unicode const * pFSysBegin = rFSysPath.getStr(); sal_Unicode const * pFSysEnd = pFSysBegin + rFSysPath.getLength(); - switch ((eStyle & FSYS_VOS ? 1 : 0) - + (eStyle & FSYS_UNX ? 1 : 0) - + (eStyle & FSYS_DOS ? 1 : 0)) + switch (((eStyle & FSYS_VOS) ? 1 : 0) + + ((eStyle & FSYS_UNX) ? 1 : 0) + + ((eStyle & FSYS_DOS) ? 1 : 0)) { case 0: return false; @@ -4433,9 +4433,9 @@ OUString INetURLObject::getFSysPath(FSysStyle eStyle, if (m_eScheme != INetProtocol::File) return OUString(); - if ((eStyle & FSYS_VOS ? 1 : 0) - + (eStyle & FSYS_UNX ? 1 : 0) - + (eStyle & FSYS_DOS ? 1 : 0) + if (((eStyle & FSYS_VOS) ? 1 : 0) + + ((eStyle & FSYS_UNX) ? 1 : 0) + + ((eStyle & FSYS_DOS) ? 1 : 0) > 1) { eStyle = eStyle & FSYS_VOS diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx index 34e560eaf0f7..8e73b4908c8c 100644 --- a/ucb/source/ucp/ftp/ftpcontent.cxx +++ b/ucb/source/ucp/ftp/ftpcontent.cxx @@ -801,7 +801,7 @@ Reference< XRow > FTPContent::getPropertyValues( else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) { if(Name == "ContentType") xRow->appendString(seqProp[i], - aDirEntry.m_nMode&INETCOREFTP_FILEMODE_ISDIR + (aDirEntry.m_nMode & INETCOREFTP_FILEMODE_ISDIR) ? OUString(FTP_FOLDER) : OUString(FTP_FILE) ); else if(Name == "IsReadOnly") diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index c4bf57cfff2e..61cbeaa4f4af 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -217,7 +217,7 @@ void OutputDevice::DrawCheckered(const Point& rPos, const Size& rSize, sal_uInt3 { const sal_uInt32 nBottom(std::min(nMaxY, nY + nLen)); - SetFillColor((x & 0x0001) ^ (y & 0x0001) ? aStart : aEnd); + SetFillColor(((x & 0x0001) ^ (y & 0x0001)) ? aStart : aEnd); DrawRect(Rectangle(nX, nY, nRight, nBottom)); } } -- cgit v1.2.3