[libvirt] [PATCHv2 02/10] Replace sscanf in nwfilter rule parsing

Eric Blake eblake at redhat.com
Wed Mar 31 22:06:16 UTC 2010


On 03/31/2010 03:41 PM, Matthias Bolte wrote:
> Parsing is stricter now and doesn't accept trailing characters
> after the actual value anymore.

The other instances are okay, but...

> @@ -1659,7 +1659,7 @@ virNWFilterRuleParse(virConnectPtr conn,
>      ret->priority = MAX_RULE_PRIORITY / 2;
>  
>      if (prio) {
> -        if (sscanf(prio, "%d", (int *)&priority) == 1) {
> +        if (virStrToLong_i(prio, NULL, 10, (int *)&priority) >= 0) {
>              if ((int)priority >= 0 && priority <= MAX_RULE_PRIORITY)

This looks gross.  Since priority is unsigned int, why not just use:

 virStrToLong_ui(,,,&priority) >= 0
  if (priority <= MAX_RULE_PRIORITY)

ACK if you make that tweak.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100331/50743dc9/attachment-0001.sig>


More information about the libvir-list mailing list