java-examples: fix reported minor vulnerabilities

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu 2018-10-11 20:06:13 -07:00
parent d5cb613ad0
commit 94be00a63d
7 changed files with 28 additions and 16 deletions

View File

@ -24,8 +24,11 @@
public class A110X_intr_Example {
public static int counter=0;
private static int counter=0;
public static void incrementCounter() {
counter++;
}
public static void main(String[] args) throws InterruptedException {
//! [Interesting]
// Instantiate an A110X sensor on digital pin D2
@ -52,6 +55,6 @@ class A110XISR implements Runnable {
super();
}
public void run(){
A110X_intr_Example.counter++;
A110X_intr_Example.incrementCounter();
}
}

View File

@ -24,9 +24,12 @@
public class Button_intr_Example {
public static int counter = 0;
private static int counter = 0;
public static void main(String[] args) throws InterruptedException {
public static void incrementCounter() {
counter++;
}
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
upm_button.Button b = new upm_button.Button(2);
@ -47,7 +50,7 @@ class ButtonISR implements Runnable {
}
public void run() {
Button_intr_Example.counter++;
Button_intr_Example.incrementCounter();
System.out.println("Button pressed!");
}
}

View File

@ -32,7 +32,7 @@ public class FlexSensor_Example {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.toString());
}
}
//! [Interesting]

View File

@ -24,8 +24,11 @@
public class GroveButton_intr_Example {
public static int counter = 0;
private static int counter = 0;
public static void incrementCounter() {
counter++;
}
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
@ -47,7 +50,7 @@ class ButtonISR implements Runnable {
}
public void run() {
GroveButton_intr_Example.counter++;
GroveButton_intr_Example.incrementCounter();
System.out.println("Button pressed!");
}
}

View File

@ -40,7 +40,7 @@ public class GroveQTouch_Example {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(e.toString());
}
}
// ! [Interesting]

View File

@ -24,8 +24,11 @@
public class RPR220_intr_Example {
public static int counter = 0;
private static int counter = 0;
public static void incrementCounter() {
counter++;
}
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// This example uses an interrupt handler to increment a counter
@ -49,6 +52,6 @@ class RPRISR implements Runnable {
super();
}
public void run() {
RPR220_intr_Example.counter++;
RPR220_intr_Example.incrementCounter();
}
}

View File

@ -85,7 +85,7 @@ public class WT5001_Example {
vol = mp3.getVolume();
System.out.println("The current volume is: " + vol);
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.toString());
}
try {
@ -93,7 +93,7 @@ public class WT5001_Example {
ps = mp3.getPlayState();
System.out.println("The current play state is: " + ps);
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.toString());
}
try {
@ -101,7 +101,7 @@ public class WT5001_Example {
numf = mp3.getNumFiles(upm_wt5001.WT5001.WT5001_PLAYSOURCE_T.SD);
System.out.println("The number of files on the SD card is: " + numf);
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.toString());
}
try {
@ -109,7 +109,7 @@ public class WT5001_Example {
curf = mp3.getCurrentFile();
System.out.println("The current file is: " + curf);
} catch (IOException e) {
e.printStackTrace();
System.out.println(e.toString());
}
int year[] = new int[1];