Hi Peter,

> These test cases parse an XML and format it back.
>
> You've got a bug in the code formatting the socket into the XML:
>
>                         if (def->kvm_features->socket == NULL) {
>                             virBufferAsprintf(&childBuf, " socket='%s'/>\n",
>                                               def->kvm_features->socket);
>                         } else {
>                             virBufferAddLit(&childBuf, "/>\n");
>                         }
>
>
> The above hunk formats the socket only if it's NULL, and skips it if
> it's non-null (inverted condition).
>

Doh! I think it's time for me to take some PTO...

Thank you !


However, I tried my best to follow your advice using 
virBufferEscapeString() so that i can get rid of the condition on the 
socket but it fails for "feature-off". 

But this is passing the test suite:

if (def->kvm_features->features[j] != VIR_TRISTATE_SWITCH_ABSENT) {
    virBufferAsprintf(&childBuf, "<%s state='%s'", virDomainKVMTypeToString(j),
        virTristateSwitchTypeToString(def->kvm_features->features[j]));
    if (def->kvm_features->socket != NULL) {
        virBufferEscapeString(&childBuf, " socket='%s'/>\n", 
def->kvm_features->socket);
    } else {
         virBufferAddLit(&childBuf, "/>\n");
    }
}

Is ok if I send my patch like this or would you prefer me to dig more 
into simplifying the code ?

Regards,
Anthony

Reply via email to