Re: [PATCH 2/4 v2] conf: Parse and format disk <wwn>

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

 



On 2012年08月31日 22:37, Eric Blake wrote:
On 08/31/2012 04:10 AM, Osier Yang wrote:
Validates the wwn while parsing, error out if it's malformed.

* src/util/util.h: Declare virValidateWWN
* src/util/util.c: Implement virValidateWWN
* src/libvirt_private.syms: Export virValidateWWN.
* src/conf/domain_conf.h: New member 'wwn' for disk def.
* src/conf/domain_conf.c: Parse and format disk<wwn>

+#define WWN_REG_PATTERN    "[0-9a-zA-Z]{16}"
+bool
+virValidateWWN(const char *wwn) {
+    regex_t re;
+    int err;
+    char error[100];
+
+    if ((err = regcomp(&re, WWN_REG_PATTERN, REG_EXTENDED)) != 0)

Do we really need regcomp() for this?  I'm thinking it's much faster to
just do something like:

for (i = 0; wwn[i]; i++)
     if (!c_isxdigit(wwn[i]))
         break;
if (i != 16 || wwn[i])
     // error, return false;
return true;


Which is more compat, I posted a v3, thanks.

Regards,
Osier

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]