Subject: question about bitmask_snprintf(9)
To: None <current-users@netbsd.org>
From: Tetsuya Isaki <isaki@par.odn.ne.jp>
List: current-users
Date: 04/21/2007 15:39:05
I have a question about new format of bitmask_snprintf(9) in
-current.
I used new format of bitmask_snprintf(9) to display status
register in my device driver. And the status register is
consists of:
bit6 is 'NAK' if 1.
bit3 is 'D0' state if 0, 'D1' state if 1
bit0 is 'ACK' if 1.
(Other bits were ommited for easiness here.)
Here is the code I written, using 'F\B\L' and ':\V' features:
bitmask_snprintf(status_register,
"\177\20"
"b\6NAK\0"
"F\3\1" ":\1D1\0" ":\0D0\0" /* D0 or D1 */
"b\0ACK\0"
"\0",
str, sizeof(str));
printf("stat=%s\n", str);
I expect like:
stat=1<D0,ACK>
stat=9<D1,ACK>
stat=40<NAK,D0>
stat=48<NAK,D1>
but it displays:
stat=1D0<ACK>
stat=9D1<ACK>
stat=40<NAKD0>
stat=48<NAKD1>
So, do I miss the usage? or it this a bug? If it's a bug,
I can fix it with following patch. Does anyone review, please?
--- sys/kern/subr_prf.c~ 2007-03-21 23:32:31.000000000 +0900
+++ sys/kern/subr_prf.c 2007-03-21 23:36:53.000000000 +0900
@@ -980,6 +980,10 @@
goto skip;
if (ch == '=')
PUTBYTE(bp, '=', left);
+ else {
+ PUTBYTE(bp, sep, left);
+ sep = ',';
+ }
PUTSTR(bp, p, left);
break;
default:
---
Tetsuya Isaki <isaki@par.odn.ne.jp / isaki@NetBSD.org>