From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46913 invoked by alias); 10 May 2018 20:59:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 46899 invoked by uid 89); 10 May 2018 20:59:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=initializing X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.160.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 20:59:09 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 604F5CCF6 for ; Thu, 10 May 2018 15:59:08 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GseZfJrjnWCOCGseZfBitd; Thu, 10 May 2018 15:59:08 -0500 X-Authority-Reason: nr=8 Received: from 97-122-176-117.hlrn.qwest.net ([97.122.176.117]:35382 helo=pokyo) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fGseY-001T8M-SP; Thu, 10 May 2018 15:59:06 -0500 From: Tom Tromey To: Simon Marchi Cc: Subject: Re: [PATCH RFC 4/5] Introduce scoped_mmapped_file References: <1525901216-15031-1-git-send-email-simon.marchi@ericsson.com> <1525901216-15031-5-git-send-email-simon.marchi@ericsson.com> Date: Thu, 10 May 2018 21:04:00 -0000 In-Reply-To: <1525901216-15031-5-git-send-email-simon.marchi@ericsson.com> (Simon Marchi's message of "Wed, 9 May 2018 17:26:55 -0400") Message-ID: <87y3grz0px.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fGseY-001T8M-SP X-Source-Sender: 97-122-176-117.hlrn.qwest.net (pokyo) [97.122.176.117]:35382 X-Source-Auth: tom+tromey.com X-Email-Count: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-05/txt/msg00267.txt.bz2 >>>>> "Simon" == Simon Marchi writes: Simon> + void reset (int new_fd) Simon> + { Simon> + destroy (); Simon> + Simon> + m_fd = new_fd; Simon> + } I was wondering if this should only destroy() when new_fd!=m_fd. That way self-resetting would not cause a bug. Simon> + /* Map FILENAME in memory. Throw an error if anything goes wrong. */ Simon> + scoped_mmapped_file (const char *filename) Simon> + { Simon> + m_fd.reset (open (filename, 0, O_RDONLY)); ... however, then I thought perhaps this question could be avoided by just initializing m_fd directly, like: scoped_mmapped_file (const char *filename) : m_fd (open (filename, 0, O_RDONLY)) Then "reset" wouldn't be needed at all. Also I think that should be "open (filename, O_RDONLY)" -- no "0, ". Tom