libndr: moved the NDR_* flags to have less overlap
authorAndrew Tridgell <tridge@samba.org>
Wed, 7 Sep 2011 05:29:32 +0000 (15:29 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 8 Sep 2011 01:35:27 +0000 (03:35 +0200)
commit1c25f5ebca7eb4e8a6ce95b1adf6088d67aecb94
tree27215407729dbbceef70631d96e64191ab7b6e14
parent6e25723c82eced9eff8c06bd645b754008824370
libndr: moved the NDR_* flags to have less overlap

We have 3 different types of flags values in our NDR layer. We've
recently found bugs where these types of flags have been mixed up,
especially by people adding hand written ndr code for tricky
structures. We previously got away with this because (for example)
NDR_SCALARS and NDR_IN had the same value, so mixing up the two
concepts sometimes worked. Unfortunately it also led to bugs where we
didn't do what was expected, such as in our smbtorture ndr test suite,
where passing a ndr_flags value of zero led to only checking that two
empty structures were equal.

This changes the values of the NDR_IN|NDR_OUT and
NDR_SCALARS|NDR_BUFFERS values to be in different bit ranges, and adds
macros for checking the validity of passed in flags. A followup patch
modifies the ndr calls to use these macros, and pidl to generate
them. This should catch misuse of the APIs.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
librpc/ndr/libndr.h