From 300cdc435db52017a01cba2eb61c6c4decaa60a6 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Mon, 14 Feb 2022 17:57:27 +0100 Subject: [PATCH] expanding_report: make expandable for XML node generation 'generate(Xml_node node)', as used by the Sculpt manager, calls this function instead of the lambda version. The 'report' function of the 'Genode::Reporter' does not throw an exception in case there is not enough backing storage for the 'generate' request. Therefore, we have to check this condition in a loop and call '_increase_report_buffer' in case size limits are reached. Patch by Norman Feske. issue #4369 --- repos/os/include/os/reporter.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/repos/os/include/os/reporter.h b/repos/os/include/os/reporter.h index 6c32a669c1..6b18f0b8c3 100644 --- a/repos/os/include/os/reporter.h +++ b/repos/os/include/os/reporter.h @@ -203,14 +203,18 @@ class Genode::Expanding_reporter void generate(Xml_node node) { - retry( + for (bool done = false; !done; ) { + node.with_raw_node([&] (char const *start, size_t length) { + if (length > _buffer_size) + return; - [&] () { - node.with_raw_node([&] (char const *start, size_t length) { - _reporter->report(start, length); }); }, + _reporter->report(start, length); + done = true; + }); - [&] () { _increase_report_buffer(); } - ); + if (!done) + _increase_report_buffer(); + } } };