From owner-freebsd-hackers@freebsd.org Mon May 21 02:38:58 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 2C929EB097D for ; Mon, 21 May 2018 02:38:58 +0000 (UTC) (envelope-from munro@penski.net) Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A357F68535 for ; Mon, 21 May 2018 02:38:57 +0000 (UTC) (envelope-from munro@penski.net) Received: by mail-wm0-x241.google.com with SMTP id a8-v6so22706557wmg.5 for ; Sun, 20 May 2018 19:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=penski-net.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=ZovT81ibI73PUgO2srKcJ3AYo5sOwrDCKn5bZ7A+Cqg=; b=YouQv/CR6ZMhqCExb7rxknjsJ8sLKFJQD/NxHB+hn1MRQKj8yVEop1Ta8krYq8YXTo 7zBCAbtBe6gC+SEpjYOUn4QVnxC9F9XSRZIBl2KhxEsB8KBauE2CmzxQYE30bdCcL+73 UNBlSTD92dS30nZb7WyPhNGmxjsj+gIiYbj6u5K3UCYUqFS4exepMV6BNY/m1uvpL3Xg +xrakaYD2lXZY5v8xfCZPfaaBKuBb157fqJfeTOSVGYy8w6CzSnftCfybos648kHjXv+ Fxh9K3fvp3kbJ+aMr7dWYcAriARP9P8Eyt3miPicj5RAPRn74Npp/H17l9Gnundd5Nu5 Fb+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=ZovT81ibI73PUgO2srKcJ3AYo5sOwrDCKn5bZ7A+Cqg=; b=seNvHbvk4fT5T06az9k4O3GdERVJK/qFLmwFoFs347pBvVs4XkWk2bd0chuoiF6BSH EsSb5eqlludNzkk3IEkKmuKmkAbubyhH2+mS/3D0R3RtGWmUqA8rtDOGpFOXzcC8vIXp 4zQ7DjtgDWRuylxmEVLyRM3WG5UkF2XXd4GkwkP+OBEv+G64ErQQVChuNTMwuOYDcDav ZI9xa7WOZv5tblUZ0krT/XflGbQgvq4We7TYSao6ppaYzKpzf/WCYMSUNhDHmiLJd+RT 072LdmYMoGILS6RG7iEfjdIywYvQz93VMd4uEmK3xqOlaeSKRhGDodkkXVaUr79Nwyor dryg== X-Gm-Message-State: ALKqPwdqia8IkCmeK6WAQS8EI56Q55ZAgtodYYOOZRZueK+Eg+ZRIcz4 uySq9eyIk52730Q/kvy+Y9+FGtk3vBQdYBeviLyNYiJY X-Google-Smtp-Source: AB8JxZp8YyXqixmyLANPS31ouHWcwU8WpsOsfZOo/ouxL1Dg8SxegW3fIG/VJ40Jeam0tK9tukcbSRarN9sic5Rtr8Y= X-Received: by 2002:a50:b706:: with SMTP id g6-v6mr21231487ede.228.1526870336236; Sun, 20 May 2018 19:38:56 -0700 (PDT) MIME-Version: 1.0 Sender: munro@penski.net Received: by 10.80.169.225 with HTTP; Sun, 20 May 2018 19:38:55 -0700 (PDT) X-Originating-IP: [121.73.38.77] From: Thomas Munro Date: Mon, 21 May 2018 14:38:55 +1200 X-Google-Sender-Auth: Qpbtg9rEk-jqYmiWodrYtzpi_RI Message-ID: Subject: printf("%m") doesn't generate a warning -- shouldn't it? To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 21 May 2018 02:38:58 -0000 Hi, As discussed on the PostgreSQL[1] and NetBSD mailing lists[2][3], syslog-like printf("%m") is a GNU extension that doesn't generate a warning from Clang or GCC on other operating systems even though when it doesn't actually work. That's because the __printf__ attribute that our __printflike macro in /usr/include/stdio.h expands to effectively means "like printf in glibc, allowing %m", not like POSIX or our actual libc which just prints out "m" when it sees it. It'd sure be nice to get a compiler warning on FreeBSD when porting software that uses that if it doesn't actually work (or ... to support it). Concretely, contrib/llvm/tools/clang/include/clang/Analysis/Analyses/FormatString.h thinks that 'm' is valid but lib/libc/stdio/vfprintf.c doesn't. Apologies if this was already discussed, it's quite hard to search for a short squiggly format control string... Thanks, [1] https://www.postgresql.org/message-id/2975.1526862605%40sss.pgh.pa.us [2] https://mail-index.netbsd.org/tech-userlevel/2015/08/21/msg009282.html [3] https://mail-index.netbsd.org/tech-userlevel/2015/10/23/msg009371.html