cid#1607163 silence Overflowed return value

and

cid#1608078 Overflowed return value
cid#1608461 Overflowed return value

Change-Id: Ic5fa20994c5be5d6c09a21c0bd1e3530ae9a6941
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177164
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
Caolán McNamara
2024-11-24 15:14:59 +01:00
parent aed4e00c4f
commit 12cad7e619
4 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -407,7 +407,8 @@ sal_Int32 SAL_CALL AnalysisAddIn::getWeeknum( const uno::Reference< beans::XProp
DaysToDate( nDate, nDay, nMonth, nYear );
sal_Int32 nFirstInYear = DateToDays( 1, 1, nYear );
sal_Int16 nFirstDayInYear = GetDayOfWeek( nFirstInYear );
// coverity[ tainted_data_return : FALSE ] version 2023.12.2
sal_uInt16 nFirstDayInYear = GetDayOfWeek( nFirstInYear );
return ( nDate - nFirstInYear + ( ( nMode == 1 )? ( nFirstDayInYear + 1 ) % 7 : nFirstDayInYear ) ) / 7 + 1;
}
@@ -580,7 +580,6 @@ inline sal_Int32 GetDiffDate360( const css::uno::Reference< css::beans::XPropert
inline sal_Int16 GetDayOfWeek( sal_Int32 n )
{ // monday = 0, ..., sunday = 6
assert(n >= 0);
return static_cast< sal_Int16 >( ( n - 1 ) % 7 );
}
+1
View File
@@ -744,6 +744,7 @@ namespace sw
if ( rDT.GetDate() == 0 )
return 0;
// coverity[ tainted_data_return : FALSE ] version 2023.12.2
sal_uInt32 nDT = ( rDT.GetDayOfWeek() + 1 ) % 7;
nDT <<= 9;
nDT += ( rDT.GetYear() - 1900 ) & 0x1ff;
+2 -2
View File
@@ -209,9 +209,8 @@ sal_uInt16 Date::GetDayOfYear() const
sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay,
sal_Int16 nMinimumNumberOfDaysInWeek ) const
{
short nWeek;
// coverity[ tainted_data_return : FALSE ] version 2023.12.2
short n1WDay = static_cast<short>(Date( 1, 1, GetYear() ).GetDayOfWeek());
assert(n1WDay >= 0);
short nDayOfYear = static_cast<short>(GetDayOfYear());
// weekdays start at 0, thus decrement one
@@ -225,6 +224,7 @@ sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay,
nMinimumNumberOfDaysInWeek = 4;
}
short nWeek;
if ( nMinimumNumberOfDaysInWeek == 1 )
{
nWeek = ((n1WDay+nDayOfYear)/7) + 1;