intel/tools: refactor logging to be easier to follow by static analyzers

Refactor out the part of fail_if function that never returns into
NORETURN function and put the condition check outside.

Addresses many false positive warnings by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7449>
This commit is contained in:
Marcin Ślusarz
2020-11-04 19:05:19 +01:00
committed by Marge Bot
parent f0061277c0
commit c323d7c2a7
4 changed files with 24 additions and 43 deletions
+21
View File
@@ -25,8 +25,10 @@
#ifndef INTEL_AUB_WRITE
#define INTEL_AUB_WRITE
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "drm-uapi/i915_drm.h"
@@ -37,6 +39,25 @@
extern "C" {
#endif
static inline void PRINTFLIKE(2, 3) NORETURN
_fail(const char *prefix, const char *format, ...)
{
va_list args;
va_start(args, format);
if (prefix)
fprintf(stderr, "%s: ", prefix);
vfprintf(stderr, format, args);
va_end(args);
abort();
}
#define _fail_if(cond, prefix, ...) do { \
if (cond) \
_fail(prefix, __VA_ARGS__); \
} while (0)
#define MAX_CONTEXT_COUNT 64
struct aub_ppgtt_table {