]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
wireshark: Don't special case retval of get_program_data() in dissect_libvirt_message()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 10 Oct 2025 17:16:54 +0000 (19:16 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 14 Oct 2025 13:08:28 +0000 (15:08 +0200)
The get_program_data() function returns a pointer (in this
specific case to an array of procedure strings) which, if
non-NULL is then passed val_to_str(). Well, if val_to_str() sees
NULL it is treated gracefully, i.e. like if the numeric value
'proc' wasn't found in the array.

Therefore, there's no need to special case call to
col_append_fstr(). Both result into the same behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
tools/wireshark/src/packet-libvirt.c

index af14c6bed74bd19a4b4d98849311b9e9f9ebb382..6c729801d4055fcbdb971479da9fb9def01706f5 100644 (file)
@@ -469,11 +469,7 @@ dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
                  val_to_str(prog, program_strings, "%x"));
 
     vs = get_program_data(prog, VIR_PROGRAM_PROCSTRINGS);
-    if (vs == NULL) {
-        col_append_fstr(pinfo->cinfo, COL_INFO, " Proc=%d", proc);
-    } else {
-        col_append_fstr(pinfo->cinfo, COL_INFO, " Proc=%s", val_to_str(proc, vs, "%d"));
-    }
+    col_append_fstr(pinfo->cinfo, COL_INFO, " Proc=%s", val_to_str(proc, vs, "%d"));
 
     col_append_fstr(pinfo->cinfo, COL_INFO, " Type=%s Serial=%u Status=%s",
                     val_to_str(type, type_strings, "%d"), serial,