On Tue, Aug 08, 2017 at 02:32:23PM +0200, Pino Toscano wrote:
> On Thursday, 3 August 2017 19:13:48 CEST Richard W.M. Jones wrote:
> > +  fprintf (stderr, "mode = %o\n", statbuf.st_mode);
> > +  if (S_ISBLK (statbuf.st_mode))
> > +    /* continue */;
> > +  else if (S_ISDIR (statbuf.st_mode)) {
> > +    fprintf (stderr, "S_ISDIR\n");
> 
> The two unconditional fprintf() look like debugging leftovers.

Oops, indeed they are ...

> > +  fd = open (device, O_RDONLY|O_CLOEXEC);
> > +  if (fd == -1) {
> > +    if (verbose)
> > +      fprintf (stderr, "%s: open: %s: %m\n", "is_device_parameter", 
> > device);
> > +    return 0;
> > +  }
> > +  if (ioctl (fd, BLKGETSIZE64, &n) == -1) {
> > +    if (verbose)
> > +      fprintf (stderr, "%s: ioctl BLKGETSIZE64: %s: %m\n",
> > +               "is_device_parameter", device);
> > +    close (fd);
> > +    return 0;
> > +  }
> > +  close (fd);
> 
> Maybe 'fd' can be:
>   CLEANUP_CLOSE int fd = -1;
> so there is no need to manually close() it on every return path.

Yeah, that would be better.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Reply via email to