From aca8b94f48acf751899a8a3f670a9555cf423872 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 17 Oct 2012 15:57:14 -0400 Subject: [PATCH] Consolidate duplicate osrfMethodVerifyContext handler Log redaction was not occuring in some cases because the code was using the OSRF_METHOD_VERIFY_CONTEXT macro instead of the similarly named function which does the same thing. This change points the macro at the function so that all code uses the same underlying code. Note this change turns on CALL param logging unconditionally, whereas users of the macro would previously have been able to avoid CALL logging via the OSRF_LOG_PARAMS variable. In practice, little code uses the macro and all code enables OSRF_LOG_PARAMS. If we need to add this control back, it can be added directly to osrfMethodVerifyContext(). For now, it's one less env variable we need to define. Signed-off-by: Bill Erickson Signed-off-by: Dan Scott --- include/opensrf/osrf_application.h | 38 ++---------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/include/opensrf/osrf_application.h b/include/opensrf/osrf_application.h index d05f2cc..e50e114 100644 --- a/include/opensrf/osrf_application.h +++ b/include/opensrf/osrf_application.h @@ -57,42 +57,8 @@ extern "C" { */ /** This macro verifies that methods receive the correct parameters */ -#define _OSRF_METHOD_VERIFY_CONTEXT(d) \ - if(!d) return -1; \ - if(!d->session) { \ - osrfLogError( OSRF_LOG_MARK, "Session is NULL in app request" ); \ - return -1; \ - } \ - if(!d->method) { \ - osrfLogError( OSRF_LOG_MARK, "Method is NULL in app request" ); \ - return -1; \ - } \ - if(d->method->argc) { \ - if(!d->params) { \ - osrfLogError( OSRF_LOG_MARK, "Params is NULL in app request %s", d->method->name ); \ - return -1; \ - } \ - if( d->params->type != JSON_ARRAY ) { \ - osrfLogError( OSRF_LOG_MARK, "'params' is not a JSON array for method %s", \ - d->method->name); \ - return -1; } \ - } \ - if( !d->method->name ) { \ - osrfLogError( OSRF_LOG_MARK, "Method name is NULL"); return -1; \ - } - -#ifdef OSRF_LOG_PARAMS -#define OSRF_METHOD_VERIFY_CONTEXT(d) \ - _OSRF_METHOD_VERIFY_CONTEXT(d); \ - char* __j = jsonObjectToJSON(d->params); \ - if(__j) { \ - osrfLogInfo( OSRF_LOG_MARK, "CALL:\t%s %s - %s", d->session->remote_service, \ - d->method->name, __j);\ - free(__j); \ - } -#else -#define OSRF_METHOD_VERIFY_CONTEXT(d) _OSRF_METHOD_VERIFY_CONTEXT(d); -#endif +/** TODO: deprecate me, since I no longer server a purpose */ +#define OSRF_METHOD_VERIFY_CONTEXT(d) osrfMethodVerifyContext(d) /** @name Method options -- 2.43.2