X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=common%2Ftr_idp_encoders.c;h=72acd159b3cf8d78d4e42b5f371dac0a53ae8cda;hb=cb18e83e9f4edd62e5316c19fa5870d46b10ffd4;hp=fec129a2f014f0fe4c0cecb4f5a759d920707ae6;hpb=441f3e4e60d5b005508f05d8c7718728c425202b;p=trust_router.git diff --git a/common/tr_idp_encoders.c b/common/tr_idp_encoders.c index fec129a..72acd15 100644 --- a/common/tr_idp_encoders.c +++ b/common/tr_idp_encoders.c @@ -40,6 +40,7 @@ #include #include #include +#include static char *tr_aaa_server_to_str(TALLOC_CTX *mem_ctx, TR_AAA_SERVER *aaa) { @@ -121,23 +122,6 @@ char *tr_idp_realm_to_str(TALLOC_CTX *mem_ctx, TR_IDP_REALM *idp) } -/* helper for below */ -#define OBJECT_SET_OR_FAIL(jobj, key, val) \ -do { \ - if (val) \ - json_object_set_new((jobj),(key),(val)); \ - else \ - goto cleanup; \ -} while (0) - -#define ARRAY_APPEND_OR_FAIL(jary, val) \ -do { \ - if (val) \ - json_array_append_new((jary),(val)); \ - else \ - goto cleanup; \ -} while (0) - static json_t *tr_apcs_to_json(TR_APC *apcs) { json_t *jarray = json_array(); @@ -148,10 +132,10 @@ static json_t *tr_apcs_to_json(TR_APC *apcs) if ((jarray == NULL) || (iter == NULL)) goto cleanup; - apc = tr_apc_iter_first(iter, apcs); - while (apc) { + for (apc = tr_apc_iter_first(iter, apcs); + apc != NULL; + apc = tr_apc_iter_next(iter)) { ARRAY_APPEND_OR_FAIL(jarray, tr_name_to_json_string(tr_apc_get_id(apc))); - apc = tr_apc_iter_next(iter); } /* success */ @@ -192,10 +176,10 @@ static json_t *tr_aaa_servers_to_json(TR_AAA_SERVER *aaas) if ((jarray == NULL) || (iter == NULL)) goto cleanup; - aaa = tr_aaa_server_iter_first(iter, aaas); - while (aaa) { + for (aaa = tr_aaa_server_iter_first(iter, aaas); + aaa != NULL; + aaa = tr_aaa_server_iter_next(iter)) { ARRAY_APPEND_OR_FAIL(jarray, tr_aaa_server_to_json(aaa)); - aaa = tr_aaa_server_iter_next(iter); } /* success */