Re: [PATCH] util: move ENODATA redefine to virutil.h

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

 



On Thu, Apr 07, 2016 at 11:13:00AM +0200, Andrea Bolognani wrote:
> On Thu, 2016-04-07 at 09:53 +0300, Roman Bogorodskiy wrote:
> > FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO. However,
> > now we have virrandom.c that's using ENODATA also, so move this
> > re-definition to a common place, virutil.h, so it could fix things for
> > both consumers.
> > ---
> >  src/util/virutil.h | 4 ++++
> >  src/util/viruuid.c | 4 ----
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/util/virutil.h b/src/util/virutil.h
> > index b121de0..36ed186 100644
> > --- a/src/util/virutil.h
> > +++ b/src/util/virutil.h
> > @@ -36,6 +36,10 @@
> >  #  define MAX(a, b) ((a) > (b) ? (a) : (b))
> >  # endif
> >  
> > +# ifndef ENODATA
> > +#  define ENODATA EIO
> > +# endif
> > +
> >  
> >  int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK;
> >  int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK;
> > diff --git a/src/util/viruuid.c b/src/util/viruuid.c
> > index 1fcc954..16e57db 100644
> > --- a/src/util/viruuid.c
> > +++ b/src/util/viruuid.c
> > @@ -46,10 +46,6 @@
> >  
> >  VIR_LOG_INIT("util.uuid");
> >  
> > -#ifndef ENODATA
> > -# define ENODATA EIO
> > -#endif
> > -
> >  static unsigned char host_uuid[VIR_UUID_BUFLEN];
> >  
> >  static int
> 
> These are the current occurrences of ENODATA:
> 
>   src/storage/storage_backend.c:
>     if (errno != ENODATA && errno != ENOTSUP) {
> 
>   tests/securityselinuxlabeltest.c:
>     if (errno == ENODATA) {
> 
>   src/util/viruuid.c:
>     #ifndef ENODATA
>     # define ENODATA EIO
> 
>   src/util/virrandom.c:
>     return n < 0 ? errno : ENODATA;
> 
> The first is inside a '#if WITH_SELINUX' block, so FreeBSD is
> not going to hit it. The second one is a SELinux-specific test,
> and it's not compiled on FreeBSD.
> 
> The third one is where ENODATA gets defined, as you mention in
> your commit message, and the fourth one where it's used.
> 
> Note that ENODATA is not being used in viruuid.c... I guess
> the code that prompted the definition has since been removed.
> 
> So I think you should rather move the definition from viruuid.c
> to virrandom.c instead of virutil.h.
> 
> ACK with that changed.

Actually for this kind of super generic portability fix I'd
strongly suggest we put it in internal.h, so no matter what
code we add in the future, it'll always have the ENODATA
compat defined

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
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]