Fix V3029 warnings from PVS-Studio Static Analyzer

Hi! I'm a member of the Pinguem.ru competition on finding errors in open
source projects. A bug, found using PVS-Studio.

Warnings with low priority:
This commit is contained in:
AdmAlexus 2017-10-28 16:00:30 +05:00
parent c07a9ded13
commit c4acd5e5bd

View file

@ -88,8 +88,11 @@ private void left_MouseMove(object sender, MouseEventArgs e)
{
var toDraw = resizer.ToDraw;
if (resizable) {
if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X;
if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8)
{
toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
toDraw.X = Cursor.Position.X;
}
}
resizer.ToDraw = toDraw;
}
@ -100,8 +103,11 @@ private void bottom_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) toDraw.Y = this.Location.Y;
if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
if (resizable)
{
toDraw.Y = this.Location.Y;
toDraw.Height = MousePosition.Y - this.Location.Y;
}
resizer.ToDraw = toDraw;
}
}
@ -111,8 +117,13 @@ private void bottomrightcorner_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X;
if (resizable) toDraw.Height = MousePosition.Y - this.Location.Y;
if (resizable)
{
if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8)
toDraw.Width = MousePosition.X - this.Location.X;
toDraw.Height = MousePosition.Y - this.Location.Y;
}
resizer.ToDraw = toDraw;
}
}
@ -122,9 +133,15 @@ private void bottomleftcorner_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X);
if (resizable) toDraw.Height = Cursor.Position.Y - this.Location.Y;
if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X;
if (resizable)
{
if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8)
{
toDraw.Width = ((toDraw.Width + toDraw.Location.X) - Cursor.Position.X);
toDraw.X = Cursor.Position.X;
}
toDraw.Height = Cursor.Position.Y - this.Location.Y;
}
resizer.ToDraw = toDraw;
}
}
@ -134,10 +151,16 @@ private void topleftcorner_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
if (resizable) if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8) toDraw.X = Cursor.Position.X;
if (resizable) toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
if (resizable) toDraw.Y = Cursor.Position.Y;
if (resizable)
{
if (((this.Width + this.Location.X) - Cursor.Position.X) > progContent.MinimumSize.Width + 8)
{
toDraw.Width = ((this.Width + this.Location.X) - Cursor.Position.X);
toDraw.X = Cursor.Position.X;
}
toDraw.Height = ((this.Height + this.Location.Y) - Cursor.Position.Y);
toDraw.Y = Cursor.Position.Y;
}
resizer.ToDraw = toDraw;
}
}
@ -147,8 +170,11 @@ private void top_MouseMove(object sender, MouseEventArgs e)
if(e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
if (resizable) toDraw.Y = Cursor.Position.Y;
if (resizable)
{
toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
toDraw.Y = Cursor.Position.Y;
}
resizer.ToDraw = toDraw;
}
}
@ -158,9 +184,12 @@ private void toprightcorner_MouseMove(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
{
var toDraw = resizer.ToDraw;
if (resizable) if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X;
if (resizable) toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
if (resizable) toDraw.Y = Cursor.Position.Y;
if (resizable)
{
if (MousePosition.X - this.Location.X > progContent.MinimumSize.Width + 8) toDraw.Width = MousePosition.X - this.Location.X;
toDraw.Height = ((toDraw.Height + toDraw.Top) - Cursor.Position.Y);
toDraw.Y = Cursor.Position.Y;
}
resizer.ToDraw = toDraw;
}
}