
On Mon, Aug 19, 2024 at 12:46:18 +0200, Michal Privoznik wrote:
There is a family of convenient macros: NULLSTR, NULLSTR_EMPTY, NULLSTR_STAR, NULLSTR_MINUS which hides ternary operator.
Generated using the following spatch (and its obvious variants):
@@ expression s; @@ <+... - s ? s : "<null>" + NULLSTR(s) ...+>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt.c | 2 +- src/network/network_iptables.c | 4 ++-- src/network/network_nftables.c | 4 ++-- src/qemu/qemu_firmware.c | 2 +- src/util/virnetdevip.c | 8 ++++---- tools/virsh-checkpoint.c | 2 +- tools/virsh-domain-monitor.c | 8 ++++---- tools/virsh-nodedev.c | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c index 26c3fe454f..1d37696d6f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -168,7 +168,7 @@ virConnectAuthCallbackDefault(virConnectCredentialPtr cred, }
if (cred[i].type != VIR_CRED_EXTERNAL) { - cred[i].result = bufptr ? bufptr : g_strdup(cred[i].defresult ? cred[i].defresult : "");
oof, double eww!
+ cred[i].result = bufptr ? bufptr : g_strdup(NULLSTR_EMPTY(cred[i].defresult));
but getting rid of this too would be out of scope
cred[i].resultlen = strlen(cred[i].result); } }
Reviewed-by: Peter Krempa <pkrempa@redhat.com>