if (argc == 0) {
fr_perror("radlock - Need file to operate on");
usage(64);
- };
+ }
if (argc == 1) {
fr_perror("radlock - Need action, must be one of (lock|trylock|unlock|remove|info|perm)");
fr_strerror_clear();
#define NEXT_LINE(_line, _buffer) \
-{ \
+do { \
size_t _len; \
if (stop) return 0; \
errno = 0;\
if ((_len > 0) && (_line[_len - 1] == '\n')) _line[_len - 1] = '\0'; \
DEBUG2("read: %s", _line); \
} \
-}
+} while (0)
+
/*
* Read commands from pass_persist
*/
module_ctx_t const *mctx, \
request_t *request)
-#define STATE_TRANSITION(_x) guard_ ## _x(p_result, mctx, request);
+#define STATE_TRANSITION(_x) guard_ ## _x(p_result, mctx, request)
#define CALL_SECTION(_x) unlang_module_yield_to_section(p_result, \
request, \
default:
fail:
RWDEBUG("Failure-Notification not ACKed correctly, sending EAP-Failure anyway");
- return STATE_TRANSITION(eap_failure)
+ return STATE_TRANSITION(eap_failure);
}
}
#define cas_decr(_store, _var) atomic_compare_exchange_strong_explicit(&_store, &_var, _var - 1, memory_order_release, memory_order_relaxed)
#define load(_var) atomic_load_explicit(&_var, memory_order_relaxed)
#define aquire(_var) atomic_load_explicit(&_var, memory_order_acquire)
-#define store(_store, _var) atomic_store_explicit(&_store, _var, memory_order_release);
+#define store(_store, _var) atomic_store_explicit(&_store, _var, memory_order_release)
#ifdef __cplusplus
extern "C" {
fr_assert(fr_time_lteq((_tt)->ended, (_now))); \
fr_assert(fr_time_lteq((_tt)->last_yielded, (_now))); \
fr_assert(fr_time_lteq((_tt)->last_resumed, (_now))); \
-} while(0);
+} while(0)
/** Set the last time a tracked entity started in its list of parents
*
*/
static inline CC_HINT(nonnull) void fr_time_tracking_debug(fr_time_tracking_t *tt, FILE *fp)
{
-#define DPRINT_TIME(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_unwrap(tt->_x));
-#define DPRINT(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_delta_unwrap(tt->_x));
+#define DPRINT_TIME(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_unwrap(tt->_x))
+#define DPRINT(_x) fprintf(fp, "\t" #_x " = %"PRIu64"\n", fr_time_delta_unwrap(tt->_x))
DPRINT_TIME(started);
DPRINT_TIME(ended);
if (done_config) return 0;
#define do_ldap_global_option(_option, _name, _value) \
- if (ldap_set_option(NULL, _option, _value) != LDAP_OPT_SUCCESS) { \
+ if (ldap_set_option(NULL, _option, _value) != LDAP_OPT_SUCCESS) do { \
int _ldap_errno; \
ldap_get_option(NULL, LDAP_OPT_RESULT_CODE, &_ldap_errno); \
ERROR("Failed setting global option %s: %s", _name, \
(_ldap_errno != LDAP_SUCCESS) ? ldap_err2string(_ldap_errno) : "Unknown error"); \
return -1;\
- }
+ } while (0)
#define maybe_ldap_global_option(_option, _name, _value) \
if (_value) do_ldap_global_option(_option, _name, _value)
* Set a bunch of LDAP options, using common code.
*/
#define do_ldap_option(_option, _name, _value) \
- if (ldap_set_option(c->handle, _option, _value) != LDAP_OPT_SUCCESS) { \
+ if (ldap_set_option(c->handle, _option, _value) != LDAP_OPT_SUCCESS) do { \
ldap_get_option(c->handle, LDAP_OPT_ERROR_NUMBER, &ldap_errno); \
ERROR("Failed setting connection option %s: %s", _name, \
(ldap_errno != LDAP_SUCCESS) ? ldap_err2string(ldap_errno) : "Unknown error"); \
goto error;\
- }
+ } while (0)
DIAG_OFF(unused-macros)
#define maybe_ldap_option(_option, _name, _value) \
#include <freeradius-devel/server/map.h>
#include <freeradius-devel/server/module.h>
+DIAG_OFF(extra-semi-stmt)
#include <hiredis/hiredis.h>
+DIAG_ON(extra-semi-stmt)
#ifdef __cplusplus
extern "C" {
pthread_mutex_unlock(&cluster->mutex);
hostname = inet_ntop(node_addr->inet.dst_ipaddr.af, &node_addr->inet.dst_ipaddr.addr, buffer, sizeof(buffer));
- fr_assert(hostname); /* addr.ipaddr is probably corrupt */;
+ fr_assert(hostname); /* addr.ipaddr is probably corrupt */
fr_strerror_printf("No existing node found with address %s, port %i",
hostname, node_addr->inet.dst_port);
return -1;
return 0;
}
-#define RULES_VERIFY(_cs, _rules) if (cf_tmpl_rules_verify(_cs, _rules) < 0) return NULL;
+#define RULES_VERIFY(_cs, _rules) if (cf_tmpl_rules_verify(_cs, _rules) < 0) return NULL
static ssize_t fr_skip_xlat(char const *start, char const *end);
frame->filename);
goto pop_stack;
}
- };
+ }
/*
* Read, checking for line continuations ('\\' at EOL)
* @param[in] _type of data to remove.
* @param[in] _name of data to remove.
*/
-#define cf_data_remove(_cf, _type, _name) _cf_data_remove(CF_TO_ITEM(_cf), cf_data_find(_cf, _type, _name));
+#define cf_data_remove(_cf, _type, _name) _cf_data_remove(CF_TO_ITEM(_cf), cf_data_find(_cf, _type, _name))
/** Remove an item from a parent
*
* @param[in] _cf conf section or pair to remove data from.
* @param[in] _cd conf data to remove.
*/
-#define cf_data_remove_by_data(_cf, _cd) _cf_data_remove(CF_TO_ITEM(_cf), _cd);
+#define cf_data_remove_by_data(_cf, _cd) _cf_data_remove(CF_TO_ITEM(_cf), _cd)
void *_cf_data_remove(CONF_ITEM *ci, CONF_DATA const *_cd);
#define cf_data_walk(_cf, _type, _cb, _ctx) _cf_data_walk(CF_TO_ITEM(_cf), #_type, _cb, _ctx)
break;
default:
break;
- };
+ }
log_always(log_dst, type, file, line,
"%s" /* prefix */
* Clear out the existing data
*/
fr_sbuff_shift(&sbuff, fr_sbuff_used(&m_start));
- };
+ }
}
/** Log a fatal error, then exit
* @param[in] ... Additional arguments to print.
*/
#define _RHEXDUMP_INLINE(_lvl, _data, _len, _fmt, ...) \
- if (log_rdebug_enabled(_lvl, request)) { \
+ if (log_rdebug_enabled(_lvl, request)) do { \
log_request(L_DBG, _lvl, request, __FILE__, __LINE__, _fmt " 0x%pH", ## __VA_ARGS__, fr_box_octets(_data, _len)); \
- }
+ } while (0)
#define RHEXDUMP_INLINE1(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_1, _data, _len, _fmt, ## __VA_ARGS__)
#define RHEXDUMP_INLINE2(_data, _len, _fmt, ...) _RHEXDUMP_INLINE(L_DBG_LVL_2, _data, _len, _fmt, ## __VA_ARGS__)
/** Call a named recv function directly
*/
-#define CALL_RECV(_x) recv_ ## _x(p_result, mctx, request);
+#define CALL_RECV(_x) recv_ ## _x(p_result, mctx, request)
/** Call a named send function directly
*/
return;
#undef INC_AUTH
-#define INC_AUTH(_x) radius_auth_stats._x++;request->client->auth._x++;
+#define INC_AUTH(_x) do { radius_auth_stats._x++;request->client->auth._x++; } while (0)
#undef INC_ACCT
-#define INC_ACCT(_x) radius_acct_stats._x++;request->client->acct._x++
+#define INC_ACCT(_x) do { radius_acct_stats._x++;request->client->acct._x++; } while (0)
/*
* Update the statistics.
fr_pair_t *mid_vp ## _x; \
fr_pair_t *leaf_int32_vp ## _x
-#define pair_populate(_x) \
+#define pair_populate(_x) do { \
pair_append_request(&int32_vp ## _x, fr_dict_attr_test_int32); \
pair_append_request(&string_vp ## _x, fr_dict_attr_test_string); \
pair_append_request(&group_vp ## _x, fr_dict_attr_test_group); \
pair_append_request(&top_vp ## _x, fr_dict_attr_test_nested_top_tlv); \
fr_pair_append_by_da(top_vp ## _x, &mid_vp ## _x, &top_vp ## _x->children, fr_dict_attr_test_nested_child_tlv); \
fr_pair_append_by_da(mid_vp ## _x, &leaf_string_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_string); \
- fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32);
+ fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32); \
+ } while (0)
-#define pair_populate_thin(_x) \
+#define pair_populate_thin(_x) do { \
pair_append_request(&int32_vp ## _x, fr_dict_attr_test_int32); \
pair_append_request(&group_vp ## _x, fr_dict_attr_test_group); \
pair_append_request(&top_vp ## _x, fr_dict_attr_test_nested_top_tlv); \
fr_pair_append_by_da(top_vp ## _x, &mid_vp ## _x, &top_vp ## _x->children, fr_dict_attr_test_nested_child_tlv); \
- fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32);
+ fr_pair_append_by_da(mid_vp ## _x, &leaf_int32_vp ## _x, &mid_vp ## _x->children, fr_dict_attr_test_nested_leaf_int32); \
+ } while (0)
/*
* Top level attribute names in the test dictionary all have -0 on the end
*/
#define common_vars \
tmpl_dcursor_vars_t vars; \
- request_t *request = request_fake_alloc();
+ request_t *request = request_fake_alloc()
/** Initialise a tmpl using the _attr_str string, and return the first pair
*
}
#define tmpl_setup_and_cursor_init(_vp_out, _ref) \
- if (_tmpl_setup_and_cursor_init(_vp_out, &vars, request, _ref)) return;
+ if (_tmpl_setup_and_cursor_init(_vp_out, &vars, request, _ref)) return
/** Initialise a tmpl using the _attr_str string, and return the first pair
*
}
#define tmpl_setup_and_cursor_build_init(_vp_out, _ref) \
- if (_tmpl_setup_and_cursor_build_init(_vp_out, &vars, request, _ref)) return;
+ if (_tmpl_setup_and_cursor_build_init(_vp_out, &vars, request, _ref)) return
/*
* How every test ends
if (tmpl_eval_cast_in_place(&list, vpt) < 0) {
fr_value_box_list_talloc_free(&list);
return -1;
- };
+ }
fr_value_box_list_move(out, &list);
return 0;
if (tmpl_eval_cast_in_place(&list, vpt) < 0) {
fr_value_box_list_talloc_free(&list);
return -1;
- };
+ }
fr_value_box_list_move(out, &list);
return 0;
args_error:
talloc_free(request);
return -1;
- };
+ }
if (request_data_add(request, &trigger_exec_main, REQUEST_INDEX_TRIGGER_ARGS, local_args,
false, false, false) < 0) goto args_error;
/** Remove the current request from the sent list
*
*/
-#define REQUEST_EXTRACT_SENT(_treq) fr_dlist_remove(&tconn->sent, treq);
+#define REQUEST_EXTRACT_SENT(_treq) fr_dlist_remove(&tconn->sent, treq)
/** Remove the current request from the cancel list
*
*/
-#define REQUEST_EXTRACT_CANCEL(_treq) fr_dlist_remove(&tconn->cancel, treq);
+#define REQUEST_EXTRACT_CANCEL(_treq) fr_dlist_remove(&tconn->cancel, treq)
/** Remove the current request from the cancel_partial slot
*
/** Remove the current request from the cancel sent list
*
*/
-#define REQUEST_EXTRACT_CANCEL_SENT(_treq) fr_dlist_remove(&tconn->cancel_sent, treq);
+#define REQUEST_EXTRACT_CANCEL_SENT(_treq) fr_dlist_remove(&tconn->cancel_sent, treq)
/** Reorder the connections in the active heap
*
fr_table_str_by_value(fr_trunk_states, _new, "<INVALID>")); \
CALL_WATCHERS(trunk, _new); \
trunk->pub.state = _new; \
-} while (0);
+} while (0)
static void trunk_request_enter_backlog(fr_trunk_request_t *treq, bool new);
static void trunk_request_enter_pending(fr_trunk_request_t *treq, fr_trunk_connection_t *tconn, bool new);
#define OVER_MAX_CHECK if (++count > max) return (count - 1)
-#define DEQUEUE_ALL(_src_list, _state) \
+#define DEQUEUE_ALL(_src_list, _state) do { \
while ((treq = fr_dlist_head(_src_list))) { \
OVER_MAX_CHECK; \
fr_assert(treq->pub.state == (_state)); \
trunk_request_enter_unassigned(treq); \
fr_dlist_insert_tail(out, treq); \
- }
+ } } while (0)
/*
* Don't need to do anything with
count += fr_trunk_request_count_by_connection(tconn, req_state); \
} \
} \
-} while (0);
+} while (0)
if (conn_state & FR_TRUNK_CONN_ACTIVE) {
for (tconn = fr_minmax_heap_iter_init(trunk->active, &iter);
fr_connection_signal_reconnect(((fr_trunk_connection_t *)fr_dlist_tail(&trunk->_list))->pub.conn, reason); \
} \
} \
-} while (0);
+} while (0)
/*
* Connections in the 'connecting' state
"CONSISTENCY_CHECK_FAILED %s[%i}: trunk request-trunk mismatch", file, line); \
fr_fatal_assert_msg(_state == _treq->pub.state, \
"CONSISTENCY_CHECK_FAILED %s[%i}: trunk request-state mismatch", file, line); \
-} while (0);
+} while (0)
#define TREQ_DLIST_VERIFY(_dlist, _state) \
do { \
fr_trunk_request_verify(file, line, treq); \
TCONN_TREQ_CHECKS(treq, _state); \
} \
-} while (0);
+} while (0)
#define TREQ_HEAP_VERIFY(_heap, _state) \
do { \
fr_trunk_request_verify(file, line, treq); \
TCONN_TREQ_CHECKS(treq, _state); \
} \
-} while (0);
+} while (0)
#define TREQ_OPTION_VERIFY(_option, _state) \
do { \
fr_trunk_request_verify(file, line, tconn->_option); \
TCONN_TREQ_CHECKS(tconn->_option, _state); \
} \
-} while (0);
+} while (0)
/* verify associated requests */
TREQ_HEAP_VERIFY(pending, FR_TRUNK_REQUEST_STATE_PENDING);
return true; \
} \
} \
-} while (0);
+} while (0)
#define TREQ_HEAP_SEARCH(_heap) \
do { \
return true; \
} \
} \
-} while (0);
+} while (0)
#define TREQ_OPTION_SEARCH(_option) \
do { \
return true; \
} \
} \
-} while (0);
+} while (0)
/* search associated requests */
TREQ_HEAP_SEARCH(pending);
*
* @param[in] ssl session containing the request pointer.
*/
-#define fr_tls_session_request_unbind(_ssl) _fr_tls_session_request_unbind(__FILE__, __LINE__, _ssl);
+#define fr_tls_session_request_unbind(_ssl) _fr_tls_session_request_unbind(__FILE__, __LINE__, _ssl)
/** Add extra pairs to the temporary subrequests
*
#if 0
#define ATTR_RULES_VERIFY(_rules) if (unlang_attr_rules_verify(_rules) < 0) return NULL;
#endif
-#define RULES_VERIFY(_rules) if (unlang_rules_verify(_rules) < 0) return NULL;
+#define RULES_VERIFY(_rules) do { if (unlang_rules_verify(_rules) < 0) return NULL; } while (0)
static bool pass2_fixup_tmpl(TALLOC_CTX *ctx, tmpl_t **vpt_p, CONF_ITEM const *ci, fr_dict_t const *dict)
{
*/
if (tmpl_cast_set(map->rhs, tmpl_attr_tail_da(map->lhs)->type) < 0) {
cf_log_perr(map->ci, "Failed setting rhs type");
- };
+ }
if (map->op != T_OP_CMP_EQ) {
cf_log_err(map->ci, "Must use '==' for comparisons with virtual attribute %s", map->lhs->name);
fr_assert_msg(method_env->inst_size, "Method environment for module %s, method %s %s declared, "
"but no inst_size set",
inst->module->name, unlang_ctx->section_name1, unlang_ctx->section_name2);
- };
+ }
/*
* If a module reference is a section, then the section
size_t len;
#define UNWIND_FLAG_DUMP(attrib) \
- if (unwind & attrib) strcat(buf, #attrib" ");
+ if (unwind & attrib) strcat(buf, #attrib" ")
snprintf(buf, sizeof(buf), "unwind=0x%x (", unwind);
error:
talloc_free(vb);
return XLAT_ACTION_FAIL;
- };
+ }
goto finish;
}
break;
}
- };
+ }
return list_mod_apply(p_result, request);
}
if (!state) {
*p_result = RLM_MODULE_FAIL;
return UNLANG_ACTION_CALCULATE_RESULT;
- };
+ }
(void) talloc_set_type(state, unlang_parallel_state_t);
state->result = RLM_MODULE_FAIL;
do { \
*(_a) = fr_value_box_list_head(_list); \
XLAT_ARGS_NEXT(_list, _a, _b); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_3(_list, _a, _b, _c) \
do { \
*(_a) = fr_value_box_list_head(_list); \
XLAT_ARGS_NEXT(_list, _a, _b); \
XLAT_ARGS_NEXT(_list, _b, _c); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_4(_list, _a, _b, _c, _d) \
do { \
XLAT_ARGS_NEXT(_list, _a, _b); \
XLAT_ARGS_NEXT(_list, _b, _c); \
XLAT_ARGS_NEXT(_list, _c, _d); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_5(_list, _a, _b, _c, _d, _e) \
do { \
XLAT_ARGS_NEXT(_list, _b, _c); \
XLAT_ARGS_NEXT(_list, _c, _d); \
XLAT_ARGS_NEXT(_list, _d, _e); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_6(_list, _a, _b, _c, _d, _e, _f) \
do { \
XLAT_ARGS_NEXT(_list, _c, _d); \
XLAT_ARGS_NEXT(_list, _d, _e); \
XLAT_ARGS_NEXT(_list, _e, _f); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_7(_list, _a, _b, _c, _d, _e, _f, _g) \
do { \
XLAT_ARGS_NEXT(_list, _d, _e); \
XLAT_ARGS_NEXT(_list, _e, _f); \
XLAT_ARGS_NEXT(_list, _f, _g); \
- } while (0);
+ } while (0)
#define XLAT_ARGS_8(_list, _a, _b, _c, _d, _e, _f, _g, _h) \
do { \
XLAT_ARGS_NEXT(_list, _e, _f); \
XLAT_ARGS_NEXT(_list, _f, _g); \
XLAT_ARGS_NEXT(_list, _g, _h); \
- } while (0);
+ } while (0)
/** Trampoline macro for selecting which ``XLAT_ARGS_<num>`` macro to expand
*
if (!fr_type_is_leaf(*cast)) {
fr_strerror_printf("Invalid data type '%s' in cast", fr_type_to_str(*cast));
- FR_SBUFF_ERROR_RETURN(&our_in)
+ FR_SBUFF_ERROR_RETURN(&our_in);
}
if (!fr_sbuff_next_if_char(&our_in, close)) {
fr_strerror_const("Unterminated cast");
- FR_SBUFF_ERROR_RETURN(&our_in)
+ FR_SBUFF_ERROR_RETURN(&our_in);
}
fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, NULL);
* @param[in] _uctx data to be passed to free function.
*/
#define fr_atexit_global_once_ret(_ret, _init, _free, _uctx) \
-{ \
+do { \
static atomic_bool _init_done = false; \
static pthread_mutex_t _init_mutex = PTHREAD_MUTEX_INITIALIZER; \
void *_our_uctx = _uctx; /* stop _uctx being evaluated multiple times, it may be a call to malloc() */ \
} \
pthread_mutex_unlock(&_init_mutex); \
} \
-}
+} while (0)
/** Setup pair of global init/free functions
*
void *_our_uctx = _uctx; /* stop _uctx being evaluated multiple times, it may be a call to malloc() */ \
_fr_atexit_thread_local(__FILE__, __LINE__, _free, _our_uctx); \
_name = _our_uctx; \
-} while (0);
+} while (0)
int _fr_atexit_thread_local(char const *file, int line,
fr_atexit_t func, void const *uctx);
FR_DBUFF_IN_BYTES_RETURN(&our_out, (alphabet[us(p[0])] << 4) | alphabet[us(p[1])]);
fr_sbuff_advance(&our_in, 2);
- };
+ }
if (err) *err = FR_SBUFF_PARSE_OK;
#include <freeradius-devel/util/syserror.h>
#if defined(STATIC_ANALYZER) || !defined(NDEBUG)
-# define CHECK_DBUFF_INIT(_sbuff) if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return 0;
+# define CHECK_DBUFF_INIT(_sbuff) do { if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return 0; } while (0)
#else
# define CHECK_DBUFF_INIT(_sbuff)
#endif
* @param[in] _max Maximum size of the dbuff buffer.
*/
#define FR_DBUFF_TALLOC_THREAD_LOCAL(_out, _init, _max) \
-{ \
+do { \
static _Thread_local fr_dbuff_thread_local_t *_dbuff_t_local; \
if (!_dbuff_t_local) { \
fr_dbuff_thread_local_t *dbtl = talloc_zero(NULL, fr_dbuff_thread_local_t); \
fr_dbuff_reset_talloc(&_dbuff_t_local->dbuff); \
*(_out) = &_dbuff_t_local->dbuff; \
} \
-}
+} while (0)
/** @} */
/** @name Extension requests
} fr_dcursor_stack_t;
#ifndef TALLOC_GET_TYPE_ABORT_NOOP
-#define VALIDATE(_item) if (cursor->dlist->type && (_item)) _talloc_get_type_abort(_item, cursor->dlist->type, __location__);
+#define VALIDATE(_item) do { if (cursor->dlist->type && (_item)) _talloc_get_type_abort(_item, cursor->dlist->type, __location__); } while (0)
#else
#define VALIDATE(_item)
#endif
fprintf(stderr, "Stacktrace for: %p\n", p->obj);
backtrace_symbols_fd(p->frames, p->count, STDERR_FILENO);
}
- };
+ }
if (!found) {
fprintf(stderr, "No backtrace available for %p", obj);
}
}
break;
- };
+ }
DA_VERIFY(n);
*
*/
#define CHECK_ELEMENT_COUNT(_head, _add) \
- if (unlikely((_head)->num_elements > (UINT_MAX - (_add)))) { \
+ if (unlikely((_head)->num_elements > (UINT_MAX - (_add)))) do { \
fr_strerror_const("Maximum elements in list"); \
return -1; \
- }
+ } while (0)
/** Check if a list entry is part of a list
*
* talloc_free(el). That should be somewhat
* faster than doing it incrementally.
*/
- };
+ }
talloc_free(el);
}
#define HEAP_PARENT(_x) ((_x) >> 1)
#define HEAP_LEFT(_x) (2 * (_x))
#define HEAP_RIGHT(_x) (2 * (_x) + 1 )
-#define HEAP_SWAP(_a, _b) { void *_tmp = _a; _a = _b; _b = _tmp; }
+#define HEAP_SWAP(_a, _b) do { void *_tmp = _a; _a = _b; _b = _tmp; } while (0)
static void fr_heap_bubble(fr_heap_t *h, fr_heap_index_t child);
*((fr_heap_index_t *)(((uint8_t *)data) + h->offset)) = idx;
}
-#define OFFSET_SET(_heap, _idx) index_set(_heap, _heap->p[_idx], _idx);
-#define OFFSET_RESET(_heap, _idx) index_set(_heap, _heap->p[_idx], 0);
+#define OFFSET_SET(_heap, _idx) index_set(_heap, _heap->p[_idx], _idx)
+#define OFFSET_RESET(_heap, _idx) index_set(_heap, _heap->p[_idx], 0)
static inline CC_HINT(always_inline)
int realloc_heap(fr_heap_t **hp, unsigned int n_size)
#define ind(mm,x) ((mm)[(x >> 2) &(RANDSIZ-1)])
#define rngstep(mix, a, b, mm, m, m2, r, x) \
-{ \
+do { \
x = *m; \
a = ((a^(mix)) + *(m2++)) & 0xffffffff; \
*(m++) = y = (ind(mm, x) + a + b) & 0xffffffff; \
*(r++) = b = (ind(mm, y >> RANDSIZL) + x) & 0xffffffff; \
-}
+} while (0)
void fr_isaac(fr_randctx *ctx)
{
#define mix(a,b,c,d,e,f,g,h) \
-{ \
+do { \
a ^= b << 11; d += a; b += c; \
b ^= c >> 2; e += b; c += d; \
c ^= d << 8; f += c; d += e; \
f ^= g >> 4; a += f; g += h; \
g ^= h << 8; b += g; h += a; \
h ^= a >> 9; c += h; a += b; \
-}
+} while (0)
/* if (flag==1), then use the contents of randrsl[] to initialize mm[]. */
void fr_rand_init(fr_randctx *ctx, int flag)
* Clear out the existing data
*/
fr_sbuff_shift(&sbuff, fr_sbuff_used(&m_start));
- };
+ }
}
/** Maps log categories to message prefixes
#ifndef TALLOC_GET_TYPE_ABORT_NOOP
void fr_lst_verify(char const *file, int line, fr_lst_t const *lst);
-#define FR_LST_VERIFY(_lst) fr_lst_verify(__FILE__, __LINE__, _lst);
+#define FR_LST_VERIFY(_lst) fr_lst_verify(__FILE__, __LINE__, _lst)
#elif !defined(NDEBUG)
#define FR_LST_VERIFY(_lst) fr_assert(_lst)
#else
#define HEAP_GRANDPARENT(_x) HEAP_PARENT(HEAP_PARENT(_x))
#define HEAP_LEFT(_x) (2 * (_x))
#define HEAP_RIGHT(_x) (2 * (_x) + 1 )
-#define HEAP_SWAP(_a, _b) { void *_tmp = _a; _a = _b; _b = _tmp; }
+#define HEAP_SWAP(_a, _b) do { void *_tmp = _a; _a = _b; _b = _tmp; } while (0)
/**
* @hidecallergraph
return HEAP_LEFT(HEAP_LEFT(i)) <= h->num_elements;
}
-#define OFFSET_SET(_heap, _idx) index_set(_heap, _heap->p[_idx], _idx);
-#define OFFSET_RESET(_heap, _idx) index_set(_heap, _heap->p[_idx], 0);
+#define OFFSET_SET(_heap, _idx) index_set(_heap, _heap->p[_idx], _idx)
+#define OFFSET_RESET(_heap, _idx) index_set(_heap, _heap->p[_idx], 0)
/*
* The minmax heap has the same basic idea as binary heaps:
void fr_pair_fprint(FILE *, fr_pair_t const *vp) CC_HINT(nonnull);
-#define fr_pair_list_log(_log, _lvl, _list) _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__);
+#define fr_pair_list_log(_log, _lvl, _list) _fr_pair_list_log(_log, _lvl, NULL, _list, __FILE__, __LINE__)
void _fr_pair_list_log(fr_log_t const *log, int lvl, fr_pair_t *parent,
fr_pair_list_t const *list, char const *file, int line) CC_HINT(nonnull(1,4));
* yeah yeah not perfect distribution
* but close enough.
*/
-#define fill(_expr) \
+#define fill(_expr) do { \
while (p < end) { \
if ((mod = ((p - out) & (sizeof(word) - 1))) == 0) word = fr_rand(); \
byte = ((uint8_t *)&word)[mod]; \
*p++ = (_expr); \
-}
+} } while (0)
switch (class) {
/*
* Lowercase letters
*/
case 'c':
- fill('a' + (byte % 26))
+ fill('a' + (byte % 26));
return;
/*
* Uppercase letters
*/
case 'C':
- fill('A' + (byte % 26))
+ fill('A' + (byte % 26));
return;
/*
*/
case 'b':
default:
- fill(byte)
+ fill(byte);
return;
}
}
size_t sbuff_parse_error_table_len = NUM_ELEMENTS(sbuff_parse_error_table);
#if defined(STATIC_ANALYZER) || !defined(NDEBUG)
-# define CHECK_SBUFF_INIT(_sbuff) if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return 0;
+# define CHECK_SBUFF_INIT(_sbuff) do { if (!(_sbuff)->extend && (unlikely(!(_sbuff)->buff) || unlikely(!(_sbuff)->start) || unlikely(!(_sbuff)->end) || unlikely(!(_sbuff)->p))) return 0; } while (0)
#else
# define CHECK_SBUFF_INIT(_sbuff)
#endif
FILL_OR_GOTO_DONE(out, &our_in, p - our_in.p);
if (p != end) break; /* stopped early, break */
- };
+ }
done:
*out->p = '\0';
FILL_OR_GOTO_DONE(out, &our_in, p - our_in.p);
if (p != end) break; /* stopped early, break */
- };
+ }
done:
*out->p = '\0';
next:
if (tt && fr_sbuff_terminal_search(in, fr_sbuff_current(&our_in), idx, tt, needle_len)) break;
fr_sbuff_advance(&our_in, 1);
- };
+ }
/*
* Copy any remaining data over
total += fr_sbuff_set(sbuff, p);
if (p != end) break; /* stopped early, break */
- };
+ }
return total;
}
* @param[in] _max Maximum size of the sbuff buffer.
*/
#define FR_SBUFF_TALLOC_THREAD_LOCAL(_out, _init, _max) \
-{ \
+do { \
static _Thread_local fr_sbuff_thread_local_t *_sbuff_t_local; \
if (!_sbuff_t_local) { \
fr_sbuff_thread_local_t *sbtl = talloc_zero(NULL, fr_sbuff_thread_local_t); \
fr_sbuff_reset_talloc(&_sbuff_t_local->sbuff); \
*(_out) = &_sbuff_t_local->sbuff; \
} \
-}
+} while (0)
void fr_sbuff_update(fr_sbuff_t *sbuff, char *new_buff, size_t new_len);
* An error at offset 0 will be returned as -1.
*/
#define fr_sbuff_error(_sbuff_or_marker) \
- _fr_sbuff_error(fr_sbuff_ptr(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker));
+ _fr_sbuff_error(fr_sbuff_ptr(_sbuff_or_marker), fr_sbuff_current(_sbuff_or_marker))
/** Like fr_sbuff_used, but adjusts for the value returned for the amount shifted
*
^block->l[(i+2)&15]^block->l[i&15],1))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-# define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
-# define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
-# define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
-# define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
-# define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+# define R0(v,w,x,y,z,i) do { z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); } while (0)
+# define R1(v,w,x,y,z,i) do { z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); } while (0)
+# define R2(v,w,x,y,z,i) do { z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); } while (0)
+# define R3(v,w,x,y,z,i) do { z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); } while (0)
+# define R4(v,w,x,y,z,i) do { z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); } while (0)
/* Hash a single 512-bit block. This is the core of the algorithm. */
#ifdef WITH_TRIE_VERIFY
static int trie_verify(fr_trie_t *trie);
//#define VERIFY(_x) fr_cond_assert(trie_verify((fr_trie_t *) _x) == 0)
-#define VERIFY(_x) do { if (trie_verify((fr_trie_t *) _x) < 0) { fprintf(stderr, "FAIL VERIFY at %d - %s\n", __LINE__, fr_strerror()); fr_cond_assert(0);} } while (0)
+#define VERIFY(_x) if (trie_verify((fr_trie_t *) _x) < 0) do { fprintf(stderr, "FAIL VERIFY at %d - %s\n", __LINE__, fr_strerror()); fr_cond_assert(0); } while (0)
#else
#define VERIFY(_x)
#endif
* Short-hand for simplicity.
*/
#define RETURN(_type) return CMP(a->datum._type, b->datum._type)
-#define COMPARE(_type) return CMP(memcmp(&a->datum._type, &b->datum._type, sizeof(a->datum._type)), 0);
+#define COMPARE(_type) return CMP(memcmp(&a->datum._type, &b->datum._type, sizeof(a->datum._type)), 0)
case FR_TYPE_BOOL:
RETURN(boolean);
error:
talloc_free(local);
return -1;
- };
+ }
fr_pair_list_append_by_da(local, vp, &pairs, attr_packet_type, (uint32_t)FR_LDAP_SYNC_CODE_COOKIE_STORE, true);
if (!vp) goto error;
if (msg) ldap_msgfree(msg);
talloc_free(sync_packet_ctx);
return -1;
- };
+ }
pcode = sync_packet_code_table[op];
values[i]->bv_len, NULL, true) < 0) {
fr_pair_remove(pairs, vp);
talloc_free(vp);
- };
+ }
/* Only += operator adds multiple values */
if (map->op != T_OP_ADD_EQ) break;
default:
fr_assert(0);
return -1;
- };
+ }
return 0;
}
}
#undef READFILE
-#define READFILE(_x, _y, _d) do { if (getusersfile(inst, inst->_x, &inst->_y, &inst->_d, inst->key_data_type) != 0) { ERROR("Failed reading %s", inst->_x); return -1;} } while (0)
+#define READFILE(_x, _y, _d) if (getusersfile(inst, inst->_x, &inst->_y, &inst->_d, inst->key_data_type) != 0) do { ERROR("Failed reading %s", inst->_x); return -1;} while (0)
READFILE(filename, common, common_def);
READFILE(usersfile, users, users_def);
}
#define REPEAT_LDAP_MEMBEROF_XLAT_RESULTS \
- if (unlang_function_repeat_set(request, ldap_memberof_xlat_results) < 0) { \
+ if (unlang_function_repeat_set(request, ldap_memberof_xlat_results) < 0) do { \
rcode = RLM_MODULE_FAIL; \
goto finish; \
- }
+ } while (0)
/** Run the state machine for the LDAP membership xlat
*
}
#define REPEAT_MOD_AUTHORIZE_RESUME \
- if (unlang_function_repeat_set(request, mod_authorize_resume) < 0) { \
+ if (unlang_function_repeat_set(request, mod_authorize_resume) < 0) do { \
rcode = RLM_MODULE_FAIL; \
goto finish; \
- }
+ } while (0)
/** Resume function called after each potential yield in LDAP authorization
*
* Retrieve Universal Password if we use eDirectory
*/
if (inst->edir) {
- autz_ctx->dn = rlm_find_user_dn_cached(request);;
+ autz_ctx->dn = rlm_find_user_dn_cached(request);
/*
* Retrive universal password
* Fall back to lease_time otherwise.
*/
lease_time = (env->offer_time.type == FR_TYPE_UINT32) ?
- env->offer_time.vb_uint32 : env->lease_time.vb_uint32;;
+ env->offer_time.vb_uint32 : env->lease_time.vb_uint32;
ippool_action_print(request, POOL_ACTION_ALLOCATE, L_DBG_LVL_2, &env->pool_name, NULL,
&env->owner, &env->gateway_id, lease_time);
switch (redis_ippool_allocate(inst, request, env, lease_time)) {
p->name = optarg; \
p++; \
need_pool = true; \
-} while (0);
+} while (0)
while ((c = getopt(argc, argv, "a:d:r:s:Sm:A:U:O:p:ilLhxo:f:")) != -1) switch (c) {
case 'a':
if (alloc > limit) break;
MEM(buff = talloc_realloc(NULL, buff, char, alloc));
- };
+ }
talloc_free(buff);
default:
fr_assert(0);
break;
- };
+ }
/*
* Set user based authentication parameters
default:
fr_assert(0);
- };
+ }
/*
* Setup encoder specific options
PERROR("Failed creating directory for SQLite database");
return -1;
- };
+ }
status = sqlite3_open_v2(inst->filename, &db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (!db) {
len = fr_dhcpv4_encode_option(&work_dbuff,
&cursor, &(fr_dhcpv4_ctx_t){ .root = fr_dict_root(dict_dhcpv4) });
if (len <= 0) break;
- };
+ }
FR_DBUFF_IN_BYTES_RETURN(&work_dbuff, FR_END_OF_OPTIONS, 0x00);
raw:
return fr_pair_raw_from_network(ctx, out, parent, data, data_len);
- };
+ }
/*
* Structs used fixed length IPv6 addressews.
raw:
return fr_pair_raw_from_network(ctx, out, parent, data, data_len);
- };
+ }
/*
* Structs used fixed length fields
int fr_radius_packet_send(fr_radius_packet_t *packet, fr_pair_list_t *list,
fr_radius_packet_t const *original, char const *secret) CC_HINT(nonnull (1,2,4));
-#define fr_radius_packet_log_hex(_log, _packet) _fr_radius_packet_log_hex(_log, _packet, __FILE__, __LINE__);
+#define fr_radius_packet_log_hex(_log, _packet) _fr_radius_packet_log_hex(_log, _packet, __FILE__, __LINE__)
void _fr_radius_packet_log_hex(fr_log_t const *log, fr_radius_packet_t const *packet, char const *file, int line) CC_HINT(nonnull);
typedef struct {
int fr_tacacs_body_xor(fr_tacacs_packet_t const *pkt, uint8_t *body, size_t body_len, char const *secret, size_t secret_len) CC_HINT(nonnull(1,2,4));
-#define fr_tacacs_packet_log_hex(_log, _packet, _size) _fr_tacacs_packet_log_hex(_log, _packet, _size, __FILE__, __LINE__);
+#define fr_tacacs_packet_log_hex(_log, _packet, _size) _fr_tacacs_packet_log_hex(_log, _packet, _size, __FILE__, __LINE__)
void _fr_tacacs_packet_log_hex(fr_log_t const *log, fr_tacacs_packet_t const *packet, size_t packet_len, char const *file, int line) CC_HINT(nonnull);