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, 21 Dec 2023 18:51:43 +0000 (GMT)	[thread overview]
Message-ID: <20231221185143.DED2A3857B8B@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=41d1aa9e39c19b2bd0ab8ec91ffc5a853ba16388

commit 41d1aa9e39c19b2bd0ab8ec91ffc5a853ba16388
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 | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/misc/syslog.c b/misc/syslog.c
index 1b8cb722c5..ab1e46ff7d 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>
@@ -177,6 +178,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,
@@ -184,6 +189,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,6 +216,8 @@ __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 (buf, l + 1,
 			SYSLOG_HEADER (pri, timestamp, &msgoff, pid));
@@ -221,6 +230,7 @@ __vsyslog_internal (int pri, const char *fmt, va_list ap,
 	  __vsnprintf_internal (buf + l, bufsize - l + 1, fmt, apc,
 				mode_flags);
 	  va_end (apc);
+	  DIAG_POP_NEEDS_COMMENT_CLANG;
 	}
       else
         {
@@ -233,8 +243,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)

             reply	other threads:[~2023-12-21 18:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 18:51 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 15:51 Adhemerval Zanella
2024-02-09 17:29 Adhemerval Zanella
2024-02-07 14:04 Adhemerval Zanella
2024-01-29 17:55 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=20231221185143.DED2A3857B8B@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: link
Be 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).