From 0f79480b9f10683962235d8babce4913df411ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 24 Jun 2016 10:37:04 +0200 Subject: [PATCH] Replace some uses STREQLEN with STRPREFIX 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 08c66b8800..0638a868af 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") && virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon) def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c index 98d114110c..832cf6537a 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -106,7 +106,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path, } while ((direrr = virDirRead(sysdir, &dirent, sysfs_path)) > 0) { - if (STREQLEN(dirent->d_name, "target", strlen("target"))) { + if (STRPREFIX(dirent->d_name, "target")) { if (sscanf(dirent->d_name, "target%u:", host) != 1) { VIR_DEBUG("Failed to parse target '%s'", dirent->d_name); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 558b3cf49c..99504f4e00 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -350,7 +350,7 @@ getBlockDevice(uint32_t host, goto cleanup; while ((direrr = virDirRead(lun_dir, &lun_dirent, lun_path)) > 0) { - if (STREQLEN(lun_dirent->d_name, "block", 5)) { + if (STRPREFIX(lun_dirent->d_name, "block")) { if (strlen(lun_dirent->d_name) == 5) { if (getNewStyleBlockDevice(lun_path, lun_dirent->d_name, diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index fc9e1c6bec..79b25b3e6c 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2255,7 +2255,7 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode) *pae = 0; *hvm = ""; - if (STREQLEN((const char *)®s.r_ebx, "AuthcAMDenti", 12)) { + if (STRPREFIX((const char *)®s.r_ebx, "AuthcAMDenti")) { if (pread(fd, ®s, sizeof(regs), 0x80000001) == sizeof(regs)) { /* Read secure virtual machine bit (bit 2 of ECX feature ID) */ if ((regs.r_ecx >> 2) & 1) @@ -2263,7 +2263,7 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode) if ((regs.r_edx >> 6) & 1) *pae = 1; } - } else if (STREQLEN((const char *)®s.r_ebx, "GenuntelineI", 12)) { + } else if (STRPREFIX((const char *)®s.r_ebx, "GenuntelineI")) { if (pread(fd, ®s, sizeof(regs), 0x00000001) == sizeof(regs)) { /* Read VMXE feature bit (bit 5 of ECX feature ID) */ if ((regs.r_ecx >> 5) & 1) -- GitLab