checks: Make each message output atomic
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@kernel.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
committed by
David Gibson
parent
a1eff70c02
commit
2bdbd07a12
17
checks.c
17
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, ...) \
|
||||
|
||||
Reference in New Issue
Block a user