FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 11-23-2011, 09:15 AM
"Fabio M. Di Nitto"
 
Default libcman: fix fd usage

Spotted by Coverity Scan

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
:100644 100644 9ea82c1... 46f5c89... M cman/lib/libcman.c
cman/lib/libcman.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
index 9ea82c1..46f5c89 100644
--- a/cman/lib/libcman.c
+++ b/cman/lib/libcman.c
@@ -318,8 +318,8 @@ static cman_handle_t open_socket(const char *name, int namelen, void *privdata)
free(h);
h = NULL;
errno = saved_errno;
- }
- fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */
+ } else
+ fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */

return (cman_handle_t)h;
}
--
1.7.4.4
 
Old 11-23-2011, 09:32 AM
Steven Whitehouse
 
Default libcman: fix fd usage

Hi,

On Wed, 2011-11-23 at 11:15 +0100, Fabio M. Di Nitto wrote:
> Spotted by Coverity Scan
>
> Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
> ---
> :100644 100644 9ea82c1... 46f5c89... M cman/lib/libcman.c
> cman/lib/libcman.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
> index 9ea82c1..46f5c89 100644
> --- a/cman/lib/libcman.c
> +++ b/cman/lib/libcman.c
> @@ -318,8 +318,8 @@ static cman_handle_t open_socket(const char *name, int namelen, void *privdata)
> free(h);
> h = NULL;
> errno = saved_errno;
> - }
> - fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */
> + } else
> + fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */
FD_CLOEXEC would be a bit clearer than 1, even with the comment. Also
its normal to do a F_GETFD first and OR the new flag so that you don't
accidentally reset any other flags that are set on the fd beforehand.
I'm not sure whether that makes sense in this particular case though,

Steve.

>
> return (cman_handle_t)h;
> }
 
Old 11-23-2011, 09:46 AM
"Fabio M. Di Nitto"
 
Default libcman: fix fd usage

On 11/23/2011 11:32 AM, Steven Whitehouse wrote:
> Hi,
>
> On Wed, 2011-11-23 at 11:15 +0100, Fabio M. Di Nitto wrote:
>> Spotted by Coverity Scan
>>
>> Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
>> ---
>> :100644 100644 9ea82c1... 46f5c89... M cman/lib/libcman.c
>> cman/lib/libcman.c | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
>> index 9ea82c1..46f5c89 100644
>> --- a/cman/lib/libcman.c
>> +++ b/cman/lib/libcman.c
>> @@ -318,8 +318,8 @@ static cman_handle_t open_socket(const char *name, int namelen, void *privdata)
>> free(h);
>> h = NULL;
>> errno = saved_errno;
>> - }
>> - fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */
>> + } else
>> + fcntl(h->zero_fd, F_SETFD, 1); /* Set close-on-exec */
> FD_CLOEXEC would be a bit clearer than 1, even with the comment. Also
> its normal to do a F_GETFD first and OR the new flag so that you don't
> accidentally reset any other flags that are set on the fd beforehand.
> I'm not sure whether that makes sense in this particular case though,
>
> Steve.


Good catch... will change that for final submission

Fabio
 

Thread Tools




All times are GMT. The time now is 10:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org