[Libguestfs] [PATCH 3/6] daemon: Refine check for Device and Dev_or_Path parameters (RHBZ#1477623).
Pino Toscano
ptoscano at redhat.com
Tue Aug 8 12:32:23 UTC 2017
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170808/dac51c37/attachment.sig>
More information about the Libguestfs
mailing list