[Libvir] PATCH: Make the virBuffer API harder to misuse

Daniel Veillard veillard at redhat.com
Mon Apr 28 12:19:20 UTC 2008


On Mon, Apr 28, 2008 at 01:13:00PM +0100, Daniel P. Berrange wrote:
> On Mon, Apr 28, 2008 at 03:17:33AM -0400, Daniel Veillard wrote:
> > I would prefer to relax the 'non-public' point and let the compiler 
> > compute the size in some ways rather than hardcode based on a word size
> > indication which may not take into account specific alignment problems
> > on some platforms.
> 
> One other option I considered is to just define the struct in the public 
> header with meaningless field names
> 
>   struct _virBuffer {
>      char a;

       char *a;

>      unsigned int b;
>      unsinged int c;
>   };
> 
> The real version is re-declared with proper names in buf.c, so this will
> at least discourage its use which is probably good enough.

  Fine by me.
  Let's just make sure that the compiler can do all its checking as needed
loosing that is IMHO more dangerous than potential abuses.

Daniel


-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/




More information about the libvir-list mailing list