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.

> +  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.

-- 
Pino Toscano

Attachment: signature.asc
Description: This is a digitally signed message part.

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

Reply via email to