[net.bugs.4bsd] Buglet or featurette in kernel printf %b format

jim@haring.UUCP (04/07/84)

Subject: Buglet or featurette in kernel printf %b format (trivia)
Index:	sys/sys/subr_prf.c 4.2BSD

Description:
	The %b option to printf produces odd results if the first
	argument (the bit-map) only contains bits which are not
	declared in the second argument (the bit-definitions), it
	prints an opening '<' bracket, but no closing one.

Repeat-By:
	Find a device which can give register contents which do not
	appear in the bit-definitions, and make it give an error...
	Alternatively add the routines printf(), prf() and printn() from
	subr_prf.c to the short program below and call it with various 
	integers as arguemnts, like 5. You should get
		5<

	#include <sys/types.h>

	#define	FORMAT	"\20\20XPWR\17ICAB\10PCTO\7ILLINT\6TIMEOUT\5POWER\4RMTC"

	main(argc, argv)
	char **argv;
	{
		register int x;

		argc--; argv++;
		while(argc){
			if((x = atoi(*argv)) != 0)
				printf("%b\n", x, FORMAT);
			argc--; argv++;
		}
		exit(0);
	}

Fix:
	How you fix it depends on whether you think the solution is to
	print a closing '>' barcket, or not to print the opening '<'.
	The actual code is left as an exercise for the interested reader.