Linux-man Archive on lore.kernel.org
 help / color / Atom feed
* [patch] inotify.7: Merge late perror() into fprintf()
@ 2020-01-20 16:58 Nick Shipp
  2020-01-21 19:46 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Shipp @ 2020-01-20 16:58 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] inotify.7: Merge late perror() into fprintf()
  2020-01-20 16:58 [patch] inotify.7: Merge late perror() into fprintf() Nick Shipp
@ 2020-01-21 19:46 ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-01-21 19:46 UTC (permalink / raw)
  To: Nick Shipp; +Cc: mtk.manpages, linux-man

Hello Nick,

On 1/20/20 5:58 PM, Nick Shipp wrote:
> fprintf may have overridden errno before perror could print it in this
> example.

Thanks. Patch applied.

Cheers,

Michael

> ---
>  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
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 16:58 [patch] inotify.7: Merge late perror() into fprintf() Nick Shipp
2020-01-21 19:46 ` Michael Kerrisk (man-pages)

Linux-man Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-man/0 linux-man/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-man linux-man/ https://lore.kernel.org/linux-man \
		linux-man@vger.kernel.org
	public-inbox-index linux-man

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-man


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git