[libvirt] RFC: fixing struct name in public header

Pavel Hrdina phrdina at redhat.com
Wed Apr 12 13:07:59 UTC 2017


On Wed, Apr 12, 2017 at 03:01:35PM +0200, Michal Privoznik wrote:
> On 04/12/2017 01:31 PM, Daniel P. Berrange wrote:
> > Take a look at this def from libvirt-domain.h:
> >
> > typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
> > typedef virDomainIPAddress *virDomainIPAddressPtr;
> > struct _virDomainInterfaceIPAddress {
> >     int type;                /* virIPAddrType */
> >     char *addr;              /* IP address */
> >     unsigned int prefix;     /* IP address prefix */
> > };
> >
> >
> > Notice the struct name is different from the typedef names.
> >
> > Technically renaming the struct to remove the 'Interface' word
> > would be an API break.
> >
> > On the flip side though we don't expect any apps to use the struct
> > name, but rather use the typedefs, hence use of '_' in the name.
> >
> > We could do what we did with the typed parameter stuff and rename
> > the struct, but add a
> >
> >   #define _virDomainInterfaceIPAddress _virDomainIPAddress
> >
> > Any thoughts ?
> 
> I'd rename it even without the additional #define. APPs should favour 
> the type instead of using struct _virBlah. We have it there because 
> there's no other way to expose the struct members to callers in C.

That's true but it could break some application and libvirt promises not
to do that, so I'm for the rename including the #define.  We cannot assume
that it's not used and simply rename it.

This might be related, but how about marking some our really old API and
also those wrong names as deprecated or some different compile time warning
to let developers know that they might want to update their code?

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170412/a488a114/attachment-0001.sig>


More information about the libvir-list mailing list