/*
* xlat.c
*/
-void fr_aka_sim_xlat_func_register(void);
+int fr_aka_sim_xlat_func_register(void);
void fr_aka_sim_xlat_func_unregister(void);
return XLAT_ACTION_DONE;
}
-void fr_aka_sim_xlat_func_register(void)
+int fr_aka_sim_xlat_func_register(void)
{
xlat_t *xlat;
if (aka_sim_xlat_refs) {
aka_sim_xlat_refs++;
- return;
+ return 0;
}
- xlat = xlat_func_register(NULL, "aka_sim_id_method", aka_sim_xlat_id_method_xlat, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "aka_sim_id_method", aka_sim_xlat_id_method_xlat, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_args_set(xlat, aka_sim_xlat_id_method_xlat_args);
- xlat = xlat_func_register(NULL, "aka_sim_id_type", aka_sim_xlat_id_type_xlat, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "aka_sim_id_type", aka_sim_xlat_id_type_xlat, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_args_set(xlat, aka_sim_xlat_id_type_xlat_args);
- xlat = xlat_func_register(NULL, "3gpp_temporary_id_key_index", aka_sim_id_3gpp_temporary_id_key_index_xlat, FR_TYPE_UINT8);
+ if (unlikely((xlat = xlat_func_register(NULL, "3gpp_temporary_id_key_index", aka_sim_id_3gpp_temporary_id_key_index_xlat, FR_TYPE_UINT8)) == NULL)) return -1;
xlat_func_args_set(xlat, aka_sim_id_3gpp_temporary_id_key_index_xlat_args);
- xlat = xlat_func_register(NULL, "3gpp_temporary_id_decrypt", aka_sim_3gpp_temporary_id_decrypt_xlat, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "3gpp_temporary_id_decrypt", aka_sim_3gpp_temporary_id_decrypt_xlat, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_args_set(xlat, aka_sim_3gpp_temporary_id_decrypt_xlat_args);
- xlat = xlat_func_register(NULL, "3gpp_temporary_id_encrypt", aka_sim_3gpp_temporary_id_encrypt_xlat, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "3gpp_temporary_id_encrypt", aka_sim_3gpp_temporary_id_encrypt_xlat, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_args_set(xlat, aka_sim_3gpp_temporary_id_encrypt_xlat_args);
aka_sim_xlat_refs = 1;
+
+ return 0;
}
void fr_aka_sim_xlat_func_unregister(void)
/*
* Register the %(config:section.subsection) xlat function.
*/
- xlat = xlat_func_register(NULL, "config", xlat_config, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "config", xlat_config, FR_TYPE_STRING)) == NULL)) goto failure;
xlat_func_args_set(xlat, xlat_config_args);
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE);
return talloc_get_type_abort(intp_thread_default, unlang_interpret_t);
}
-void unlang_interpret_init_global(void)
+int unlang_interpret_init_global(void)
{
xlat_t *xlat;
/*
* Should be void, but someone decided not to register multiple xlats
* breaking the convention we use everywhere else in the server...
*/
- xlat = xlat_func_register(NULL, "interpreter", unlang_interpret_xlat, FR_TYPE_VOID);
+ if (unlikely((xlat = xlat_func_register(NULL, "interpreter", unlang_interpret_xlat, FR_TYPE_VOID)) == NULL)) return -1;
xlat_func_args_set(xlat, unlang_interpret_xlat_args);
- xlat = xlat_func_register(NULL, "cancel", unlang_cancel_xlat, FR_TYPE_VOID);
+ if (unlikely((xlat = xlat_func_register(NULL, "cancel", unlang_cancel_xlat, FR_TYPE_VOID)) == NULL)) return -1;
xlat_func_args_set(xlat, unlang_cancel_xlat_args);
+
+ return 0;
}
TALLOC_CTX *unlang_interpret_frame_talloc_ctx(request_t *request);
-void unlang_interpret_init_global(void);
+int unlang_interpret_init_global(void);
#ifdef __cplusplus
}
#endif
XLAT_REGISTER_MONO("rand", xlat_func_rand, FR_TYPE_UINT64, xlat_func_rand_arg);
XLAT_REGISTER_MONO("randstr", xlat_func_randstr, FR_TYPE_STRING, xlat_func_randstr_arg);
- xlat = xlat_func_register(NULL, "module", xlat_func_module, FR_TYPE_STRING);
+ if (unlikely((xlat = xlat_func_register(NULL, "module", xlat_func_module, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL);
return xlat_register_expressions();
#undef XLAT_REGISTER_BINARY_OP
#define XLAT_REGISTER_BINARY_OP(_op, _name) \
do { \
- if (!(xlat = xlat_func_register(NULL, "op_" STRINGIFY(_name), xlat_func_op_ ## _name, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, "op_" STRINGIFY(_name), xlat_func_op_ ## _name, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_args_set(xlat, binary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_print_set(xlat, xlat_expr_print_binary); \
#undef XLAT_REGISTER_BINARY_CMP
#define XLAT_REGISTER_BINARY_CMP(_op, _name) \
do { \
- if (!(xlat = xlat_func_register(NULL, "cmp_" STRINGIFY(_name), xlat_func_cmp_ ## _name, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, "cmp_" STRINGIFY(_name), xlat_func_cmp_ ## _name, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_args_set(xlat, binary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_print_set(xlat, xlat_expr_print_binary); \
#undef XLAT_REGISTER_NARY_OP
#define XLAT_REGISTER_NARY_OP(_op, _name, _func_name) \
do { \
- if (!(xlat = xlat_func_register(NULL, STRINGIFY(_name), xlat_func_ ## _func_name, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, STRINGIFY(_name), xlat_func_ ## _func_name, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_async_instantiate_set(xlat, xlat_instantiate_ ## _func_name, xlat_ ## _func_name ## _inst_t, NULL, NULL); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_print_set(xlat, xlat_expr_print_ ## _func_name); \
#undef XLAT_REGISTER_REGEX_OP
#define XLAT_REGISTER_REGEX_OP(_op, _name) \
do { \
- if (!(xlat = xlat_func_register(NULL, STRINGIFY(_name), xlat_func_ ## _name, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, STRINGIFY(_name), xlat_func_ ## _name, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_args_set(xlat, regex_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_async_instantiate_set(xlat, xlat_instantiate_regex, xlat_regex_inst_t, NULL, NULL); \
#define XLAT_REGISTER_MONO(_xlat, _func, _arg) \
do { \
- if (!(xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_mono_set(xlat, _arg); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL); \
} while (0)
#define XLAT_REGISTER_UNARY(_op, _xlat, _func) \
do { \
- if (!(xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_VOID))) return -1; \
+ if (unlikely((xlat = xlat_func_register(NULL, _xlat, _func, FR_TYPE_VOID)) == NULL)) return -1; \
xlat_func_args_set(xlat, unary_op_xlat_args); \
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_PURE | XLAT_FUNC_FLAG_INTERNAL); \
xlat_func_print_set(xlat, xlat_expr_print_unary); \
/*
* Callback wrapper around old paircmp() API.
*/
- if (!(xlat = xlat_func_register(NULL, "paircmp", xlat_paircmp_func, FR_TYPE_VOID))) return -1; /* never pure! */
+ if (unlikely((xlat = xlat_func_register(NULL, "paircmp", xlat_paircmp_func, FR_TYPE_VOID)) == NULL)) return -1; /* never pure! */
xlat_func_args_set(xlat, xlat_paircmp_xlat_args);
xlat_func_flags_set(xlat, XLAT_FUNC_FLAG_INTERNAL);
}
xlat = xlat_func_register(NULL, name2, xlat_redundant, return_type);
- if (!xlat) {
+ if (unlikely(xlat == NULL)) {
ERROR("Registering xlat for %s section failed",
fr_table_str_by_value(xlat_redundant_type_table, xr->type, "<INVALID>"));
talloc_free(xr);
{
xlat_t *xlat;
- xlat = xlat_func_register(NULL, "chap_password", xlat_func_chap_password, FR_TYPE_OCTETS);
- if (!xlat) return -1;
+ if (unlikely((xlat = xlat_func_register(NULL, "chap_password", xlat_func_chap_password, FR_TYPE_OCTETS)) == NULL)) return -1;
xlat_func_args_set(xlat, xlat_func_chap_password_args);
return 0;
{
xlat_t *xlat;
- xlat = xlat_func_register(NULL, "client", xlat_client, FR_TYPE_STRING);
- if (!xlat) return -1;
+ if (unlikely((xlat = xlat_func_register(NULL, "client", xlat_client, FR_TYPE_STRING)) == NULL)) return -1;
xlat_func_args_set(xlat, xlat_client_args);
map_proc_register(NULL, "client", map_proc_client, NULL, 0);