From owner-freebsd-hackers@freebsd.org Tue May 22 09:49:45 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 349EAEEF636 for ; Tue, 22 May 2018 09:49:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8711E6C487; Tue, 22 May 2018 09:49:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w4M9nXBJ033678 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 22 May 2018 12:49:36 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w4M9nXBJ033678 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w4M9nXLq033677; Tue, 22 May 2018 12:49:33 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 22 May 2018 12:49:33 +0300 From: Konstantin Belousov To: Poul-Henning Kamp Cc: Ed Schouten , FreeBSD Hackers , Dimitry Andric , Thomas Munro Subject: Re: printf("%m") doesn't generate a warning -- shouldn't it? Message-ID: <20180522094933.GC88128@kib.kiev.ua> References: <20180521134306.GT6887@kib.kiev.ua> <5221.1526981838@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5221.1526981838@critter.freebsd.dk> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2018 09:49:45 -0000 On Tue, May 22, 2018 at 09:37:18AM +0000, Poul-Henning Kamp wrote: > -------- > In message > , Ed Schouten writes: > >2018-05-21 15:43 GMT+02:00 Konstantin Belousov : > >> Why not add %m instead ? It is very easy and several people did it in > >> round-about ways. > > > >Added advantage of that approach is that it allows the syslog() > >function to be simplified significantly. No need to expand the %m > >there, which ends up being quite messy. > > We have an cleanly expandable printf implementation for exactly > this kind of stuff, so that is not really the case. > > However, expandable printf is close to useless when there is no > sane/portable way to teach compilers about new formatting arguments. Expandable printf(3) could serve a situation when application wants and implements an extenstion. It does not work, or is rather weird thing to try to make it work, when application assumes that the extension is provided by the operating system. There was at least one patch which tried to add %m as an extension, and of course the problem with this approach is that errno may be already obliterated when the format handler for %m got called.