From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 49BA91F8C6 for ; Mon, 12 Jul 2021 21:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234947AbhGLVrv (ORCPT ); Mon, 12 Jul 2021 17:47:51 -0400 Received: from cloud.peff.net ([104.130.231.41]:47152 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbhGLVru (ORCPT ); Mon, 12 Jul 2021 17:47:50 -0400 Received: (qmail 23170 invoked by uid 109); 12 Jul 2021 21:45:01 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 12 Jul 2021 21:45:01 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 2873 invoked by uid 111); 12 Jul 2021 21:45:01 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 12 Jul 2021 17:45:01 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 12 Jul 2021 17:45:00 -0400 From: Jeff King To: "Randall S. Becker" Cc: =?utf-8?B?J8OGdmFyIEFybmZqw7Zyw7A=?= Bjarmason' , git@vger.kernel.org, 'Junio C Hamano' Subject: Re: [PATCH 6/6] git-compat-util.h: add __attribute__((printf)) to git_*printf* Message-ID: References: <012b01d7775c$2ddcca60$89965f20$@nexbridge.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <012b01d7775c$2ddcca60$89965f20$@nexbridge.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Jul 12, 2021 at 04:26:16PM -0400, Randall S. Becker wrote: > >> In practice this is redundant to the compiler's default printf format > >> checking, since we mostly (entirely?) develop and test on platforms > >> where SNPRINTF_RETURNS_BOGUS is not set. I'm doing this mainly for > >> consistency with other code, now we don't need to think about why this > >> particular case is different. > >> > >> See c4582f93a26 (Add compat/snprintf.c for systems that return bogus, > >> 2008-03-05) for the commit that added these functions. > > > >I'm slightly lukewarm on general on adding this to a compat function. > >Those are meant to be a lowest-common-denominator fallback, and we usually avoid fancy features or our usual styles there in favor of > >simplicity. > > > >I guess this probably isn't _hurting_ anything, but it makes me wonder how many systems have a broken snprintf _and_ support the > >attribute. > > NonStop does not support __attribute__ on any compiler I know of. This > appears to be a gcc extension, so compat.c would create a gcc > dependency, which is also not on the platform. snprintf is in place. We already turn __attribute__ into a noop on unsupported platforms early in git-compat-util.h (around line 443). So this would be OK, since the snprintf macro hackery is later in the file (around line 786). -Peff