summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-13 13:24:59 (UTC)
committer zecke <zecke>2004-07-13 13:24:59 (UTC)
commit74f19a502a513258f88a75e057a5998393e3c7f6 (patch) (side-by-side diff)
tree3e905a7b2dd6776e4e1f1204510b95599477965f
parent4a31bc0d4c9a30583200e866f21340448d41d1c2 (diff)
downloadopie-74f19a502a513258f88a75e057a5998393e3c7f6.zip
opie-74f19a502a513258f88a75e057a5998393e3c7f6.tar.gz
opie-74f19a502a513258f88a75e057a5998393e3c7f6.tar.bz2
Use snprintf to just be sure that we don't go over the buffer limit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 76f03a0..e62ea18 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -310,61 +310,61 @@ bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
return res;
}
bool SIMpad::setSoftSuspend ( bool soft )
{
qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
return false;
}
bool SIMpad::setDisplayStatus ( bool on )
{
qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
bool res = false;
int fd;
QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
res = ( ::system( (const char*) cmdline ) == 0 );
return res;
}
bool SIMpad::setDisplayBrightness ( int bright )
{
qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 1 )
bright = 0;
if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
int value = 255 - bright;
const int mask = SIMPAD_BACKLIGHT_MASK;
value = value << 8;
value += mask;
char writeCommand[100];
- const int count = sprintf( writeCommand, "0x%x\n", value );
+ const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
res = ( ::write ( fd, writeCommand, count ) != -1 );
::close ( fd );
}
return res;
}
int SIMpad::displayBrightnessResolution() const
{
return 255; // All SIMpad models share the same display
}