[SeaBIOS] [RFC PATCH v3 11/19] Implement qmp and hmp commands for notification lists
Stefan Hajnoczi
stefanha at gmail.com
Tue Oct 23 14:15:12 CEST 2012
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
More information about the SeaBIOS
mailing list