#endif
/*
- * Reduce spurious errors from clang scan by having
+ * Static analyzers don't notice or can't infer some properties
+ * of the code, and hence may give false positives. To deal with
+ * them, there is some conditionally compiled code in various
+ * places. The following lets the code change minimally if and
+ * when new static analyzers are added.
+ */
+#ifdef __clang_analyzer__
+#define STATIC_ANALYZER 1
+#endif
+#ifdef __COVERITY__
+#define STATIC_ANALYZER 1
+#endif
+
+/*
+ * Reduce spurious errors from static analyzers by having
* all paths that find the da to be NULL, result
* in program exit.
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
# define WITH_VERIFY_PTR 1
#endif
return -1;
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!parent->parent) return -1; /* stupid static analyzers */
#endif
fr_assert(parent->parent);
return 0;
}
-#ifdef __clang_analyzer__
- saremote.ss_family = AF_INET; /* clang doesn't know that accept() initializes this */
+#ifdef STATIC_ANALYZER
+ saremote.ss_family = AF_INET; /* static analyzer doesn't know that accept() initializes this */
#endif
/*
#endif
if (!request->async) {
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!request->parent) RETURN_MODULE_FAIL;
#endif
fr_assert(request->parent != NULL);
* This happens, as dl_inst is is used in
* as the loop condition above.
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!fr_cond_assert(a->dl_inst)) return +1;
if (!fr_cond_assert(b->dl_inst)) return -1;
#endif
switch (check_item->op) {
case T_OP_EQ:
default:
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!check_item->da) return -1;
#endif
return new;
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
/*
- * clang isn't smart enough to notice that "normify" clears out n1.
+ * static analyzer isn't smart enough to notice that "normify" clears out n1.
*/
memset(n1, 0, sizeof(n1));
#endif
#ifdef NDEBUG
# define fr_assert(_expr)
-#elif !defined(__clang_analyzer__)
+#elif !defined(STATIC_ANALYZER)
# define fr_assert(_expr) ((void) ((_expr) ? (void) 0 : (void) fr_assert_exit(__FILE__, __LINE__, #_expr)))
#else
# include <assert.h>
case SSL_TICKET_FATAL_ERR_MALLOC:
case SSL_TICKET_FATAL_ERR_OTHER:
case SSL_TICKET_NONE:
-#if defined(__clang_analyzer__) || defined(__COVERITY__)
+#ifdef STATIC_ANALYZER
default:
#endif
return SSL_TICKET_RETURN_IGNORE_RENEW; /* Send a new ticket */
}
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
/*
* Container can never be NULL, because if container
* was previously NULL, i will be <= depth.
fr_assert(state->lhs.vp != NULL);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!state->lhs.vp) return -1;
#endif
goto check_rhs;
case UNLANG_EDIT_EXPANDED_RHS:
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!state->lhs.vp) goto error;
#endif
unlang_frame_state_redundant_t *redundant = talloc_get_type_abort(frame->state, unlang_frame_state_redundant_t);
unlang_group_t *g = unlang_generic_to_group(frame->instruction);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!redundant->found) {
*p_result = RLM_MODULE_FAIL;
return UNLANG_ACTION_CALCULATE_RESULT;
a = fr_dlist_head(in);
b = fr_dlist_next(in, a);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!a || !b) return XLAT_ACTION_FAIL;
#else
fr_assert(a != NULL);
}
redo:
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!lhs) return 0; /* shut up stupid analyzer */
#else
fr_assert(lhs != NULL);
talloc_free(lhs);
FR_SBUFF_ERROR_RETURN_ADJ(&our_in, slen);
}
-
-#ifdef __clang_analyzer__
+
+#ifdef STATIC_ANALYZER
if (!rhs) {
talloc_free(lhs);
FR_SBUFF_ERROR_RETURN(&our_in);
xlat_exp_set_type(node, XLAT_ONE_LETTER);
xlat_exp_set_name_buffer_shallow(node, str);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!node->fmt) goto error;
#endif
#include <freeradius-devel/util/dbuff.h>
#include <freeradius-devel/util/syserror.h>
-#if defined(__clang_analyzer__) || !defined(NDEBUG)
+#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;
#else
# define CHECK_DBUFF_INIT(_sbuff)
# define fr_assert(_x)
# define fr_assert_msg(_x, _msg, ...)
# define fr_assert_fail(_msg, ...)
-#elif !defined(__clang_analyzer__)
+#elif !defined(STATIC_ANALYZER)
/** Calls panic_action ifndef NDEBUG, else logs error
*
* @param[in] _x expression to test (should evaluate to true)
fr_dict_attr_t *unknown;
fr_dict_attr_t const *child;
-#if defined(__clang_analyzer__) || !defined(NDEBUG)
+#if defined(STATIC_ANALYZER) || !defined(NDEBUG)
if (!parent->parent) return -1; /* stupid static analyzers */
#endif
}
#endif
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!ctx->dict) return -1;
#endif
* Maybe we do want a flag field for named time deltas?
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!ctx->dict) return -1;
#endif
if (!dict_attr_flags_valid(ctx->dict, ctx->stack[ctx->stack_depth].da, argv[2], NULL, type, &flags)) return -1;
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!ctx->dict) return -1;
#endif
*/
dict = dict_by_protocol_name(argv[0]);
if (dict) {
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!dict->root) return -1;
#endif
}
} else if ((dict = dict_by_protocol_num(value)) != NULL) {
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!dict->root || !dict->root->name || !argv[0]) return -1;
#endif
return NULL;
}
} else {
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!unknown->parent) return NULL;
#endif
parent = unknown->parent;
return n;
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!unknown->name) return NULL;
#endif
}
}
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!dict->root) return -1;
#endif
if (!a->symbol && !b->symbol) return 0;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!fr_cond_assert(a->symbol && b->symbol)) return 0; /* Bug in clang scan ? */
#endif
if (!a->symbol && !b->symbol) return 0;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!fr_cond_assert(a->symbol && b->symbol)) return 0; /* Bug in clang scan ? */
#endif
/*
* Catch Linux weirdness.
*
- * You'd think this'd be enough to quite clang scan,
+ * You'd think this'd be enough to quiet clang scan,
* but it's not.
*/
if (unlikely((tsibs == 0) || (lcores == 0) || (lcores > tsibs))) return 1;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
/*
- * Prevent clang scanner from warning about divide by zero
+ * Prevent static analyzer from warning about divide by zero
*/
if ((tsibs / lcores) == 0) return 1;
#endif
fr_assert(!m->current->def->exit);
fr_assert(m->current->def->process);
-#if defined(__clang_analyzer__)
+#ifdef STATIC_ANALYZER
if (!m->current || !m->current->def || !m->current->def->process) {
talloc_free(m);
return NULL;
*/
static inline bool is_whitespace(char const *value)
{
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (*value == '\0') return false; /* clang analyzer doesn't seem to know what isspace does */
#endif
do {
*/
static inline bool is_integer(char const *value)
{
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (*value == '\0') return false; /* clang analyzer doesn't seem to know what isdigit does */
#endif
do {
fr_pair_aprint(ctx, &value, NULL, list);
fr_pair_aprint(ctx, &str, NULL, filter);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!value || !str) return;
#endif
};
size_t sbuff_parse_error_table_len = NUM_ELEMENTS(sbuff_parse_error_table);
-#if defined(__clang_analyzer__) || !defined(NDEBUG)
+#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;
#else
# define CHECK_SBUFF_INIT(_sbuff)
state[3] += d;
state[4] += e;
-# ifndef __clang_analyzer__
+# ifndef STATIC_ANALYZER
/* Wipe variables */
a = b = c = d = e = 0;
# endif
digest[i] = (uint8_t)((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
-# ifndef __clang_analyzer__
+# ifndef STATIC_ANALYZER
/* Wipe variables */
i = j = 0;
memset(context->buffer, 0, 64);
digest[i] = (uint8_t)((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
-# ifndef __clang_analyzer__
+# ifndef STATIC_ANALYZER
/* Wipe variables */
i = j = 0;
memset(context->buffer, 0, 64);
errno = ENOSYS;
/*
- * Clang analyzer doesn't see that getsockname initialises
+ * Static analyzer doesn't see that getsockname initialises
* the memory passed to it.
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
memset(&si, 0, sizeof(si));
#endif
}
/*
- * Clang analyzer doesn't see that getsockname initialises
+ * Static analyzer doesn't see that getsockname initialises
* the memory passed to it.
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
memset(&si, 0, sizeof(si));
#endif
#define SIGN_PROMOTE(_int, _len) ((_len) < sizeof(_int) ? \
(_int) | (~((__typeof__(_int))0)) << ((_len) << 3) : (_int))
-#if !defined(NDEBUG) || defined(__clang_analyzer__)
+#if !defined(NDEBUG) || defined(STATIC_ANALYZER)
/*
* Helps catch invalid fr_value_box_field_sizes
* entries, and shuts up clang analyzer.
/*
* Ensure we have the string form of the attribute
*/
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
/*
- * clang scan misses that fr_pair_print_value_quoted
+ * static analyzer misses that fr_pair_print_value_quoted
* always terminates the buffer.
*/
buffer[0] = '\0';
fr_dict_attr_t const *da;
fr_dhcpv4_ctx_t *packet_ctx = decode_ctx;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
#endif
fr_dict_attr_t const *da;
fr_dhcpv6_decode_ctx_t *packet_ctx = decode_ctx;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
#endif
return fr_pair_dns_labels_from_network(ctx, out, parent, packet_ctx->packet, data, data_len, packet_ctx->lb, false);
}
-
+
return decode_value(ctx, out, parent, data, data_len, decode_ctx);
}
fr_dict_attr_t const *da;
fr_dns_ctx_t *packet_ctx = decode_ctx;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
#endif
fr_dict_attr_t const *da;
fr_radius_ctx_t *packet_ctx = decode_ctx;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx || !packet_ctx->tmp_ctx) return PAIR_DECODE_FATAL_ERROR;
#endif
fr_pair_list_init(&head);
if (data_len < 3) return -1; /* type, length, value */
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx->tmp_ctx) return -1;
#endif
ssize_t attrlen, my_len;
fr_dict_attr_t const *da;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx->tmp_ctx) return -1;
#endif
uint8_t const *attr, *end;
fr_dict_attr_t const *da;
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx->tmp_ctx) return -1;
#endif
fr_pair_list_init(&head);
-#ifdef __clang_analyzer__
+#ifdef STATIC_ANALYZER
if (!packet_ctx->tmp_ctx) return -1;
#endif