[CRIU] [PATCH 1/5] test_msg(): avoid recursion
Kir Kolyshkin
kir at openvz.org
Wed Oct 21 16:06:12 PDT 2015
In (highly unlikely) case localtime() failed, test_msg() calls
pr_perror() which is a wrapper around test_msg() so we're
calling ourselves, which can lead to infinite recursion if
localtime() keeps failing. Use fprintf() here to avoid this.
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
test/zdtm/lib/msg.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/lib/msg.c b/test/zdtm/lib/msg.c
index 012dd84..7b8d74d 100644
--- a/test/zdtm/lib/msg.c
+++ b/test/zdtm/lib/msg.c
@@ -50,7 +50,8 @@ void test_msg(const char *format, ...)
gettimeofday(&tv, NULL);
tm = localtime(&tv.tv_sec);
if (tm == NULL) {
- pr_perror("localtime() failed");
+ fprintf(stderr, "ERROR in %s: localtime() failed: %m\n",
+ __func__);
} else {
off += strftime(buf, sizeof(buf), "%H:%M:%S", tm);
}
--
2.4.3
More information about the CRIU
mailing list