mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qdist: return "(empty)" instead of NULL when printing an empty dist
Printf'ing a NULL string is undefined behaviour. Avoid it. Reported-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <1469459025-23606-4-git-send-email-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
071d405477
commit
11b7b07f8a
2 changed files with 12 additions and 4 deletions
|
@ -360,10 +360,16 @@ static void test_none(void)
|
|||
g_assert(isnan(qdist_xmax(&dist)));
|
||||
|
||||
pr = qdist_pr_plain(&dist, 0);
|
||||
g_assert(pr == NULL);
|
||||
g_assert_cmpstr(pr, ==, "(empty)");
|
||||
g_free(pr);
|
||||
|
||||
pr = qdist_pr_plain(&dist, 2);
|
||||
g_assert(pr == NULL);
|
||||
g_assert_cmpstr(pr, ==, "(empty)");
|
||||
g_free(pr);
|
||||
|
||||
pr = qdist_pr(&dist, 0, QDIST_PR_BORDER);
|
||||
g_assert_cmpstr(pr, ==, "(empty)");
|
||||
g_free(pr);
|
||||
|
||||
qdist_destroy(&dist);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue