Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site haring.UUCP Path: utzoo!watmath!clyde!floyd!harpo!decvax!mcvax!turing!haring!jim From: jim@haring.UUCP Newsgroups: net.bugs.4bsd,net.unix-wizards Subject: Buglet or featurette in kernel printf %b format (trivia) Message-ID: <237@haring.UUCP> Date: Sat, 7-Apr-84 03:52:02 EST Article-I.D.: haring.237 Posted: Sat Apr 7 03:52:02 1984 Date-Received: Sat, 7-Apr-84 06:21:13 EST Organization: CWI, Amsterdam Lines: 39 Apparently-To: rnews@turing.LOCAL 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 #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.