Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Dec 2020 14:53:38 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mateusz Piotrowski <0mp@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r368714 - head/lib/libc/string
Message-ID:  <X9tU0kTm9V6KoCRr@kib.kiev.ua>
In-Reply-To: <202012171241.0BHCfl1r008452@repo.freebsd.org>
References:  <202012171241.0BHCfl1r008452@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 17, 2020 at 12:41:47PM +0000, Mateusz Piotrowski wrote:
> Author: 0mp (doc,ports committer)
> Date: Thu Dec 17 12:41:47 2020
> New Revision: 368714
> URL: https://svnweb.freebsd.org/changeset/base/368714
> 
> Log:
>   strerror.3: Add an example for perror()
>   
>   This is a nice and quick reference.
>   
>   Reviewed by:	jilles, yuripv
>   MFC after:	2 weeks
>   Differential Revision:	https://reviews.freebsd.org/D27623
> 
> Modified:
>   head/lib/libc/string/strerror.3
> 
> Modified: head/lib/libc/string/strerror.3
> ==============================================================================
> --- head/lib/libc/string/strerror.3	Thu Dec 17 03:42:54 2020	(r368713)
> +++ head/lib/libc/string/strerror.3	Thu Dec 17 12:41:47 2020	(r368714)
> @@ -32,7 +32,7 @@
>  .\"     @(#)strerror.3	8.1 (Berkeley) 6/9/93
>  .\" $FreeBSD$
>  .\"
> -.Dd December 7, 2020
> +.Dd December 17, 2020
>  .Dt STRERROR 3
>  .Os
>  .Sh NAME
> @@ -170,6 +170,31 @@ The use of these variables is deprecated;
>  or
>  .Fn strerror_r
>  should be used instead.
> +.Sh EXAMPLES
> +The following example shows how to use
> +.Fn perror
> +to report an error.
> +.Bd -literal -offset 2n
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +int
> +main(void)
> +{
> +	int fd;
> +
> +	if ((fd = open("/nonexistent", O_RDONLY)) == -1) {
> +		perror("open()");
> +		exit(1);
> +	}
> +        printf("File descriptor: %d\en", fd);
This lines is indented with spaces, while other lines have tabs.

> +	return (0);
return (0) is redundand.

> +}
> +.Ed
> +.Pp
> +When executed, the program will print an error message along the lines of
> +.Ql "open(): No such file or directory" .
>  .Sh SEE ALSO
>  .Xr intro 2 ,
>  .Xr err 3 ,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?X9tU0kTm9V6KoCRr>