* [PATCH igt] lib/igt_core: use print("%s", #expr) instead of print(#expr)
@ 2015-08-13 17:17 Paulo Zanoni
2015-08-17 16:42 ` Dave Gordon
0 siblings, 1 reply; 2+ messages in thread
From: Paulo Zanoni @ 2015-08-13 17:17 UTC (permalink / raw)
To: intel-gfx
If I have a program with the following:
igt_skip_on(i % 2 == 0);
igt_skip_on_f(i % 2 == 0, "i:%d\n", i);
igt_require(i % 2 == 0);
igt_require_f(i % 2 == 0, "i:%d\n", i);
then I'll get compiler error messages complaining about format
conversions related to the '%' character used in the mod operation. So
put the whole string as a %s argument to avoid interpreting '%' and
any other possible chars.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
lib/igt_core.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 1d77f45..f8bfbf0 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -491,7 +491,7 @@ void igt_exit(void) __attribute__((noreturn));
*/
#define igt_require(expr) do { \
if (!(expr)) igt_skip_check(#expr , NULL); \
- else igt_debug("Test requirement passed: "#expr"\n"); \
+ else igt_debug("Test requirement passed: %s\n", #expr); \
} while (0)
/**
@@ -506,7 +506,7 @@ void igt_exit(void) __attribute__((noreturn));
*/
#define igt_skip_on(expr) do { \
if ((expr)) igt_skip_check("!(" #expr ")" , NULL); \
- else igt_debug("Test requirement passed: !("#expr")\n"); \
+ else igt_debug("Test requirement passed: !(%s)\n", #expr); \
} while (0)
/**
@@ -525,7 +525,7 @@ void igt_exit(void) __attribute__((noreturn));
*/
#define igt_require_f(expr, f...) do { \
if (!(expr)) igt_skip_check(#expr , f); \
- else igt_debug("Test requirement passed: "#expr"\n"); \
+ else igt_debug("Test requirement passed: %s\n", #expr); \
} while (0)
/**
@@ -544,7 +544,7 @@ void igt_exit(void) __attribute__((noreturn));
*/
#define igt_skip_on_f(expr, f...) do { \
if ((expr)) igt_skip_check("!("#expr")", f); \
- else igt_debug("Test requirement passed: !("#expr")\n"); \
+ else igt_debug("Test requirement passed: !(%s)\n", #expr); \
} while (0)
/* fork support code */
--
2.4.6
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH igt] lib/igt_core: use print("%s", #expr) instead of print(#expr)
2015-08-13 17:17 [PATCH igt] lib/igt_core: use print("%s", #expr) instead of print(#expr) Paulo Zanoni
@ 2015-08-17 16:42 ` Dave Gordon
0 siblings, 0 replies; 2+ messages in thread
From: Dave Gordon @ 2015-08-17 16:42 UTC (permalink / raw)
To: intel-gfx
On 13/08/15 18:17, Paulo Zanoni wrote:
> If I have a program with the following:
>
> igt_skip_on(i % 2 == 0);
> igt_skip_on_f(i % 2 == 0, "i:%d\n", i);
> igt_require(i % 2 == 0);
> igt_require_f(i % 2 == 0, "i:%d\n", i);
>
> then I'll get compiler error messages complaining about format
> conversions related to the '%' character used in the mod operation. So
> put the whole string as a %s argument to avoid interpreting '%' and
> any other possible chars.
>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Dave Gordon <david.s.gordon@intel.com>
... and I found a similar issue in the i915 driver's macros; see the
patch I just posted:
[PATCH] drm/i915: fix driver's versions of WARN_ON & WARN_ON_ONCE
.Dave.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-17 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 17:17 [PATCH igt] lib/igt_core: use print("%s", #expr) instead of print(#expr) Paulo Zanoni
2015-08-17 16:42 ` Dave Gordon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.