author | zecke <zecke> | 2004-03-13 21:59:48 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-13 21:59:48 (UTC) |
commit | ee753c0009da5bec4a71d3263e9623d04dddc5c4 (patch) (side-by-side diff) | |
tree | f578536203c4277cc124d622b50f46a025cbb3f9 | |
parent | 2eb5c075b612498c4b65f3d49389b8612612a930 (diff) | |
download | opie-ee753c0009da5bec4a71d3263e9623d04dddc5c4.zip opie-ee753c0009da5bec4a71d3263e9623d04dddc5c4.tar.gz opie-ee753c0009da5bec4a71d3263e9623d04dddc5c4.tar.bz2 |
Fix possible divide by null
Patch for mickeyl...
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index ab3e77f..26a6c81 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -993,33 +993,34 @@ int OWirelessNetworkInterface::signalStrength() const iw_statistics stat;
::memset( &stat, 0, sizeof stat );
_iwr.u.data.pointer = (char*) &stat;
_iwr.u.data.flags = 0;
_iwr.u.data.length = sizeof stat;
if ( !wioctl( SIOCGIWSTATS ) )
{
return -1;
}
int max = _range.max_qual.qual;
int cur = stat.qual.qual;
int lev = stat.qual.level; //FIXME: Do something with them?
int noi = stat.qual.noise; //FIXME: Do something with them?
- return cur*100/max;
+
+ return max != 0 ? cur*100/max: -1;
}
bool OWirelessNetworkInterface::wioctl( int call, struct iwreq& iwreq ) const
{
#ifndef NODEBUG
int result = ::ioctl( _sfd, call, &iwreq );
if ( result == -1 )
odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
<< debugmapper->map( call ) << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
else
odebug << "ONetworkInterface::wioctl (" << name() << ") call '"
<< debugmapper->map( call ) << "' - Status: Ok." << oendl;
return ( result != -1 );
|