I said I'd never blog

DeforaOS, NetBSD, reverse-engineering and stuff

Older stuff...

Debian sarge packages for some DeforaOS software
Mon May 14 01:16:24 CEST 2007

Ok, so before I go ahead and put it somewhere on www.defora.org (probably in the packages page), here is something I invite you to play with:

deb http://ftp.defora.org/debian sarge defora
deb-src http://ftp.defora.org/debian sarge defora

which you can directly include to your /etc/apt/sources.list if you are running Debian sarge.

You can safely replace "http" with "ftp" if you prefer.

The packages available so far are libsystem0, libsystem-dev, init, probe, and gputty.

I promise to write some documentation for all of this as soon as I can.

Update: yes, this will be available for etch when this machine gets an update.

Note for C/C++ developers and code auditors
Thu May 3 19:56:35 CEST 2007

Duh. I was lurking on fefe's web site this evening, and I stumbled upon GCC bug #30475 (and associated thread on GCC's mailing-list). I won't add my own comment here, but just try to summarize the essential.

The following integer overflow detection code:

1  signed int a = INT_MAX;
2  signed int b = 1;
3  
4  	if(a + b <= 0)
5  		exit(1); //integer overflow detection

is not correct. The C standard apparently says that signed integer overflows are undefined. This sort of security check code consequently breaks portability of the code, or at least cannot be proven correct.

Moreover, it seems the newest versions of GCC (>= 4.1) may optimize it out by default (e.g. even without specifying -O).

This definitely deserves the attention of developers and code auditors. There is probably a lot of code out there that may look safe but is not. Read more about it there.

Some good practices in Gtk+ programming
Wed May 2 21:43:49 CEST 2007

Not that I'm a Gtk+ guru, but there are a number of non-obvious things that may break if you don't pay attention:

  • call gtk_init() before getopt()
  • convert filenames to UTF-8 before use with g_filename_to_utf8()
  • call g_object_unref() whenever you have internally allocated something, used it somewhere and don't need it elsewhere (this is never obvious, check the documentation)
  • use extra variables to avoid macro expansions like GTK_TYPE() all the time (it improves readability too)
  • check in the documentation if the functions you are using exist in every version available, and otherwise make good use of GTK_CHECK_VERSION(); write alternative code whenever possible (it's often easy, and many users stuck with old Debian, Ubuntu or Solaris systems will thank you)

Other good links on this topic:

I will update this post as other things come to my mind.

IBM ACPI driver for NetBSD
Tue May 1 19:15:46 CEST 2007

If you are interested by the following features on your IBM/Lenovo laptop running NetBSD:

  • hotkey support
  • bluetooth enable/disable
  • hotbay ejection
  • on-the-fly video switching

then you may be interested by my implementation (just apply ibm_acpi.diff to your 4.0_BETA2 source tree).

The driver is taking direct inspiration from its already existing Linux equivalent, while trying to not infringe the GPL of course.

The way my driver currently works is probably wrong, because it directly hooks the hotkeys to the desired functionality. The problem lies in the fact that different IBM/Lenovo laptops may have different stickers on the corresponding hotkeys, and thus the driver may not behave as expected. For now I am mostly trying to achieve decent functionality on my T60, but feedback for different models would motivate me to enhance their support as well.

Things would be so much simpler with better DSDT tables...

Come again?
Tue May 1 19:05:52 CEST 2007

This blog opens again.

Come back...
Creative Commons License