Skip to content

Commit

Permalink
Merge pull request #1531 from stweil/cov
Browse files Browse the repository at this point in the history
java: Fix some issues reported by Coverity Scan
  • Loading branch information
zdenop committed Apr 26, 2018
2 parents 3c269c9 + 62df5ae commit af72ad7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
5 changes: 2 additions & 3 deletions java/com/google/scrollview/ScrollView.java
Expand Up @@ -371,9 +371,8 @@ public static void main(String[] args) {
intPattern = Pattern.compile("[0-9-][0-9]*");
floatPattern = Pattern.compile("[0-9-][0-9]*\\.[0-9]*");

try {
// Open a socket to listen on.
ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
// Open a socket to listen on.
try (ServerSocket serverSocket = new ServerSocket(SERVER_PORT)) {
System.out.println("Socket started on port " + SERVER_PORT);

// Wait (blocking) for an incoming connection
Expand Down
1 change: 0 additions & 1 deletion java/com/google/scrollview/ui/SVCheckboxMenuItem.java
Expand Up @@ -30,7 +30,6 @@
*/
class SVCheckboxMenuItem extends SVAbstractMenuItem {
public String value = null;
public String desc = null;
public boolean bvalue;

SVCheckboxMenuItem(int id, String name, boolean val) {
Expand Down
18 changes: 14 additions & 4 deletions java/com/google/scrollview/ui/SVWindow.java
Expand Up @@ -204,10 +204,20 @@ public SVWindow(String name, int hash, int posX, int posY, int sizeX,
super(name);

// Provide defaults for sizes.
if (sizeX == 0) sizeX = canvasSizeX;
if (sizeY == 0) sizeY = canvasSizeY;
if (canvasSizeX == 0) canvasSizeX = sizeX;
if (canvasSizeY == 0) canvasSizeY = sizeY;
if (sizeX <= 0) sizeX = canvasSizeX;
if (sizeY <= 0) sizeY = canvasSizeY;
if (canvasSizeX <= 0) canvasSizeX = sizeX;
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
nrWindows++;
Expand Down

0 comments on commit af72ad7

Please sign in to comment.