Revision: 5997 http://sourceforge.net/p/jnode/svn/5997 Author: epr Date: 2013-11-12 15:20:54 +0000 (Tue, 12 Nov 2013) Log Message: ----------- Avoid nullpointer exception.
Modified Paths: -------------- trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java Modified: trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java 2013-11-12 15:20:24 UTC (rev 5996) +++ trunk/core/src/driver/org/jnode/driver/chipset/i440BX/i82371AB_ACPI_SMBusControler.java 2013-11-12 15:20:54 UTC (rev 5997) @@ -20,8 +20,11 @@ package org.jnode.driver.chipset.i440BX; +import java.io.IOException; import java.security.PrivilegedExceptionAction; + import javax.naming.NameNotFoundException; + import org.apache.log4j.Logger; import org.jnode.driver.DeviceUtils; import org.jnode.driver.DriverException; @@ -129,12 +132,20 @@ public boolean sendByte(byte address, byte value) throws java.security.InvalidParameterException, java.lang.UnsupportedOperationException { + if (ioRes == null) { + throw new UnsupportedOperationException("IO resource not available"); + } ioRes.outPortByte(hostAddressIORegister, address | ADDRESS_WRITE_TAG); ioRes.outPortByte(hostData0IORegister, value); ioRes.outPortByte(hostCommandIORegister, value); ioRes.outPortByte(hostControlIORegister, CONTROL_START | CONTROL_PROTOCOL_READWRITE_BYTE | CONTROL_INTERUPT_DISABLED); - byte status = statusWait(); + byte status; + try { + status = statusWait(); + } catch (IOException e) { + throw new UnsupportedOperationException(e); + } return status == 0; } @@ -317,12 +328,15 @@ } - private void reset() { + private void reset() throws IOException { statusWait(); // just make sure it is available (may be errors due to last conditions so... ioRes.outPortByte(hostStatusIORegister, 0x1e); // ...clears the error bits } - private byte statusWait() { + private byte statusWait() throws IOException { + if (ioRes == null) { + throw new IOException("IO resource not available"); + } byte status = 0; for (int i = 0; i < 500; i++) ; // dumb delay : see specification update status = (byte) ioRes.inPortByte(hostStatusIORegister); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ November Webinars for C, C++, Fortran Developers Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits