Re: [PATCH kvm-unit-tests 1/3] lib/string: Fix getenv name matching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14/10/20 21:14, Andrew Jones wrote:
> +        if (strlen(name) == len && strncmp(name, *envp, len) == 0)
>              return delim + 1;
>          ++envp;
>      }
> -- 2.26.2


Slightly more efficient:

+        if (memcmp(name, *envp, len) == 0 && !name[len])

(strncmp is not needed since we know there's no NULL between *envp and
*envp+len, and after memcmp we know the same about the first len
characters of name).

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux