Re: [libvirt] [PATCH] nwfilter: enable hex number inputs in filter XML

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

 



On 04/26/2010 10:44 AM, Stefan Berger wrote:
> With this patch I want to enable hex number inputs in the filter XML. A
> number that was entered as hex is also printed as hex unless a string
> representing the meaning can be found.
> 
> I am also extending the schema and adding a test case. A problem with
> the DSCP value is fixed on the way as well.

ACK.

> +               format = "%d";
> +
> +               switch (item->datatype) {
>  
> +               case DATATYPE_UINT8_HEX:
> +                   format = "0x%x";
>                 case DATATYPE_IPMASK:
>                 case DATATYPE_IPV6MASK:
>                     // display all masks in CIDR format
>                 case DATATYPE_UINT8:
>                     storage_ptr = &item->u.u8;
> -                   virBufferVSprintf(buf, "%d", *(uint8_t *)storage_ptr);
> +                   virBufferVSprintf(buf, format, *(uint8_t *)storage_ptr);

Gcc didn't warn about the use of a non-literal format argument here?  At
any rate, if it does start warning, the fix is simple - create a bool
witness, and a ?: expression based on that bool, rather than default
assignment to a variable, similar to what you did here:

>      case DATATYPE_UINT8:
> +    case DATATYPE_UINT8_HEX:
>          if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",

-- 
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

[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]