+/*
+ Common cleanup on initialisation error. These are hard to force, and this helps to ensure
+ all code is tested by providing a callable rather than a block of "goto" code.
+
+ There is a return value so that where we need this we get dinked only for one
+ uncovered line rather than two:
+ init_err(...);
+ return NULL;
+
+ That's a hack, and is yet another example of the testing tail wagging the dog.
+*/
+static inline void* init_err( char* msg, void* ctx, void* port, int errval ) {
+ if( errval != 0 ) { // if not letting it be what a sysllib set it to...
+ errno = errval;
+ }
+
+ if( port ) { // free things if allocated
+ free( port );
+ }
+ if( ctx ) {
+ free_ctx( ctx );
+ }
+
+ if( msg ) { // crit message if supplied
+ rmr_vlog( RMR_VL_CRIT, "rmr_init: %s: %s", msg, strerror( errno ) );
+ }
+
+ return NULL;
+}