NetBSD Problem Report #55311
From www@netbsd.org Thu May 28 10:12:20 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id B75381A9227
for <gnats-bugs@gnats.NetBSD.org>; Thu, 28 May 2020 10:12:20 +0000 (UTC)
Message-Id: <20200528101219.B1DAE1A9247@mollari.NetBSD.org>
Date: Thu, 28 May 2020 10:12:19 +0000 (UTC)
From: rares.aioanei@gmail.com
Reply-To: rares.aioanei@gmail.com
To: gnats-bugs@NetBSD.org
Subject: compilation error (CURRENT, amd64) in /usr/src/external/bsd/ntp/dist/ntpd/ntp_refclock.c, line 1749 : format string is not a string literal
X-Send-Pr-Version: www-1.0
>Number: 55311
>Category: bin
>Synopsis: compilation error (CURRENT, amd64) in /usr/src/external/bsd/ntp/dist/ntpd/ntp_refclock.c, line 1749 : format string is not a string literal
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 28 10:15:00 +0000 2020
>Originator: Rares Aioanei
>Release: CURRENT
>Organization:
>Environment:
>Description:
Issue is with the fmt argument to vsnprintf, although the warning is totally harmless and the only reason this fails is because we compile with -Werror.
>How-To-Repeat:
try to compile today's CURRENT amd64 with clang
>Fix:
I suggest using a pragma locally inside refclock_vformat_lcode(). Not a big fan of pragmas, but in this case it is harmless. So the code would look like this :
void
refclock_vformat_lcode(
struct refclockproc * pp,
char const * fmt,
va_list va
)
{
long len;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va);
if (len <= 0)
len = 0;
else if ((size_t)len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
pp->lencode = (u_short)len;
pp->a_lastcode[len] = '\0';
/* !note! the NUL byte is needed in case vsnprintf() really fails */
#pragma clang diagnostic pop
}
The only changes are the #pragma directives, nothing else, which means no functional changes of any kind.
(Contact us)
$NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.