未验证 提交 af72ad77 编写于 作者: Z zdenop 提交者: GitHub

Merge pull request #1531 from stweil/cov

java: Fix some issues reported by Coverity Scan
...@@ -371,9 +371,8 @@ public class ScrollView { ...@@ -371,9 +371,8 @@ public class ScrollView {
intPattern = Pattern.compile("[0-9-][0-9]*"); intPattern = Pattern.compile("[0-9-][0-9]*");
floatPattern = Pattern.compile("[0-9-][0-9]*\\.[0-9]*"); floatPattern = Pattern.compile("[0-9-][0-9]*\\.[0-9]*");
try { // Open a socket to listen on.
// Open a socket to listen on. try (ServerSocket serverSocket = new ServerSocket(SERVER_PORT)) {
ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
System.out.println("Socket started on port " + SERVER_PORT); System.out.println("Socket started on port " + SERVER_PORT);
// Wait (blocking) for an incoming connection // Wait (blocking) for an incoming connection
......
...@@ -30,7 +30,6 @@ import javax.swing.JCheckBoxMenuItem; ...@@ -30,7 +30,6 @@ import javax.swing.JCheckBoxMenuItem;
*/ */
class SVCheckboxMenuItem extends SVAbstractMenuItem { class SVCheckboxMenuItem extends SVAbstractMenuItem {
public String value = null; public String value = null;
public String desc = null;
public boolean bvalue; public boolean bvalue;
SVCheckboxMenuItem(int id, String name, boolean val) { SVCheckboxMenuItem(int id, String name, boolean val) {
......
...@@ -204,10 +204,20 @@ public class SVWindow extends JFrame { ...@@ -204,10 +204,20 @@ public class SVWindow extends JFrame {
super(name); super(name);
// Provide defaults for sizes. // Provide defaults for sizes.
if (sizeX == 0) sizeX = canvasSizeX; if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY == 0) sizeY = canvasSizeY; if (sizeY <= 0) sizeY = canvasSizeY;
if (canvasSizeX == 0) canvasSizeX = sizeX; if (canvasSizeX <= 0) canvasSizeX = sizeX;
if (canvasSizeY == 0) canvasSizeY = sizeY; if (canvasSizeY <= 0) canvasSizeY = sizeY;
// Avoid later division by zero.
if (sizeX <= 0) {
sizeX = 1;
canvasSizeX = sizeX;
}
if (sizeY <= 0) {
sizeY = 1;
canvasSizeY = sizeY;
}
// Initialize variables // Initialize variables
nrWindows++; nrWindows++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册