Re: PATCH: Make the virBuffer API harder to misuse

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

 



On Mon, Apr 28, 2008 at 10:10:53AM -0400, Daniel Veillard wrote:
> On Mon, Apr 28, 2008 at 02:59:06PM +0100, Daniel P. Berrange wrote:
> > On Mon, Apr 28, 2008 at 08:19:20AM -0400, Daniel Veillard wrote:
> > > 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.
> > 
> > Here's the updated patch...
> 
>   Okay, that's massive, best to apply it early since we agree on it.

Great, this is applied too.

> > +
> > +/* If adding more fields, ensure to edit buf.h to match
> > +   the number of fields */
> > +struct _virBuffer {
> > +    unsigned int size;
> > +    unsigned int use;
> > +    unsigned int error;
> > +    char *content;
> > +};
> 
>   I would still prefer if we could get the compiler to check the
> structure (or at least their size) is the same... but that's should not
> impact how the client code will be using the buffers so, we can try to
> fix that after the main commit.

Might be able to play some games with sizeof() to make it break the
compile if they differ...

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]