public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2 01/21] lib: Introduce igt_assume()
Date: Fri, 18 Jan 2019 12:34:04 +0200	[thread overview]
Message-ID: <20190118103404.4330-1-petri.latvala@intel.com> (raw)
In-Reply-To: <20190116112050.27647-2-petri.latvala@intel.com>

igt_assume() is an assert-like macro that is used to give hints to
static analysis of code. If static analysis is not used (as detected
by STATIC_ANALYSIS_BUILD), igt_assume() expands to a no-op statement,
otherwise expands to an assert().

v2: Make sure the expression in igt_assume is still parsed without
    static analysis. (Chris)

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski@intel.com>
---
 lib/igt_core.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/igt_core.h b/lib/igt_core.h
index 6f8c3852..4fdac1b8 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -30,6 +30,7 @@
 #ifndef IGT_CORE_H
 #define IGT_CORE_H
 
+#include <assert.h>
 #include <setjmp.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -54,6 +55,21 @@
 #endif
 #endif
 
+/**
+ * igt_assume:
+ * @expr: Condition to test
+ *
+ * An assert-like macro to be used for tautologies to give hints to
+ * static analysis of code. No-op if STATIC_ANALYSIS_BUILD is not
+ * defined, expands to an assert() if it is.
+ */
+#if STATIC_ANALYSIS_BUILD
+#define igt_assume(e) assert(e)
+#else
+/* Make sure the expression is still parsed even though it generates no code */
+#define igt_assume(e) ((void)(sizeof((long)(e))))
+#endif
+
 extern const char* __igt_test_description __attribute__((weak));
 extern bool __igt_plain_output;
 extern char *igt_frame_dump_path;
-- 
2.19.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-01-18 10:34 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-16 11:20 [igt-dev] [PATCH i-g-t 00/21] Static analysis: misc cleanups and fixes Petri Latvala
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 01/21] lib: Introduce igt_assume() Petri Latvala
2019-01-16 14:26   ` Chris Wilson
2019-01-18 10:34   ` Petri Latvala [this message]
2019-01-21 11:33     ` [igt-dev] [PATCH i-g-t v3 01/21] lib: Introduce BUILD_BUG_ON_INVALID and igt_assume() Petri Latvala
2019-01-21 11:41       ` Chris Wilson
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 02/21] lib/i915/gem_context: Help static analysis with execution flow Petri Latvala
2019-01-16 11:30   ` Chris Wilson
2019-01-16 14:22   ` Chris Wilson
2019-01-18 10:42   ` [igt-dev] [PATCH i-g-t v2 " Petri Latvala
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 03/21] lib/ioctl_wrappers: " Petri Latvala
2019-01-18 10:42   ` [igt-dev] [PATCH i-g-t v2 " Petri Latvala
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 04/21] lib/igt_kms: Use correct type for calloc Petri Latvala
2019-01-17  9:55   ` Abdiel Janulgue
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 05/21] tests: " Petri Latvala
2019-01-16 11:28   ` Kahola, Mika
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 06/21] lib: Avoid memcpying 0 bytes from NULL Petri Latvala
2019-01-17 11:14   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 07/21] overlay: Write out the assumption for kernel-provided data Petri Latvala
2019-01-28 13:21   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 08/21] benchmarks/wsim: Handle a parse error Petri Latvala
2019-01-16 11:45   ` Tvrtko Ursulin
2019-01-16 12:03     ` Petri Latvala
2019-01-16 12:07       ` Chris Wilson
2019-01-16 12:08       ` Tvrtko Ursulin
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 09/21] lib/igt_kms: Make igt_display_init require at least one plane Petri Latvala
2019-01-16 17:11   ` Robert Foss
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 10/21] tests/kms_color: Assert gamma look up table sizes Petri Latvala
2019-01-28 13:04   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 11/21] lib/igt_kms: Assert that active crtcs have at least one plane Petri Latvala
2019-01-16 11:30   ` Kahola, Mika
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 12/21] benchmarks/gem_userptr_benchmark: Correctly free memory Petri Latvala
2019-01-16 11:48   ` Tvrtko Ursulin
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 13/21] lib/igt_alsa: Remove dead assignment Petri Latvala
2019-01-16 14:14   ` Paul Kocialkowski
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 14/21] lib/igt_audio: Initialize freq in audio_signal_detect() Petri Latvala
2019-01-16 14:16   ` Paul Kocialkowski
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 15/21] igt_aux: Handle empty pm_test file gracefully Petri Latvala
2019-01-28 13:18   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 16/21] lib/igt_core: Assert that optarg is present Petri Latvala
2019-01-17 12:17   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 17/21] lib/igt_core: Handle all failures to read .igtrc Petri Latvala
2019-01-16 14:18   ` Paul Kocialkowski
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 18/21] lib/igt_core: Initialize fds in igt_system_quiet Petri Latvala
2019-01-17  9:56   ` Abdiel Janulgue
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 19/21] lib/igt_kms: Aid static analyzer with the control flow Petri Latvala
2019-01-28 13:17   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 20/21] lib/igt_x86: Mock-use variable to silence static analysis Petri Latvala
2019-01-28 13:11   ` Arkadiusz Hiler
2019-01-16 11:20 ` [igt-dev] [PATCH i-g-t 21/21] lib/drmtest: Don't read from NULL in set_forced_driver Petri Latvala
2019-01-16 12:15   ` Rodrigo Siqueira
2019-01-16 12:12 ` [igt-dev] ✓ Fi.CI.BAT: success for Static analysis: misc cleanups and fixes Patchwork
2019-01-16 22:20 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-01-18 11:22 ` [igt-dev] ✗ Fi.CI.BAT: failure for Static analysis: misc cleanups and fixes (rev4) Patchwork
2019-01-18 12:44 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2019-01-18 17:48 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-01-21 12:09 ` [igt-dev] ✓ Fi.CI.BAT: success for Static analysis: misc cleanups and fixes (rev5) Patchwork
2019-01-21 16:21 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190118103404.4330-1-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox