Greatest change with the least effect.

On Monday, I fixed a bug in OpenSolaris. The bug was in xntpd and ntpdate, and was related to the changeover to using Mercurial starting next week. the problem was that SCCS (the current revision control system) does keyword expansion. This means that there are certain special strings stored in the source file while they are checked in, that, when the file is checked out of the system, get replaced by various other strings, such as the revision number of the file, or the time and date that the file was last changed.

Now, having this information in a file can be very handy. As a result, some executables where changed to include this information as a version string that is printed out. So, when you start up xntpd, it will log “xntpd 3-5.93e+sun 03/08/29 16:23:05 (1.4)” in the messages file. The date, time and version number you see are actually the date, time and version of a little file called version.c. So, every time someone makes a change to anything in xntpd, they also make a change to the version.c file, and thus it becomes easy to see what version of xntpd is installed.

The problem is that mercurial does not do this keyword expansion. So, once mercurial is in place, what people would have seen is “xntpd 3-5.93e+sun %E% %U% (%I%)”, which isn’t helpful at all. So, I had to go in and change the string, and remove the keywords and replace them with something meaningful.

That’s what I did on Monday. To avoid confusion, I just replaced the keywords with what they were already expanding into. Since I wasn’t actually making any changes in the behavior of xntpd, I figured that leaving the string the same would be best.

This had an interesting effect. Even though in the checked in file I was taking one string and replacing it with a longer string, the checked out files were identical. Almost all of the tools we use to format deltas like this actually compare the checked out versions, so all of them showed that I had made no change at all! I had to use a program called sccsdiff that happens to compare the checked in versions to allow others to review the changes.

And of course, when programs are compiled, they actually use checked out files, so as a result of this change, the xntpd program is bit by bit identical both before and after the change. This has got to be the smallest change (none!) for a substantive (non-comment, not formating, etc.) change in the code that I have ever made.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: