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: Thu, 12 May 2022 19:40:11 +0000 (GMT) [thread overview] Message-ID: <20220512194011.EE2A0383542B@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3c9c183dcbae6999861a0f3493d83dd1ad3abb21 commit 3c9c183dcbae6999861a0f3493d83dd1ad3abb21 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Fri Apr 29 10:50:13 2022 -0300 misc: Suppress clang warnings on syslog Diff: --- misc/syslog.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/misc/syslog.c b/misc/syslog.c index a1b67f6527..b217ef007d 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> @@ -175,6 +176,10 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, #define SYSLOG_HEADER_WITHOUT_TS(__pri, __msgoff) \ "<%d>: %n", __pri, __msgoff + /* 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"); int l; if (has_ts) l = __snprintf (bufs, sizeof bufs, @@ -182,6 +187,8 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, else l = __snprintf (bufs, sizeof bufs, SYSLOG_HEADER_WITHOUT_TS (pri, &msgoff)); + DIAG_POP_NEEDS_COMMENT_CLANG; + if (0 <= l && l < sizeof bufs) { va_list apc; @@ -209,12 +216,15 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap, /* Tell the cancellation handler to free this buffer. */ clarg.buf = buf; + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wstring-plus-int"); if (has_ts) __snprintf (bufs, sizeof bufs, SYSLOG_HEADER (pri, timestamp, &msgoff, pid)); else __snprintf (bufs, sizeof bufs, SYSLOG_HEADER_WITHOUT_TS (pri, &msgoff)); + DIAG_POP_NEEDS_COMMENT_CLANG; } else { @@ -227,8 +237,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:[~2022-05-12 19:40 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-12 19:40 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 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-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=20220512194011.EE2A0383542B@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).