From: Eugene Syromyatnikov Date: Sat, 2 Jun 2018 16:25:56 +0000 (+0200) Subject: tests: cast printf arguments to short when %h format qualifier is used X-Git-Tag: v4.23~67 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c0c2117be0b1607ae571496bd249a6b6f06288c6;p=strace tests: cast printf arguments to short when %h format qualifier is used Reported by clang. * tests/mknod.c (main): Cast printf argument for %#03ho format to short. * tests/mknodat.c (main): Likewise. * tests/net-sockaddr.c (main): Cast printf argument for %hu format to short. * tests/semop.c (main): Likewise. --- diff --git a/tests/mknod.c b/tests/mknod.c index b3871499..4bcc2744 100644 --- a/tests/mknod.c +++ b/tests/mknod.c @@ -59,7 +59,7 @@ main(int ac, char **av) rc = call_mknod(mode, dev); printf("mknod(\"%s\", S_IFBLK|S_ISUID|S_ISGID|S_ISVTX|%#03ho" ", makedev(%u, %u)) = %ld %s (%m)\n", - sample, mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX), + sample, (short) (mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX)), major((unsigned) dev), minor((unsigned) dev), rc, errno2name()); diff --git a/tests/mknodat.c b/tests/mknodat.c index 756e2771..318dc5a6 100644 --- a/tests/mknodat.c +++ b/tests/mknodat.c @@ -59,7 +59,7 @@ main(void) rc = call_mknodat(mode, dev); printf("mknodat(-1, \"%s\", S_IFBLK|S_ISUID|S_ISGID|S_ISVTX|%#03ho" ", makedev(%u, %u)) = %ld %s (%m)\n", - sample, mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX), + sample, (short) (mode & ~(S_IFMT|S_ISUID|S_ISGID|S_ISVTX)), major((unsigned) dev), minor((unsigned) dev), rc, errno2name()); diff --git a/tests/net-sockaddr.c b/tests/net-sockaddr.c index 0e2950c1..64427d1b 100644 --- a/tests/net-sockaddr.c +++ b/tests/net-sockaddr.c @@ -456,11 +456,12 @@ check_l2(void) #ifdef HAVE_STRUCT_SOCKADDR_L2_L2_BDADDR_TYPE ", l2_bdaddr_type=0xce /* BDADDR_??? */" #endif - "}, %u) = %d EBADF (%m)\n", h_psm - 0x1001, + "}, %u) = %d EBADF (%m)\n", + (short) (h_psm - 0x1001), c_l2.l2_bdaddr.b[0], c_l2.l2_bdaddr.b[1], c_l2.l2_bdaddr.b[2], c_l2.l2_bdaddr.b[3], c_l2.l2_bdaddr.b[4], c_l2.l2_bdaddr.b[5], - h_cid - 0x40, len, ret); + (short) (h_cid - 0x40), len, ret); c_l2.l2_psm = htobs(1); c_l2.l2_cid = htobs(1); diff --git a/tests/semop.c b/tests/semop.c index 350806c5..4b14882c 100644 --- a/tests/semop.c +++ b/tests/semop.c @@ -68,7 +68,7 @@ main(void) bogus_semid, sem_b2->sem_num, sem_b2->sem_op, sem_b2->sem_flg & SEM_UNDO ? "SEM_UNDO|" : "", sem_b2->sem_flg & IPC_NOWAIT ? "IPC_NOWAIT|" : "", - sem_b2->sem_flg & ~(SEM_UNDO | IPC_NOWAIT), + (short) (sem_b2->sem_flg & ~(SEM_UNDO | IPC_NOWAIT)), sem_b2 + 1, 2, sprintrc(rc)); if (semop(id, sem_b, 1)) @@ -96,7 +96,7 @@ main(void) bogus_semid, sem_b2->sem_num, sem_b2->sem_op, sem_b2->sem_flg & SEM_UNDO ? "SEM_UNDO|" : "", sem_b2->sem_flg & IPC_NOWAIT ? "IPC_NOWAIT|" : "", - sem_b2->sem_flg & ~(SEM_UNDO | IPC_NOWAIT), + (short) (sem_b2->sem_flg & ~(SEM_UNDO | IPC_NOWAIT)), sem_b2 + 1, 2, (long long) ts->tv_sec, zero_extend_signed_to_ull(ts->tv_nsec), sprintrc(rc));