* mysterious -1 offset in staging rt2860 driver
@ 2010-03-04 19:14 Dan Carpenter
2010-03-05 9:44 ` walter harms
2010-03-06 0:21 ` Darren Jenkins
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2010-03-04 19:14 UTC (permalink / raw)
To: kernel-janitors
So here is a mystery for people who enjoy such mysterious things.
drivers/staging/rt2860/sta_ioctl.c +1020 rt_ioctl_giwscan(219)
1011 if (CAP_IS_PRIVACY_ON
1012 (pAdapter->ScanTab.BssEntry[i].CapabilityInfo))
1013 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1014 else
1015 iwe.u.data.flags = IW_ENCODE_DISABLED;
1016
1017 __smatch_value("iwe.u.data.flags");
1018 previous_ev = current_ev;
1019 current_ev 1020 iwe_stream_add_point(info, current_ev, end_buf, &iwe,
1021 (char *)pAdapter->
1022 SharedKey[BSS0][(iwe.u.data.
1023 flags &
1024 IW_ENCODE_INDEX) -
1025 1].Key);
That last bit is easier to read if it's on one line.
SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX) - 1].Key);
iwe.u.data.flags is either 0x0400 or 0x8000. IW_ENCODE_INDEX is 0xff, so
after we mask off the lower bits we get 0x00 and then we subtract 1 we get
an array offset of -1.
I doubt that's what we want, but what _do_ we want here?
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: mysterious -1 offset in staging rt2860 driver
2010-03-04 19:14 mysterious -1 offset in staging rt2860 driver Dan Carpenter
@ 2010-03-05 9:44 ` walter harms
2010-03-06 0:21 ` Darren Jenkins
1 sibling, 0 replies; 3+ messages in thread
From: walter harms @ 2010-03-05 9:44 UTC (permalink / raw)
To: kernel-janitors
Dan Carpenter schrieb:
> So here is a mystery for people who enjoy such mysterious things.
>
> drivers/staging/rt2860/sta_ioctl.c +1020 rt_ioctl_giwscan(219)
> 1011 if (CAP_IS_PRIVACY_ON
> 1012 (pAdapter->ScanTab.BssEntry[i].CapabilityInfo))
> 1013 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
> 1014 else
> 1015 iwe.u.data.flags = IW_ENCODE_DISABLED;
> 1016
> 1017 __smatch_value("iwe.u.data.flags");
> 1018 previous_ev = current_ev;
> 1019 current_ev > 1020 iwe_stream_add_point(info, current_ev, end_buf, &iwe,
> 1021 (char *)pAdapter->
> 1022 SharedKey[BSS0][(iwe.u.data.
> 1023 flags &
> 1024 IW_ENCODE_INDEX) -
> 1025 1].Key);
>
>
> That last bit is easier to read if it's on one line.
>
> SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX) - 1].Key);
>
> iwe.u.data.flags is either 0x0400 or 0x8000. IW_ENCODE_INDEX is 0xff, so
> after we mask off the lower bits we get 0x00 and then we subtract 1 we get
> an array offset of -1.
>
> I doubt that's what we want, but what _do_ we want here?
I used http://tomoyo.sourceforge.jp/cgi-bin/lxr/ident?i=IW_ENCODE_INDEX to get an idea,
and it seems most times the index is protected by
if ( idx<0) what seems to indicate that the index should start with 1 (very wired).
NTL this is unreadable code and should be desected.
perhaps:
idx=iwe.u.data.flags & IW_ENCODE_INDEX) - 1
char *key=pAdapter->SharedKey[BSS0][idx].key
but i have still no idea about this -1 it does not fit well.
just my 2 cents,
walter
> regards,
> dan carpenter
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: mysterious -1 offset in staging rt2860 driver
2010-03-04 19:14 mysterious -1 offset in staging rt2860 driver Dan Carpenter
2010-03-05 9:44 ` walter harms
@ 2010-03-06 0:21 ` Darren Jenkins
1 sibling, 0 replies; 3+ messages in thread
From: Darren Jenkins @ 2010-03-06 0:21 UTC (permalink / raw)
To: kernel-janitors
On Fri, Mar 5, 2010 at 6:14 AM, Dan Carpenter <error27@gmail.com> wrote:
> So here is a mystery for people who enjoy such mysterious things.
>
> drivers/staging/rt2860/sta_ioctl.c +1020 rt_ioctl_giwscan(219)
> 1011 if (CAP_IS_PRIVACY_ON
> 1012 (pAdapter->ScanTab.BssEntry[i].CapabilityInfo))
> 1013 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
> 1014 else
> 1015 iwe.u.data.flags = IW_ENCODE_DISABLED;
> 1016
> 1017 __smatch_value("iwe.u.data.flags");
> 1018 previous_ev = current_ev;
> 1019 current_ev > 1020 iwe_stream_add_point(info, current_ev, end_buf, &iwe,
> 1021 (char *)pAdapter->
> 1022 SharedKey[BSS0][(iwe.u.data.
> 1023 flags &
> 1024 IW_ENCODE_INDEX) -
> 1025 1].Key);
>
>
> That last bit is easier to read if it's on one line.
>
> SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX) - 1].Key);
>
> iwe.u.data.flags is either 0x0400 or 0x8000. IW_ENCODE_INDEX is 0xff, so
> after we mask off the lower bits we get 0x00 and then we subtract 1 we get
> an array offset of -1.
>
> I doubt that's what we want, but what _do_ we want here?
>
Looking at the use of IW_ENCODE_INDEX elsewhere it seems to be a mask
for a key value that can be 0..4 where 0 means some default value and
1 - 4 means use value-- ie 0 - 3.
iwe.u.data.flags is assigned to 1 earlier so I would assume the code should be
iwe.u.data.flags &= ~ IW_ENCODE_FLAGS
>> 1011 if (CAP_IS_PRIVACY_ON
>> 1012 (pAdapter->ScanTab.BssEntry[i].CapabilityInfo))
>> 1013 iwe.u.data.flags |= IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
>> 1014 else
>> 1015 iwe.u.data.flags |= IW_ENCODE_DISABLED;
Which I think would both make sense and give an array index of 0.
Darren J.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-06 0:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-04 19:14 mysterious -1 offset in staging rt2860 driver Dan Carpenter
2010-03-05 9:44 ` walter harms
2010-03-06 0:21 ` Darren Jenkins
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.