On 03/31/2010 07:20 AM, Daniel P. Berrange wrote: > There's a slightly simpler way you can do this using strspn avoiding the > regex engine > > #define VALID_IFNAME_CHARS > "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" > > rc = strspn(ifname, VALID_IFNAME_CHARS) != strlen (value); That scans the string twice; if ifname is arbitrarily long, this can be inefficient. As a micro-optimization, you could instead check: rc = !ifname[strspn(ifname, VALID_IFNAME_CHARS)]; -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list