[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: back-config, overlays



> Pierangelo Masarati wrote:
>
>>I think the problem is related to slap_mask_t being an unsigned long,
>>while the "mask" field in slap_verbmasks is an int; so masking with
>>0x80000000U may be inappropriate...  I suggest that field is made a const
>>slap_mask_t for consistency;
>>
> Yes, changing that to slap_mask_t seems to have fixed it without
> breaking anything...

OK, fine with that.

>
>> note that since I'm using that code (and I
>>think you're using it in other parts of back-config) to implement a
>>verb2enum rather than a verb2masks, maybe we could add that too.
>>
> Hm, I don't see how a verb2enum function would be any different.

> verb_to_mask returns the index of the matching table entry, so whether
> it's really a mask or something else doesn't really matter, the caller
> can dereference the table and use the value.
>
>> My
>>masking with 0x80000000U is essentially to overcome the "if (!m) return;"
>>test in verb2mask...
>>
> You mean mask_to_verbs? There is no such test in verb_to_mask.

Yes, sorry.  My point is that, besides "if (!v[i].mask) continue;", which
doesn't work for 0 in enums, the following test may not work as expected:

        if (( m & v[i].mask ) == v[i].mask ) {

it occurs that a slap_verbmasks like

        { "foo", 1 }
        { "bar", 2 }
        { "foobar", 3 }

when invoked with mask_to_verbs( v, 3, bva ) would return { "foo", "bar",
"foobar" } because they all match!  In some cases, like in
back-bdb/config.c, for bdb_lockd you end up running a linear search, I
guess for this reason.  I think having a enum_to_verb would help.  I might
add one, since that's what I'm mostly using in back-ldap.

Ciao, p.


-- 
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it


    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497