My first patch to OpenBSD

Several days ago, I come across 2 posts which introduce OpenBSD Hackathon: Historical: My first OpenBSD Hackathon and Michael W. Lucas: Visiting the OpenBSD t2k13 Hackathon. From the reading, I find OpenBSD is a really distinctive and amazing project, especially after browsing its neat code mirror in github, which makes sure my assumption. So I decided to make my hands dirty on it.

Last weekend, I installed OpenBSD on an old machine, and checked out its fresh code from CVS repository. Because I think reading its code can let me get a better understanding about OpenBSD, even Unix philosophy, I decides to take the dmesg as the first experiment. During the reading, the following code gave me a hit unexpectedly:

mib[1] = startupmsgs ? KERN_CONSBUFSIZE : KERN_MSGBUFSIZE;
len = sizeof(msgbufsize);
if (sysctl(mib, 2, &msgbufsize, &len, NULL, 0))
    err(1, "sysctl: KERN_MSGBUFSIZE");
mib[1] = startupmsgs ? KERN_CONSBUF : KERN_MSGBUF;
len = msgbufsize;
if (sysctl(mib, 2, bufdata, &len, NULL, 0))
    err(1, "sysctl: KERN_MSGBUF");

The err() function always reports KERN_MSGBUFSIZE error even it is actually KERN_CONSBUFSIZE. So it should be a bug, at least should be an enhancement. I followed Preparing a diff and Making your first patch (OpenBSD) to submit my first OpenBSD patch. Guess what? just few hours later, dmesg source file was changed base on my code. Although the final modification is not my code, it is still a great pleasure that I contribute my own effort to help make OpenBSD better!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.