All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rajnoha <prajnoha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 4/7][retry remove] Add new "dm_device_has_holders" fn to libdm
Date: Wed, 21 Sep 2011 13:23:13 +0200	[thread overview]
Message-ID: <4E79C921.8070903@redhat.com> (raw)
In-Reply-To: <4E7890B2.9060409@redhat.com>

On 09/20/2011 03:10 PM +0100, Zdenek Kabelac wrote:
> Dne 20.9.2011 14:57, Peter Rajnoha napsal(a):
>> +	if (!(d = opendir(dir))) {
>> +		log_sys_error("opendir", dir);
>> +		return 0;
>> +	}
>> +
>> +	while ((dirent = readdir(d)))
>> +		if (strcmp(dirent->d_name, ".") && strcmp(dirent->d_name, ".."))
>> +			break;
> 
> Hmm since  readdir() may return -1 - this looks like error check is missing here

Well, this is a version of readdir that returns either NULL or a pointer to a dirent
structure - man 2 readdir vs. man 3 readdir (difference in POSIX compliance).

The POSIX version returns an error only if the DIR* stream descriptor is wrong, but
this one should be fine since we already check the error in opendir just before this
call. I think it's OK to do it this way.

Peter



      reply	other threads:[~2011-09-21 11:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 12:57 [PATCH 4/7][retry remove] Add new "dm_device_has_holders" fn to libdm Peter Rajnoha
2011-09-20 13:10 ` Zdenek Kabelac
2011-09-21 11:23   ` Peter Rajnoha [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E79C921.8070903@redhat.com \
    --to=prajnoha@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.