someone ran static analysis on our code, I guess I should fix what it reported

This commit is contained in:
zeromus 2015-07-13 03:23:28 +00:00
parent 4d77617e3e
commit 4a128f946c
2 changed files with 43 additions and 41 deletions

View File

@ -345,9 +345,9 @@ void GameInfo::populate()
u32 region = (u32)(std::max<s32>(strchr(regions_index,header.gameCode[3]) - regions_index + 1, 0));
if (region < regions_num)
strncat(ROMserial, regions[region], sizeof(ROMserial));
strcat(ROMserial, regions[region]);
else
strncat(ROMserial, "???", sizeof(ROMserial));
strcat(ROMserial, "???");
}
//rom name is probably set even in homebrew, so do it regardless

View File

@ -194,30 +194,31 @@ public:
//catch (OverflowException) throw new OverflowException (Locale.GetText ("This TimeSpan value is MinValue so you cannot get the duration."));
}
static TimeSpan FromDays (double value)
{
return From (value, TicksPerDay);
}
//removed per http://sourceforge.net/p/desmume/bugs/1484/ since it was erroneous (well, From() was) and wasn't being used
//static TimeSpan FromDays (double value)
//{
// return From (value, TicksPerDay);
//}
static TimeSpan FromHours (double value)
{
return From (value, TicksPerHour);
}
//static TimeSpan FromHours (double value)
//{
// return From (value, TicksPerHour);
//}
static TimeSpan FromMinutes (double value)
{
return From (value, TicksPerMinute);
}
//static TimeSpan FromMinutes (double value)
//{
// return From (value, TicksPerMinute);
//}
static TimeSpan FromSeconds (double value)
{
return From (value, TicksPerSecond);
}
//static TimeSpan FromSeconds (double value)
//{
// return From (value, TicksPerSecond);
//}
static TimeSpan FromMilliseconds (double value)
{
return From (value, TicksPerMillisecond);
}
//static TimeSpan FromMilliseconds (double value)
//{
// return From (value, TicksPerMillisecond);
//}
static TimeSpan FromTicks (s64 value)
{
@ -343,28 +344,29 @@ private:
return t;
}
static TimeSpan From (double value, s64 tickMultiplicator)
{
//a bunch of error handling removed
//removed per http://sourceforge.net/p/desmume/bugs/1484/ since it was erroneous and wasn't being used
//static TimeSpan From (double value, s64 tickMultiplicator)
//{
// //a bunch of error handling removed
//if (Double.IsNaN (value)) throw new ArgumentException (Locale.GetText ("Value cannot be NaN."), "value");
//if (Double.IsNegativeInfinity (value) || Double.IsPositiveInfinity (value) ||
// (value < MinValue.Ticks) || (value > MaxValue.Ticks))
// throw new OverflowException (Locale.GetText ("Outside range [MinValue,MaxValue]"));
// //if (Double.IsNaN (value)) throw new ArgumentException (Locale.GetText ("Value cannot be NaN."), "value");
// //if (Double.IsNegativeInfinity (value) || Double.IsPositiveInfinity (value) ||
// // (value < MinValue.Ticks) || (value > MaxValue.Ticks))
// // throw new OverflowException (Locale.GetText ("Outside range [MinValue,MaxValue]"));
//try {
value = (value * (tickMultiplicator / TicksPerMillisecond));
// //try {
// value = (value * (tickMultiplicator / TicksPerMillisecond));
// checked {
// long val = (long) Math.Round(value);
// return new TimeSpan (val * TicksPerMillisecond);
// }
//}
//catch (OverflowException) {
// throw new OverflowException (Locale.GetText ("Resulting timespan is too big."));
//}
//}
}
// // checked {
// // long val = (long) Math.Round(value);
// // return new TimeSpan (val * TicksPerMillisecond);
// // }
// //}
// //catch (OverflowException) {
// // throw new OverflowException (Locale.GetText ("Resulting timespan is too big."));
// //}
// //}
//}
};