Printing to stderr as we build up the check message results in interleaving of messages when multiple instances of dtc are running. Change the message output to use an intermediate buffer for constructing the message and then output the message to stderr with a single fputs. While perhaps there is no guarantee that fputs will be atomic, this gets rid of any interleaved output that previously occurred on Linux. Signed-off-by: Rob Herring <robh@xxxxxxxxxx> --- checks.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/checks.c b/checks.c index 4d8dffd36b6e..32e0d7aed8f8 100644 --- a/checks.c +++ b/checks.c @@ -78,23 +78,28 @@ static inline void PRINTF(5, 6) check_msg(struct check *c, struct dt_info *dti, const char *fmt, ...) { va_list ap; + char *str = NULL; if (!(c->warn && (quiet < 1)) && !(c->error && (quiet < 2))) return; - fprintf(stderr, "%s: %s (%s): ", + xasprintf(&str, "%s: %s (%s): ", strcmp(dti->outname, "-") ? dti->outname : "<stdout>", (c->error) ? "ERROR" : "Warning", c->name); if (node) { - fprintf(stderr, "%s", node->fullpath); if (prop) - fprintf(stderr, ":%s", prop->name); - fputs(": ", stderr); + xasprintf_append(&str, "%s:%s: ", node->fullpath, prop->name); + else + xasprintf_append(&str, "%s: ", node->fullpath); } + va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + xavsprintf_append(&str, fmt, ap); va_end(ap); - fprintf(stderr, "\n"); + + xasprintf_append(&str, "\n"); + + fputs(str, stderr); } #define FAIL(c, dti, node, ...) \ -- 2.19.1