public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix -Wformat-length warning in tst-setgetname.c
@ 2016-10-24 16:08 Steve Ellcey
  2016-10-24 16:32 ` Florian Weimer
  2016-12-13  0:11 ` Tolga Dalman
  0 siblings, 2 replies; 3+ messages in thread
From: Steve Ellcey @ 2016-10-24 16:08 UTC (permalink / raw)
  To: libc-alpha

Here is another patch to fix a new warning (-Wformat-length) coming
from GCC 7.0.  If GCC thinks an snprintf might overrun the buffer being
written to, it gives a warning.  This patch increases the buffer size
so that the warning is no longer given.

OK to checkin?

Steve Ellcey
sellcey@caviumnetworks.com


2016-10-24  Steve Ellcey  <sellcey@caviumnetworks.com>

	* sysdeps/unix/sysv/linux/tst-setgetname.c: Increase buffer size.


diff --git a/sysdeps/unix/sysv/linux/tst-setgetname.c b/sysdeps/unix/sysv/linux/
tst-setgetname.c
index f490d83..30fbe4e 100644
--- a/sysdeps/unix/sysv/linux/tst-setgetname.c
+++ b/sysdeps/unix/sysv/linux/tst-setgetname.c
@@ -56,7 +56,7 @@ get_self_comm (long tid, char *buf, size_t len)
 {
   int res = 0;
 #define FMT "/proc/self/task/%lu/comm"
-  char fname[sizeof (FMT) + 8];
+  char fname[sizeof (FMT) + 32];
   sprintf (fname, FMT, (unsigned long) tid);
 
   int fd = open (fname, O_RDONLY);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix -Wformat-length warning in tst-setgetname.c
  2016-10-24 16:08 [PATCH] Fix -Wformat-length warning in tst-setgetname.c Steve Ellcey
@ 2016-10-24 16:32 ` Florian Weimer
  2016-12-13  0:11 ` Tolga Dalman
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2016-10-24 16:32 UTC (permalink / raw)
  To: Steve Ellcey, libc-alpha

On 10/24/2016 06:07 PM, Steve Ellcey wrote:
> 2016-10-24  Steve Ellcey  <sellcey@caviumnetworks.com>
>
> 	* sysdeps/unix/sysv/linux/tst-setgetname.c: Increase buffer size.

Okay.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix -Wformat-length warning in tst-setgetname.c
  2016-10-24 16:08 [PATCH] Fix -Wformat-length warning in tst-setgetname.c Steve Ellcey
  2016-10-24 16:32 ` Florian Weimer
@ 2016-12-13  0:11 ` Tolga Dalman
  1 sibling, 0 replies; 3+ messages in thread
From: Tolga Dalman @ 2016-12-13  0:11 UTC (permalink / raw)
  To: Steve Ellcey, libc-alpha

Hi Steve,

nice catch! Your fix is ok -- nitpicking now.

>  #define FMT "/proc/self/task/%lu/comm"
> -  char fname[sizeof (FMT) + 8];
> +  char fname[sizeof (FMT) + 32];

+ 20 is sufficient. (actually 20 - sizeof("%lu"))

>    sprintf (fname, FMT, (unsigned long) tid);

suggest to use snprintf instead.

Thanks
Tolga

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-13  0:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24 16:08 [PATCH] Fix -Wformat-length warning in tst-setgetname.c Steve Ellcey
2016-10-24 16:32 ` Florian Weimer
2016-12-13  0:11 ` Tolga Dalman

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).