WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] libxl: correct allocation size in libxl_list_vm

To: Ian Campbell <ian.campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxl: correct allocation size in libxl_list_vm
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Wed, 28 Sep 2011 16:34:55 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 28 Sep 2011 08:35:24 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4a6d34dffcf9d568a783.1316613329@xxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Newsgroups: chiark.mail.xen.devel
References: <4a6d34dffcf9d568a783.1316613329@xxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Ian Campbell writes ("[Xen-devel] [PATCH] libxl: correct allocation size in 
libxl_list_vm"):
> libxl: correct allocation size in libxl_list_vm

Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

> *ptr has type libxl_vminfo not libxl_domid, so correct calloc call.
> 
> This the second instance of this bug I've noticed recently, I did a
> quick audit of other similar uses of sizeof(...) and all I spotted
> were a couple of harmlessly reversed calloc arguments. It's a pretty
> strong argument for "foo = ..alloc(sizeof(*foo))" rather than
> "alloc(sizeof(foos_type))" though...

The correct approach to this is to make a macro along these lines:

  #define OUR_CALLOC(foo) ((foo)=calloc(sizeof(*(foo))))

I think we may have some of these but we should have a complete set.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>