qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v3 11/19] Implement qmp and hmp commands for


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC PATCH v3 11/19] Implement qmp and hmp commands for notification lists
Date: Tue, 23 Oct 2012 14:15:12 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]