[libvirt] [PATCH 1/3] Replace some uses STREQLEN with STRPREFIX

Andrea Bolognani abologna at redhat.com
Fri Jun 24 15:29:26 UTC 2016


On Fri, 2016-06-24 at 15:00 +0200, Ján Tomko wrote:
> Do not call it with a magic constant matching the length
> of the pattern.
> ---
>  src/qemu/qemu_command.c             | 2 +-
>  src/storage/storage_backend_iscsi.c | 2 +-
>  src/storage/storage_backend_scsi.c  | 2 +-
>  src/xen/xen_hypervisor.c            | 4 ++--
>  4 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 08c66b8..0638a86 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -3610,7 +3610,7 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
>  {
>      virBuffer buf = VIR_BUFFER_INITIALIZER;
>  
> -    if (STREQLEN(def->os.machine, "s390-virtio", 10) &&
> +    if (STRPREFIX(def->os.machine, "s390-virtio") &&

The original code only checked the first 10 bytes of
def->os.machine, though. So it would have matched
"s390-virtie", but the new version doesn't! :P

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list