From owner-svn-src-head@freebsd.org Thu Dec 17 12:53:54 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B8BEC4B6F71; Thu, 17 Dec 2020 12:53:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CxX4L3HC0z3NZ8; Thu, 17 Dec 2020 12:53:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 0BHCreMG050865 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 17 Dec 2020 14:53:43 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0BHCreMG050865 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0BHCrdpu050864; Thu, 17 Dec 2020 14:53:39 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 17 Dec 2020 14:53:38 +0200 From: Konstantin Belousov 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: References: <202012171241.0BHCfl1r008452@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202012171241.0BHCfl1r008452@repo.freebsd.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on tom.home X-Rspamd-Queue-Id: 4CxX4L3HC0z3NZ8 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2020 12:53:54 -0000 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 > +#include > +#include > + > +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 ,