From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 60A7F3858C55; Tue, 2 Apr 2024 15:51:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60A7F3858C55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712073084; bh=Yvmj686qSryfJdvTWhUeMyVubRmtbdh2B6l4D725jcE=; h=From:To:Subject:Date:From; b=lCLFZeggZ1shkR+WyiOUAQkxsLsE0u5atUBWE6xPU7NuGxTGzg0E6BA5o4xIta7zr 7xSZSo2b6EcCiRBd6E3ATwKwKQRvtUIIpa4iYYzFHRYfPQCgSxZ5w2qDPnXUVU1erl tal4zS4NfgyoIB1fKgjK/39Snt66GaK/QP4dy+8I= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] misc: Suppress clang warnings on syslog X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: c9737138cfba4ff301f545bc638e15fe7ada197e X-Git-Newrev: 955a1270d1d1073d88d85ac9857e636bac8fbc7c Message-Id: <20240402155124.60A7F3858C55@sourceware.org> Date: Tue, 2 Apr 2024 15:51:24 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=955a1270d1d1073d88d85ac9857e636bac8fbc7c commit 955a1270d1d1073d88d85ac9857e636bac8fbc7c Author: Adhemerval Zanella Date: Fri Apr 29 10:50:13 2022 -0300 misc: Suppress clang warnings on syslog clang complains that adding a 'int_t' to a string does not append to it, but the idea is to print the pid conditionally. Diff: --- misc/syslog.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/misc/syslog.c b/misc/syslog.c index 4af87f54fd..4186292b24 100644 --- a/misc/syslog.c +++ b/misc/syslog.c @@ -31,6 +31,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94"; #endif /* LIBC_SCCS and not lint */ +#include #include #include #include @@ -181,8 +182,15 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, int l, vl; if (has_ts) - l = __snprintf (bufs, sizeof bufs, - SYSLOG_HEADER (pri, timestamp, &msgoff, pid)); + { + /* clang complains that adding a 'int_t' to a string does not append to + it, but the idea is to print the pid conditionally. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int"); + l = __snprintf (bufs, sizeof bufs, + SYSLOG_HEADER (pri, timestamp, &msgoff, pid)); + DIAG_POP_NEEDS_COMMENT_CLANG; + } else l = __snprintf (bufs, sizeof bufs, SYSLOG_HEADER_WITHOUT_TS (pri, &msgoff)); @@ -239,8 +247,13 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, int cl; if (has_ts) - cl = __snprintf (buf, l + 1, - SYSLOG_HEADER (pri, timestamp, &msgoff, pid)); + { + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int"); + cl = __snprintf (buf, l + 1, + SYSLOG_HEADER (pri, timestamp, &msgoff, pid)); + DIAG_POP_NEEDS_COMMENT_CLANG; + } else cl = __snprintf (buf, l + 1, SYSLOG_HEADER_WITHOUT_TS (pri, &msgoff)); @@ -273,8 +286,13 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, /* Output to stderr if requested. */ if (LogStat & LOG_PERROR) - __dprintf (STDERR_FILENO, "%s%s", buf + msgoff, - "\n" + (buf[bufsize - 1] == '\n')); + { + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int"); + __dprintf (STDERR_FILENO, "%s%s", buf + msgoff, + "\n" + (buf[bufsize - 1] == '\n')); + DIAG_POP_NEEDS_COMMENT_CLANG; + } /* Get connected, output the message to the local logger. */ if (!connected)