]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
hoist static analysis checks to before when they're used
authorAlan T. DeKok <aland@freeradius.org>
Thu, 14 Jul 2022 23:58:39 +0000 (19:58 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Jul 2022 23:59:02 +0000 (19:59 -0400)
src/lib/util/dict_unknown.c
src/lib/util/machine.c

index 540fb1a528a0f1fdc3f6aa164609099509ac7995..6756802a63163d83c9985205678d601a970c18d7 100644 (file)
@@ -46,6 +46,10 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
                return NULL;
        }
 
+#ifdef STATIC_ANALYZER
+       if (!unknown->name || !unknown->parent) return NULL;
+#endif
+
        da = fr_dict_attr_by_name(NULL, unknown->parent, unknown->name);
        if (da) {
                if (da->attr == unknown->attr) return da;
@@ -65,9 +69,6 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
                        return NULL;
                }
        } else {
-#ifdef STATIC_ANALYZER
-               if (!unknown->parent) return NULL;
-#endif
                parent = unknown->parent;
        }
 
@@ -124,10 +125,6 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
                return n;
        }
 
-#ifdef STATIC_ANALYZER
-       if (!unknown->name) return NULL;
-#endif
-
        /*
         *      Add the attribute by both name and number.
         *
index 72d4a0b98ca3a98fa0796aa009ba038758f7b55e..e939d752825f97c95da21961d9e3a43dbf2aaefd 100644 (file)
@@ -216,6 +216,13 @@ fr_machine_t *fr_machine_alloc(TALLOC_CTX *ctx, fr_machine_def_t const *def, voi
         */
        m->current = &m->state[def->init];
 
+#ifdef STATIC_ANALYZER
+       if (!m->current || !m->current->def || !m->current->def->process) {
+               talloc_free(m);
+               return NULL;
+       }
+#endif
+
        /*
         *      We don't transition into the "init" state, as there is
         *      no previous state.  We just run the "process"
@@ -234,13 +241,6 @@ fr_machine_t *fr_machine_alloc(TALLOC_CTX *ctx, fr_machine_def_t const *def, voi
        fr_assert(!m->current->def->exit);
        fr_assert(m->current->def->process);
 
-#ifdef STATIC_ANALYZER
-       if (!m->current || !m->current->def || !m->current->def->process) {
-               talloc_free(m);
-               return NULL;
-       }
-#endif
-
        next = m->current->def->process(m, uctx);
        fr_assert(next >= 0);