From patchwork Tue Jan 6 13:10:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 4521 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Received: (qmail 10108 invoked by alias); 6 Jan 2015 13:10:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 10093 invoked by uid 89); 6 Jan 2015 13:10:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e24smtp05.br.ibm.com Message-ID: <54ABDECE.3030306@linux.vnet.ibm.com> Date: Tue, 06 Jan 2015 11:10:38 -0200 From: Adhemerval Zanella User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: "GNU C. Library" Subject: [PATCH] powerpc: Fix compiler warning on some syscalls X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15010613-0033-0000-0000-000001758017 GCC 5.0 emits an warning when using sizeof on array function parameters and powerpc internal syscall macros add an check for such cases. More specifically, on powerpc64 and powerpc32 sysdep.h: if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \ __illegally_sized_syscall_arg3 (); \ And for sysdeps/unix/sysv/linux/utimensat.c build GCC emits: error: ‘sizeof’ on array function parameter ‘tsp’ will return size of ‘const struct timespec *’ This patch adds explicit casts to struct pointers to avoid the warnings. Checked on powerpc64 and powerpc32. Ok to push? PS: it turned out my earlier checks were incorrect and I didn't see the issue when I updated my GCC because I used --disable-werror. --- * sysdeps/unix/sysv/linux/futimens.c (futimens): Cast timespec struct argument to pointer. * sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise. * sysdeps/unix/sysv/linux/futimesat.c (futimesat): Cast timeval struct argument to pointer. * sysdeps/unix/sysv/linux/utimes.c (__utimeS): Likewise. -- diff --git a/sysdeps/unix/sysv/linux/futimens.c b/sysdeps/unix/sysv/linux/futimens.c index c7d03a8..c0e7219 100644 --- a/sysdeps/unix/sysv/linux/futimens.c +++ b/sysdeps/unix/sysv/linux/futimens.c @@ -37,7 +37,11 @@ futimens (int fd, const struct timespec tsp[2]) __set_errno (EBADF); return -1; } - return INLINE_SYSCALL (utimensat, 4, fd, NULL, tsp, 0); + /* Some archs (powerpc) add arguments type and size check using sizeof + and without a cast the compiler might emit an warning about using + sizeof on a struct (where the builtin returns the pointer size). */ + return INLINE_SYSCALL (utimensat, 4, fd, NULL, (const struct timespec*)tsp, + 0); #else __set_errno (ENOSYS); return -1; diff --git a/sysdeps/unix/sysv/linux/futimesat.c b/sysdeps/unix/sysv/linux/futimesat.c index ac96e2a..f7d5645 100644 --- a/sysdeps/unix/sysv/linux/futimesat.c +++ b/sysdeps/unix/sysv/linux/futimesat.c @@ -28,13 +28,13 @@ /* Change the access time of FILE relative to FD to TVP[0] and the modification time of FILE to TVP[1]. */ int -futimesat (fd, file, tvp) - int fd; - const char *file; - const struct timeval tvp[2]; +futimesat (int fd, const char *file, const struct timeval tvp[2]) { if (file == NULL) return __futimes (fd, tvp); - return INLINE_SYSCALL (futimesat, 3, fd, file, tvp); + /* Some archs (powerpc) add arguments type and size check using sizeof + and without a cast the compiler might emit an warning about using + sizeof on a struct (where the builtin returns the pointer size). */ + return INLINE_SYSCALL (futimesat, 3, fd, file, (const struct timeval*)tvp); } diff --git a/sysdeps/unix/sysv/linux/utimensat.c b/sysdeps/unix/sysv/linux/utimensat.c index 5a5dec7..7448688 100644 --- a/sysdeps/unix/sysv/linux/utimensat.c +++ b/sysdeps/unix/sysv/linux/utimensat.c @@ -35,7 +35,11 @@ utimensat (int fd, const char *file, const struct timespec tsp[2], return -1; } #ifdef __NR_utimensat - return INLINE_SYSCALL (utimensat, 4, fd, file, tsp, flags); + /* Some archs (powerpc) add arguments type and size check using sizeof + and without a cast the compiler might emit an warning about using + sizeof on a struct (where the builtin returns the pointer size). */ + return INLINE_SYSCALL (utimensat, 4, fd, file, (const struct timespec*)tsp, + flags); #else __set_errno (ENOSYS); return -1; diff --git a/sysdeps/unix/sysv/linux/utimes.c b/sysdeps/unix/sysv/linux/utimes.c index 5423ff2..57c04f9 100644 --- a/sysdeps/unix/sysv/linux/utimes.c +++ b/sysdeps/unix/sysv/linux/utimes.c @@ -29,7 +29,10 @@ int __utimes (const char *file, const struct timeval tvp[2]) { - return INLINE_SYSCALL (utimes, 2, file, tvp); + /* Some archs (powerpc) add arguments type and size check using sizeof + and without a cast the compiler might emit an warning about using + sizeof on a struct (where the builtin returns the pointer size). */ + return INLINE_SYSCALL (utimes, 2, file, (const struct timeval*)tvp); } weak_alias (__utimes, utimes)