public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Rahul Bedarkar <rahulbedarkar89-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/1] mmap.2: improve example
Date: Fri, 3 Jun 2016 06:55:19 -0500	[thread overview]
Message-ID: <70538406-784a-5b19-0b5e-46b9ee6182dc@gmail.com> (raw)
In-Reply-To: <CA+NV+Vn9_9eDLvNWhgH7pLFyf+Bjd-fU6Cu0POb3vF-Qb-CnTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On 06/03/2016 02:46 AM, Rahul Bedarkar wrote:
> Hello Michael,
> 
> On Fri, Jun 3, 2016 at 4:59 AM, Michael Kerrisk (man-pages)
> <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> Hello Rahul,
>>
>>
>> Given that handle_error() calls exit(), and that triggers close()
>> on all FDs and munmap() on all mappings, I'm not sure this patch
>> improves things. Can you say some more on why you think it is
>> needed?
> 
> I think it is always better to free resources after use to avoid
> memory leaks later. But doing that in such
> simple example might be debatable.

Yep.

> May be at-least at the end we should call munmap() and close(). That
> will cover munmap() usage as well.

Yes, by way of example, I think it doesn't hurt to add the munmap() 
call especially. Added.

Thanks for the input.

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2016-06-03 11:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-02 17:56 [PATCH 1/1] mmap.2: improve example Rahul Bedarkar
     [not found] ` <1464890187-4141-1-git-send-email-rahulbedarkar89-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-02 23:29   ` Michael Kerrisk (man-pages)
     [not found]     ` <06bc8862-f4b2-c024-3852-e1db3d2ae5fb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-06-03  7:46       ` Rahul Bedarkar
     [not found]         ` <CA+NV+Vn9_9eDLvNWhgH7pLFyf+Bjd-fU6Cu0POb3vF-Qb-CnTQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-06-03 11:55           ` Michael Kerrisk (man-pages) [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=70538406-784a-5b19-0b5e-46b9ee6182dc@gmail.com \
    --to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rahulbedarkar89-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox