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

Re: casting is_entry_foo() to int



At 08:54 PM 1/18/2003, Hallvard B Furuseth wrote:
>servers/slapd/proto-slap.h has several definitions
>
>#define is_entry_foo(e)         \
>    (((e)->e_ocflags & SLAP_OC__END) ? ((e)->e_ocflags & SLAP_OC_FOO) : \
>    is_entry_objectclass((e), slap_schema.si_oc_foo, 1))
>
>Is it OK if I cast ((e)->e_ocflags & SLAP_OC_FOO) to int?
>That removes a lot of 'signed vs. unsigned' warnings.
>The SLAPD_OC_<FOO> constants are all less than INT_MAX.
>
>While I'm at it, I'd like to reformat the definitions to
>
>#define is_entry_foo(e)         \
>    (((e)->e_ocflags & SLAP_OC__END) \
>     ? (int) ((e)->e_ocflags & SLAP_OC_FOO) \
>     : is_entry_objectclass((e), slap_schema.si_oc_foo, 1))


How about

#define is_entry_foo(e) \
        (((e)->e_ocflags & SLAP_OC__END) \
                ? (((e)->e_ocflags & SLAP_OC_FOO) ? 1 : 0) \
                : is_entry_objectclass((e), slap_schema.si_oc_foo, 1))



>to avoid lines longer than 80 chars.
>
>-- 
>Hallvard