[libvirt PATCH 0/2] tests: nssdata: add empty status file

A blurb is a short promotional piece accompanying a piece of creative work. It may be written by the author or publisher or quote praise from others. Blurbs were originally printed on the back or rear dust jacket of a book. With the development of the mass-market paperback, they were placed on both covers by most publishers. Now they are also found on web portals and news websites. A blurb may introduce a newspaper or a book. -- https://en.wikipedia.org/wiki/Blurb Ján Tomko (2): DO NOT PUSH Revert "nss: Skip empty files and avoid use of uninitialized value" tests: nssdata: add empty status file tests/nssdata/virbr2.status | 0 tools/nss/libvirt_nss_leases.c | 9 ++------- tools/nss/libvirt_nss_macs.c | 9 ++------- 3 files changed, 4 insertions(+), 14 deletions(-) create mode 100644 tests/nssdata/virbr2.status -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> This reverts commit 63a3d70697dc44ef2f8b40f7c8e9aa869227a7da. --- tools/nss/libvirt_nss_leases.c | 9 ++------- tools/nss/libvirt_nss_macs.c | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 6624df2928..25978e41a8 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -266,7 +266,7 @@ findLeases(const char *file, enum json_tokener_error jerr = json_tokener_error_parse_eof; int jsonflags = JSON_TOKENER_STRICT | JSON_TOKENER_VALIDATE_UTF8; char line[1024]; - size_t nreadTotal = 0; + ssize_t nreadTotal = 0; int rv; if ((fd = open(file, O_RDONLY)) < 0) { @@ -293,17 +293,12 @@ findLeases(const char *file, jerr = json_tokener_get_error(tok); } while (jerr == json_tokener_continue); - if (nreadTotal == 0) { - ret = 0; - goto cleanup; - } - if (jerr == json_tokener_continue) { ERROR("Cannot parse %s: incomplete json found", file); goto cleanup; } - if (jerr != json_tokener_success) { + if (nreadTotal > 0 && jerr != json_tokener_success) { ERROR("Cannot parse %s: %s", file, json_tokener_error_desc(jerr)); goto cleanup; } diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c index 44544624f3..040ea045f3 100644 --- a/tools/nss/libvirt_nss_macs.c +++ b/tools/nss/libvirt_nss_macs.c @@ -124,7 +124,7 @@ findMACs(const char *file, json_tokener *tok = NULL; enum json_tokener_error jerr = json_tokener_error_parse_eof; int jsonflags = JSON_TOKENER_STRICT | JSON_TOKENER_VALIDATE_UTF8; - size_t nreadTotal = 0; + ssize_t nreadTotal = 0; int rv; size_t i; @@ -152,17 +152,12 @@ findMACs(const char *file, jerr = json_tokener_get_error(tok); } while (jerr == json_tokener_continue); - if (nreadTotal == 0) { - ret = 0; - goto cleanup; - } - if (jerr == json_tokener_continue) { ERROR("Cannot parse %s: incomplete json found", file); goto cleanup; } - if (jerr != json_tokener_success) { + if (nreadTotal > 0 && jerr != json_tokener_success) { ERROR("Cannot parse %s: %s", file, json_tokener_error_desc(jerr)); goto cleanup; } -- 2.50.1

From: Ján Tomko <jtomko@redhat.com> Add a test to makee sure we will keep ignoring empty status files properly in the future. https://bugzilla.redhat.com/show_bug.cgi?id=2364285 Fixes: 63a3d70697dc44ef2f8b40f7c8e9aa869227a7da Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/nssdata/virbr2.status | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/nssdata/virbr2.status diff --git a/tests/nssdata/virbr2.status b/tests/nssdata/virbr2.status new file mode 100644 index 0000000000..e69de29bb2 -- 2.50.1

On Wed, Jul 16, 2025 at 01:44:48PM +0200, Ján Tomko via Devel wrote:
From: Ján Tomko <jtomko@redhat.com>
Add a test to makee sure we will keep ignoring empty status files properly in the future.
https://bugzilla.redhat.com/show_bug.cgi?id=2364285
Fixes: 63a3d70697dc44ef2f8b40f7c8e9aa869227a7da Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
--- tests/nssdata/virbr2.status | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/nssdata/virbr2.status
diff --git a/tests/nssdata/virbr2.status b/tests/nssdata/virbr2.status new file mode 100644 index 0000000000..e69de29bb2 -- 2.50.1
participants (2)
-
Ján Tomko
-
Martin Kletzander