[PATCH 0/2] A couple of trivial patches

*** BLURB HERE *** Michal Prívozník (2): virsh-domain: Fix return of virshGetDBusDisplay() in one error path examples: Define _GNU_SOURCE for more examples examples/c/admin/logging.c | 1 + examples/c/domain/domtop.c | 1 + tools/virsh-domain.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) -- 2.43.0

The virshGetDBusDisplay() function is declared to return a pointer and yet, in one error path false is returned. Switch the statement to return NULL, which is what other error paths use to indicate an error. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tools/virsh-domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 58d5a4ab57..e69d14a6aa 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11908,7 +11908,7 @@ virshGetDBusDisplay(vshControl *ctl, xmlXPathContext *ctxt) addr = virXPathString(xpath, ctxt); if (!addr) - return false; + return NULL; if (STRPREFIX(addr, "unix:path=")) { return g_strdup_printf("dbus+unix://%s", addr + 10); -- 2.43.0

Some of our examples use GNU/Linux extensions functions/variables: 1) domtop.c uses usleep(3), 2) logging.c uses getopt(3). Put _GNU_SOURCE definition at the top of corresponding files so that users can just grab the code and compile it (in contrast with the rest of the code where _GNU_SOURCE is declared in meson-config.h). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- examples/c/admin/logging.c | 1 + examples/c/domain/domtop.c | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/c/admin/logging.c b/examples/c/admin/logging.c index 575d15a3a6..f7620b2ab5 100644 --- a/examples/c/admin/logging.c +++ b/examples/c/admin/logging.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <stdbool.h> diff --git a/examples/c/domain/domtop.c b/examples/c/domain/domtop.c index 65663a1c39..2345a5953c 100644 --- a/examples/c/domain/domtop.c +++ b/examples/c/domain/domtop.c @@ -18,6 +18,7 @@ * <http://www.gnu.org/licenses/>. */ +#define _GNU_SOURCE #include <errno.h> #include <getopt.h> #include <libvirt/libvirt.h> -- 2.43.0

On a Wednesday in 2024, Michal Privoznik wrote:
*** BLURB HERE ***
Michal Prívozník (2): virsh-domain: Fix return of virshGetDBusDisplay() in one error path examples: Define _GNU_SOURCE for more examples
examples/c/admin/logging.c | 1 + examples/c/domain/domtop.c | 1 + tools/virsh-domain.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Michal Privoznik