author | zecke <zecke> | 2004-07-13 13:24:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-07-13 13:24:59 (UTC) |
commit | 74f19a502a513258f88a75e057a5998393e3c7f6 (patch) (unidiff) | |
tree | 3e905a7b2dd6776e4e1f1204510b95599477965f | |
parent | 4a31bc0d4c9a30583200e866f21340448d41d1c2 (diff) | |
download | opie-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
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 |
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 | |||
310 | ::gettimeofday ( &tvs, 0 ); | 310 | ::gettimeofday ( &tvs, 0 ); |
311 | 311 | ||
312 | ::sync(); // flush fs caches | 312 | ::sync(); // flush fs caches |
313 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 313 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
314 | 314 | ||
315 | return res; | 315 | return res; |
316 | } | 316 | } |
317 | 317 | ||
318 | 318 | ||
319 | bool SIMpad::setSoftSuspend ( bool soft ) | 319 | bool SIMpad::setSoftSuspend ( bool soft ) |
320 | { | 320 | { |
321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 321 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
322 | return false; | 322 | return false; |
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | bool SIMpad::setDisplayStatus ( bool on ) | 326 | bool SIMpad::setDisplayStatus ( bool on ) |
327 | { | 327 | { |
328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 328 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
329 | 329 | ||
330 | bool res = false; | 330 | bool res = false; |
331 | int fd; | 331 | int fd; |
332 | 332 | ||
333 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 333 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
334 | 334 | ||
335 | res = ( ::system( (const char*) cmdline ) == 0 ); | 335 | res = ( ::system( (const char*) cmdline ) == 0 ); |
336 | 336 | ||
337 | return res; | 337 | return res; |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | bool SIMpad::setDisplayBrightness ( int bright ) | 341 | bool SIMpad::setDisplayBrightness ( int bright ) |
342 | { | 342 | { |
343 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 343 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
344 | bool res = false; | 344 | bool res = false; |
345 | int fd; | 345 | int fd; |
346 | 346 | ||
347 | if ( bright > 255 ) | 347 | if ( bright > 255 ) |
348 | bright = 255; | 348 | bright = 255; |
349 | if ( bright < 1 ) | 349 | if ( bright < 1 ) |
350 | bright = 0; | 350 | bright = 0; |
351 | 351 | ||
352 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 352 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
353 | int value = 255 - bright; | 353 | int value = 255 - bright; |
354 | const int mask = SIMPAD_BACKLIGHT_MASK; | 354 | const int mask = SIMPAD_BACKLIGHT_MASK; |
355 | value = value << 8; | 355 | value = value << 8; |
356 | value += mask; | 356 | value += mask; |
357 | char writeCommand[100]; | 357 | char writeCommand[100]; |
358 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 358 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); |
359 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 359 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
360 | ::close ( fd ); | 360 | ::close ( fd ); |
361 | } | 361 | } |
362 | return res; | 362 | return res; |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | int SIMpad::displayBrightnessResolution() const | 366 | int SIMpad::displayBrightnessResolution() const |
367 | { | 367 | { |
368 | return 255; // All SIMpad models share the same display | 368 | return 255; // All SIMpad models share the same display |
369 | } | 369 | } |
370 | 370 | ||