linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Shipp <ns@segbrk.com>
To: mtk.manpages@gmail.com
Cc: linux-man@vger.kernel.org
Subject: [patch] inotify.7: Merge late perror() into fprintf()
Date: Mon, 20 Jan 2020 11:58:44 -0500	[thread overview]
Message-ID: <CADjEuPv0ujm9hsvrou2giOeqzZNyKN+vWuHgudvcNNs-ffwCFA@mail.gmail.com> (raw)

fprintf may have overridden errno before perror could print it in this
example.
---
 man7/inotify.7 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/man7/inotify.7 b/man7/inotify.7
index c052acfe6..995a3116f 100644
--- a/man7/inotify.7
+++ b/man7/inotify.7
@@ -1045,8 +1045,8 @@ main(int argc, char* argv[])
         wd[i] = inotify_add_watch(fd, argv[i],
                                   IN_OPEN | IN_CLOSE);
         if (wd[i] == \-1) {
-            fprintf(stderr, "Cannot watch '%s'\en", argv[i]);
-            perror("inotify_add_watch");
+            fprintf(stderr, "Cannot watch '%s': %s\en",
+                    argv[i], strerror(errno));
             exit(EXIT_FAILURE);
         }
     }
--
2.25.0

             reply	other threads:[~2020-01-20 16:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 16:58 Nick Shipp [this message]
2020-01-21 19:46 ` [patch] inotify.7: Merge late perror() into fprintf() Michael Kerrisk (man-pages)

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=CADjEuPv0ujm9hsvrou2giOeqzZNyKN+vWuHgudvcNNs-ffwCFA@mail.gmail.com \
    --to=ns@segbrk.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).