public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] misc: Suppress clang warnings on syslog Date: Tue, 2 Apr 2024 15:51:24 +0000 (GMT) [thread overview] Message-ID: <20240402155124.60A7F3858C55@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=955a1270d1d1073d88d85ac9857e636bac8fbc7c commit 955a1270d1d1073d88d85ac9857e636bac8fbc7c Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> 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 <libc-diag.h> #include <libio/libioP.h> #include <paths.h> #include <stdarg.h> @@ -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)
next reply other threads:[~2024-04-02 15:51 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-02 15:51 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 2024-04-17 20:05 Adhemerval Zanella 2024-02-09 17:29 Adhemerval Zanella 2024-02-07 14:04 Adhemerval Zanella 2024-01-29 17:55 Adhemerval Zanella 2023-12-21 18:51 Adhemerval Zanella 2023-09-28 17:49 Adhemerval Zanella 2023-08-30 12:34 Adhemerval Zanella 2023-02-09 19:46 Adhemerval Zanella 2022-10-28 17:39 Adhemerval Zanella 2022-10-04 12:57 Adhemerval Zanella 2022-06-09 21:26 Adhemerval Zanella 2022-06-09 13:23 Adhemerval Zanella 2022-06-03 14:12 Adhemerval Zanella 2022-05-13 14:26 Adhemerval Zanella 2022-05-12 19:40 Adhemerval Zanella 2022-05-10 18:30 Adhemerval Zanella 2022-04-29 14:10 Adhemerval Zanella
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240402155124.60A7F3858C55@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).