From: Martin Radev <martin.b.radev@gmail.com>
To: kvm@vger.kernel.org, will@kernel.org,
julien.thierry.kdev@gmail.com, andre.przywara@arm.com,
alexandru.elisei@arm.com
Cc: Martin Radev <martin.b.radev@gmail.com>
Subject: [PATCH kvmtool 1/5] kvmtool: Add WARN_ONCE macro
Date: Fri, 4 Mar 2022 01:10:46 +0200 [thread overview]
Message-ID: <20220303231050.2146621-2-martin.b.radev@gmail.com> (raw)
In-Reply-To: <20220303231050.2146621-1-martin.b.radev@gmail.com>
Add a macro to enable to print a warning only once. This is
beneficial for cases where a warning could be helpful for
debugging, but still log pollution is preferred not to happen.
Signed-off-by: Martin Radev <martin.b.radev@gmail.com>
---
include/kvm/util.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/kvm/util.h b/include/kvm/util.h
index d76568a..b494548 100644
--- a/include/kvm/util.h
+++ b/include/kvm/util.h
@@ -82,6 +82,16 @@ do { \
__ret_warn_on; \
})
+#define WARN_ONCE(condition, format, args...) ({ \
+ static int __warned; \
+ int __ret_warn_on = !!(condition); \
+ if (!__warned && __ret_warn_on) { \
+ __warned = 1; \
+ pr_warning(format, args); \
+ } \
+ __ret_warn_on; \
+})
+
#define MSECS_TO_USECS(s) ((s) * 1000)
/* Millisecond sleep */
--
2.25.1
next prev parent reply other threads:[~2022-03-03 23:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 23:10 [PATCH v2 kvmtool 0/5] Fix few small issues in virtio code Martin Radev
2022-03-03 23:10 ` Martin Radev [this message]
2022-03-03 23:10 ` [PATCH kvmtool 2/5] virtio: Sanitize config accesses Martin Radev
2022-03-16 13:04 ` Alexandru Elisei
2022-03-27 20:37 ` Martin Radev
2022-04-22 10:12 ` Alexandru Elisei
2022-03-03 23:10 ` [PATCH kvmtool 3/5] virtio: Check for overflows in QUEUE_NOTIFY and QUEUE_SEL Martin Radev
2022-03-16 15:38 ` Alexandru Elisei
2022-03-27 20:45 ` Martin Radev
2022-04-22 10:35 ` Alexandru Elisei
2022-03-03 23:10 ` [PATCH kvmtool 4/5] Makefile: Mark stack as not executable Martin Radev
2022-03-03 23:10 ` [PATCH kvmtool 5/5] mmio: Sanitize addr and len Martin Radev
2022-03-16 15:39 ` Alexandru Elisei
2022-03-27 21:00 ` Martin Radev
2022-04-22 10:36 ` Alexandru Elisei
2022-03-10 14:56 ` [PATCH v2 kvmtool 0/5] Fix few small issues in virtio code Alexandru Elisei
2022-03-11 11:23 ` Andre Przywara
2022-03-14 17:11 ` Alexandru Elisei
2022-03-27 12:46 ` Martin Radev
2022-04-22 10:37 ` Alexandru Elisei
2022-05-06 13:20 ` Will Deacon
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=20220303231050.2146621-2-martin.b.radev@gmail.com \
--to=martin.b.radev@gmail.com \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=will@kernel.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 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.