From owner-svn-src-head@freebsd.org Thu Dec 17 16:22:25 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 42F6A4BC025; Thu, 17 Dec 2020 16:22:25 +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 4Cxchw6kjxz3rh6; Thu, 17 Dec 2020 16:22:24 +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 0BHGMDZJ000818 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 17 Dec 2020 18:22:16 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 0BHGMDZJ000818 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 0BHGMDdI000817; Thu, 17 Dec 2020 18:22:13 +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 18:22:13 +0200 From: Konstantin Belousov To: Jessica Clarke Cc: Mateusz Piotrowski <0mp@freebsd.org>, 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> <686CF2E6-1D3C-4A83-A323-02CD9F536675@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <686CF2E6-1D3C-4A83-A323-02CD9F536675@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: 4Cxchw6kjxz3rh6 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 16:22:25 -0000 On Thu, Dec 17, 2020 at 01:01:01PM +0000, Jessica Clarke wrote: > On 17 Dec 2020, at 12:53, Konstantin Belousov wrote: > > > > 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. > > It's not required as per the standard, but omitting it is needlessly > obfuscating it and bad practice. C lets you do a whole load of things > that are a bad idea, and whilst this one is harmless, it is nonetheless > confusing to anyone who is not intimately acquainted quirks like this > special case in the standard. Why it is bad practice ? C is a small language, and while knowing some quirks (like this one) seems to be optional, others are not. And worse, that other quirks are essential for writing correct code at all. Consequence is that ignoring details indicates insufficient knowledge of the fundamentals and lowers the trust in the provided suggestion.