Re: [RFC PATCH v3 11/19] Implement qmp and hmp commands for notification lists

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

 



On Fri, Sep 21, 2012 at 01:17:27PM +0200, Vasilis Liaskovitis wrote:
> +MemHpInfoList *qmp_query_memory_hotplug(Error **errp)
> +{
> +    DimmBus *bus = main_memory_bus;
> +    MemHpInfoList *head = NULL, *cur_item = NULL, *info;
> +    struct dimm_hp_result *item, *nextitem;
> +
> +    QTAILQ_FOREACH_SAFE(item, &bus->dimm_hp_result_queue, next, nextitem) {
> +
> +        info = g_malloc0(sizeof(*info));
> +        info->value = g_malloc0(sizeof(*info->value));
> +        info->value->dimm = g_malloc0(sizeof(char) * 32);
> +        info->value->request = g_malloc0(sizeof(char) * 16);
> +        info->value->result = g_malloc0(sizeof(char) * 16);
> +        switch (item->ret) {
> +            case DIMM_REMOVE_SUCCESS:
> +                strcpy(info->value->request, "hot-remove");
> +                strcpy(info->value->result, "success");
> +                break;
> +            case DIMM_REMOVE_FAIL:
> +                strcpy(info->value->request, "hot-remove");
> +                strcpy(info->value->result, "failure");
> +                break;
> +            case DIMM_ADD_SUCCESS:
> +                strcpy(info->value->request, "hot-add");
> +                strcpy(info->value->result, "success");
> +                break;
> +            case DIMM_ADD_FAIL:
> +                strcpy(info->value->request, "hot-add");
> +                strcpy(info->value->result, "failure");
> +                break;
> +            default:
> +                break;    
> +        }

Any reason to use fixed-size malloc + strcpy() instead of just
info->value->X = g_strdup("foo")?

Stefan
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux