May I wrap all "foo->backend_op(op, rs)" calls in new macros SLAP_OP()/slap_be_op()/slap_bi_op()?
It's for ITS#6758, SlapReply cleanup. The macros expand to the original code, except CPPFLAGS=-D"SOMETHING" uncovers a backend.c function with assertions before and after the backend call. Also code using a backend function array (example 4 below) needs tweaks.
Four types of changes. Examples, -old +new:
- rc = op->o_bd->be_modrdn( op, rs ); /* Operation *op */ + rc = SLAP_OP( op_modrdn, op, rs );
- rc = be->be_operational( op, rs ); /* BackendDB *be */ + rc = slap_be_op( be, op_aux_operational, op, rs );
- rc = bi.bi_op_search( op, rs ); /* BackendInfo bi */ + rc = slap_bi_op( &bi, op_search, op, rs );
/* &be->be_bind == "array of backend function ptrs" hack */ - func = &be->be_bind; ...; rc = func[ which ]( op, rs ); + bi = be->bd_info; ...; rc = slap_bi_op( bi, which, op, rs );
Quanah, the first three are ~150 changes to 50 files, which I expect can be a bother to merge into RE24. I can instead commit the script which makes the diffs, and let you run it when it suits you. (Generate the diffs for RE24 but apply them to HEAD, ignoring rejects, and you have the conflict-free changes. Leaves ~20 needing more care.)
Wrapper function and macros:
int (slap_bi_op)(BackendInfo*, slap_operation_t, Operation*, SlapReply*); #if !SOMETHING #define slap_bi_op(bi,which,op,rs) ((&(bi)->bi_op_bind)[ which ](op,rs)) #endif #define slap_be_op(be,which,op,rs) slap_bi_op((be)->bd_info,which,op,rs) #define SLAP_OP( which,op,rs) slap_be_op((op)->o_bd, which,op,rs)
SLAP_OP is uppercase since it evaluates op twice, unlike function calls.
My current SOMETHING is (defined(USE_RS_ASSERT) && (USE_RS_ASSERT)), which enables the assert(SlapReply OK) macros from ITS#6758. Maybe in this context it should be a more general SLAPD_DEBUG or (defined(SLAPD_DEBUG) ? (SLAPD_DEBUG) : defined(LDAP_TEST)) ? portable.h #defines LDAP_TEST when LDAP_DEVEL, not in releases.
Draft patches: http://folk.uio.no/hbf/OpenLDAP/wrap_slap_ops.txt.