On Wed, 2006-06-07 at 13:12 -0500, Larry Finger wrote:
> Dan Williams wrote:
> >
> > from ieee80211softmac_wx.c: ieee80211softmac_wx_set_genie()
> >
> > memcpy(mac->wpa.IE, extra, wrqu->data.length);
> > dprintk(KERN_INFO PFX "generic IE set to ");
> > for (i=0;i<wrqu->data.length;i++)
> > dprintk("%.2x", mac->wpa.IE[i]);
> > dprintk("\n");
> >
> > the dprintk code isn't doing the right thing here, given an array of
> > bytes. You probably want:
> >
> > dprintk("%.2hhx", mac->wpa.IE[i]);
> >
> > (ie, add the "hh" before the x to tell the print that it's a char)
> >
> That doesn't work - the result is
Weird, does the kernel not do something that fprintf() _does_ do here?
I tested with a short C program that mimics the behavior of this chunk
of code, and "%.2x" didn't work, but "%.2hhx" certainly did. "hh" is
supposed to mean "A following integer conversion corresponds to a signed
char or unsigned char argument". The original conversion was converting
stuff from la-la land after the first 4 bytes (in both softmac and my
testcase), and "hh" solved it in the testcase. I did try casting to
char, but glibc pretty much ignored that.
Dan
> %hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx%hx
>
> I changed the line to cast the output byte as a u8 as follows:
>
> dprintk("%.2x", (u8)mac->wpa.IE[i]);
>
> This produces the line
>
> generic IE set to dd160050f20101000050f20201000050f20201000050f202
>
> This is the WPA IE supplied by wpa_supplicant and it matches the one used in
> the ndiswrapper case.
> One mystery solved, but why doesn't it work?
>
> Johannes - should I submit the patch to fix this printout, or would you like
> to do it?
>
> Larry
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html