pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/x11/libxshmfence/files silence format string warning



details:   https://anonhg.NetBSD.org/pkgsrc/rev/138961633d71
branches:  trunk
changeset: 423669:138961633d71
user:      tnn <tnn%pkgsrc.org@localhost>
date:      Sun Feb 23 18:26:59 2020 +0000

description:
silence format string warning

diffstat:

 x11/libxshmfence/files/xshmfence_semaphore.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r 95fc7b73d6ab -r 138961633d71 x11/libxshmfence/files/xshmfence_semaphore.c
--- a/x11/libxshmfence/files/xshmfence_semaphore.c      Sun Feb 23 18:09:36 2020 +0000
+++ b/x11/libxshmfence/files/xshmfence_semaphore.c      Sun Feb 23 18:26:59 2020 +0000
@@ -159,12 +159,12 @@
        __sync_fetch_and_and(&f.triggered, 0);
        __sync_fetch_and_and(&f.waiting, 0);
        
-       lock = mksemtemp(f.lockname, sizeof(f.lockname) - 1, "/xshmfl-%i");
+       lock = mksemtemp(f.lockname, sizeof(f.lockname), "l");
        if (lock == SEM_FAILED) {
                err(EXIT_FAILURE, "xshmfence_init: sem_open");
        }
 
-       cond = mksemtemp(f.condname, sizeof(f.condname) - 1, "/xshmfc-%i");
+       cond = mksemtemp(f.condname, sizeof(f.condname), "c");
        if (cond == SEM_FAILED) {
                err(EXIT_FAILURE, "xshmfence_init: sem_open");
        }
@@ -223,13 +223,14 @@
 }
 
 static sem_t *
-mksemtemp(char *name, size_t namelen, const char *template)
+mksemtemp(char *name, size_t namelen, const char *suffix)
 {
        sem_t *ret;
        pid_t p;
        p = getpid();
        for(;;) {
-               snprintf(name, namelen, template, p);
+               if (snprintf(name, namelen, "/xshmf%s-%d", suffix, p) >= namelen)
+                       return SEM_FAILED;
                ret = sem_open(name, O_CREAT|O_EXCL, 0600, 1);
                if (ret == SEM_FAILED) {
                        if (errno == EEXIST) {



Home | Main Index | Thread Index | Old Index