From: Sascha Wildner Date: Fri, 21 Dec 2018 14:14:14 +0000 (+0100) Subject: libc/sysvipc: Mark two functions as printf-like and fix resulting errors. X-Git-Tag: v5.7.0~667 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/40d436c0f5e577f14c38f477e3d8ea1842260632 libc/sysvipc: Mark two functions as printf-like and fix resulting errors. --- diff --git a/lib/libc/sysvipc/msg.c b/lib/libc/sysvipc/msg.c index a0dd533769..8f0d511eac 100644 --- a/lib/libc/sysvipc/msg.c +++ b/lib/libc/sysvipc/msg.c @@ -626,7 +626,7 @@ sysvipc_msgrcv(int msqid, void *msgp, size_t msgsz, long mtype, int msgflg) if (msgsz < msghdr->msg_ts && (msgflg & MSG_NOERROR) == 0) { sysv_print_err("first message on the queue is too big" - "(want %d, got %d)\n", + "(want %zu, got %d)\n", msgsz, msghdr->msg_ts); errno = E2BIG; goto done; @@ -659,12 +659,12 @@ sysvipc_msgrcv(int msqid, void *msgp, size_t msgsz, long mtype, int msgflg) */ if (mtype == msghdr->msg_type || msghdr->msg_type <= -mtype) { - sysv_print("found message type %d, requested %d\n", + sysv_print("found message type %ld, requested %ld\n", msghdr->msg_type, mtype); if (msgsz < msghdr->msg_ts && (msgflg & MSG_NOERROR) == 0) { sysv_print_err("requested message on the queue" - " is too big (want %d, got %d)\n", + " is too big (want %zu, got %d)\n", msgsz, msghdr->msg_ts); errno = E2BIG; goto done; @@ -697,7 +697,7 @@ sysvipc_msgrcv(int msqid, void *msgp, size_t msgsz, long mtype, int msgflg) * No message found. Does the user want to wait? */ if ((msgflg & IPC_NOWAIT) != 0) { - sysv_print_err("no appropriate message found (mtype=%d)\n", + sysv_print_err("no appropriate message found (mtype=%ld)\n", mtype); errno = ENOMSG; goto done; @@ -759,7 +759,7 @@ sysvipc_msgrcv(int msqid, void *msgp, size_t msgsz, long mtype, int msgflg) * Note that this effectively truncates the message if it is too long * (since msgsz is never increased). */ - sysv_print("found a message, msgsz=%d, msg_ts=%d\n", msgsz, + sysv_print("found a message, msgsz=%zu, msg_ts=%d\n", msgsz, msghdr->msg_ts); if (msgsz > msghdr->msg_ts) msgsz = msghdr->msg_ts; diff --git a/lib/libc/sysvipc/sem.c b/lib/libc/sysvipc/sem.c index 65f6e658ae..d8c14d46ab 100644 --- a/lib/libc/sysvipc/sem.c +++ b/lib/libc/sysvipc/sem.c @@ -124,7 +124,7 @@ mark_for_removal(int shmid) { static int try_rwlock_rdlock(int semid, struct semid_pool *semaptr) { - sysv_print(" before rd lock id = %d %x\n", semid, semaptr); + sysv_print(" before rd lock id = %d %p\n", semid, semaptr); #ifdef SYSV_RWLOCK sysv_rwlock_rdlock(&semaptr->rwlock); sysv_print("rd lock id = %d\n", semid); @@ -150,7 +150,7 @@ try_rwlock_rdlock(int semid, struct semid_pool *semaptr) { static int try_rwlock_wrlock(int semid, struct semid_pool *semaptr) { #ifdef SYSV_RWLOCK - sysv_print("before wrlock id = %d %x\n", semid, semaptr); + sysv_print("before wrlock id = %d %p\n", semid, semaptr); sysv_rwlock_wrlock(&semaptr->rwlock); #else sysv_print("before lock id = %d %x\n", semid, semaptr); @@ -174,7 +174,7 @@ try_rwlock_wrlock(int semid, struct semid_pool *semaptr) { static int rwlock_unlock(int semid, struct semid_pool *semaptr) { - sysv_print("unlock id = %d %x\n", semid, semaptr); + sysv_print("unlock id = %d %p\n", semid, semaptr); if (!sema_exist(semid, semaptr)) { /* Internal resources must be freed. */ mark_for_removal(semid); @@ -613,7 +613,7 @@ int sysvipc_semop (int semid, struct sembuf *sops, unsigned nsops) { if (nsops > MAX_SOPS) { sysv_print("too many sops (max=%d, nsops=%u)\n", - getpid(), MAX_SOPS, nsops); + MAX_SOPS, nsops); eval = E2BIG; goto done; } diff --git a/lib/libc/sysvipc/sockets.c b/lib/libc/sysvipc/sockets.c index 59e993f73b..fab2a7a6ef 100644 --- a/lib/libc/sysvipc/sockets.c +++ b/lib/libc/sysvipc/sockets.c @@ -167,8 +167,7 @@ send_fd(int sock, int fd) msg.msg_iovlen = 1; if ((n = sendmsg(sock, &msg, 0)) == -1) { - sysv_print_err("sendmsg(%d)\n", - sock, getpid()); + sysv_print_err("sendmsg(%d)\n", sock); return (-1); } if (n != sizeof(int)) { diff --git a/lib/libc/sysvipc/sysvipc_utils.h b/lib/libc/sysvipc/sysvipc_utils.h index d42e6790eb..93e30a083c 100644 --- a/lib/libc/sysvipc/sysvipc_utils.h +++ b/lib/libc/sysvipc/sysvipc_utils.h @@ -28,8 +28,10 @@ #ifndef _SYSV_UTILS_H_ #define _SYSV_UTILS_H_ +#include + /* Print wrappers. */ -void sysv_print_err(const char *fmt, ...); -void sysv_print(const char *fmt, ...); +void sysv_print_err(const char *fmt, ...) __printflike(1, 2); +void sysv_print(const char *fmt, ...) __printflike(1, 2); #endif