Skip to content
Permalink
Browse files

different way of hacking const issues

in non-debug bilds, talloc_get_type_abort() is just a cast.
but if the variable is 'const', it's talloc_type is the *non-const*
version.  So we can't just add 'const' to the arguments to
talloc_get_type_abort().  That way the debug builds would fail...

the solution seems to be jist removing the calls entirely in
non-debug builds.
  • Loading branch information...
alandekok committed Sep 7, 2017
1 parent cf2419a commit 3e9071505be623bd0ebb80d783a0e0ea4799d6cc
Showing with 10 additions and 6 deletions.
  1. +6 −6 src/lib/util/dict.c
  2. +4 −0 src/lib/util/pair.c
@@ -4316,16 +4316,16 @@ void fr_dict_verify(char const *file, int line, fr_dict_attr_t const *da)
{
int i;
fr_dict_attr_t const *da_p;
fr_dict_attr_t *tmp;

if (!da) {
FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: fr_dict_attr_t pointer was NULL", file, line);

if (!fr_cond_assert(0)) fr_exit_now(1);
}

memcpy(&tmp, &da, sizeof(da));
(void) talloc_get_type_abort(tmp, fr_dict_attr_t);
#ifndef NDEBUG
(void) talloc_get_type_abort(da, fr_dict_attr_t);
#endif

if ((!da->flags.is_root) && (da->depth == 0)) {
FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: fr_dict_attr_t %s vendor: %i, attr %i: "
@@ -4343,11 +4343,11 @@ void fr_dict_verify(char const *file, int line, fr_dict_attr_t const *da)
if (!fr_cond_assert(0)) fr_exit_now(1);
}

#ifndef NDEBUG
for (da_p = da; da_p; da_p = da_p->next) {
memcpy(&tmp, &da_p, sizeof(da_p));

(void) talloc_get_type_abort(tmp, fr_dict_attr_t);
(void) talloc_get_type_abort(da_p, fr_dict_attr_t);
}
#endif

for (i = da->depth, da_p = da; (i >= 0) && da; i--, da_p = da_p->parent) {
if (i != (int)da_p->depth) {
@@ -2650,7 +2650,9 @@ inline void fr_pair_verify(char const *file, int line, VALUE_PAIR const *vp)
if (!fr_cond_assert(0)) fr_exit_now(1);
}

#ifndef NDEBUG
(void) talloc_get_type_abort(vp, VALUE_PAIR);
#endif

if (!vp->da) {
FR_FAULT_LOG("CONSISTENCY CHECK FAILED %s[%u]: VALUE_PAIR da pointer was NULL", file, line);
@@ -2763,7 +2765,9 @@ inline void fr_pair_verify(char const *file, int line, VALUE_PAIR const *vp)
}

if (vp->da->flags.is_unknown) {
#ifndef NDEBUG
(void) talloc_get_type_abort(vp->da, fr_dict_attr_t);
#endif
} else {
fr_dict_attr_t const *da;

0 comments on commit 3e90715

Please sign in to comment.
You can’t perform that action at this time.