diff mbox series

[uclibc-ng-devel,3/3] Fix some warnings due to type issues

Message ID 20211129153335.32124-3-ysionneau@kalray.eu
State Accepted
Headers show
Series [uclibc-ng-devel,1/3] kvx: fix warning about __BITS_PER_LONG not being defined | expand

Commit Message

Yann Sionneau Nov. 29, 2021, 3:33 p.m. UTC
Fixes those two warnings:

In file included from <command-line>:
libc/sysdeps/linux/common/openat64.c:18:33: warning: 'openat64' alias between functions of incompatible types 'int(int,  const char *, int,  ...)' and 'int(int,  const char *, int,  mode_t)' {aka 'int(int,  const char *, int,  unsigned int)'} [-Wattribute-alias=]
   18 | strong_alias_untyped(__openat64,openat64)
      |                                 ^~~~~~~~
./include/libc-symbols.h:177:31: note: in definition of macro '_strong_alias_untyped'
  177 |   extern __typeof (aliasname) aliasname __attribute__ ((alias (#name))) __attribute_copy__ (name);
      |                               ^~~~~~~~~
libc/sysdeps/linux/common/openat64.c:18:1: note: in expansion of macro 'strong_alias_untyped'
   18 | strong_alias_untyped(__openat64,openat64)
      | ^~~~~~~~~~~~~~~~~~~~
libc/sysdeps/linux/common/openat64.c:14:12: note: aliased declaration here
   14 | static int __openat64(int fd, const char *file, int oflag, mode_t mode)
      |            ^~~~~~~~~~

and

  CC libc/sysdeps/linux/common/stat.os
libc/sysdeps/linux/common/stat.c: In function 'stat':
libc/sysdeps/linux/common/stat.c:28:40: warning: passing argument 3 of 'fstatat64' from incompatible pointer type [-Wincompatible-pointer-types]
   28 |  return fstatat64(AT_FDCWD, file_name, buf, 0);
      |                                        ^~~
      |                                        |
      |                                        struct stat *
In file included from libc/sysdeps/linux/common/stat.c:11:
./include/sys/stat.h:258:35: note: expected 'struct stat64 * restrict' but argument is of type 'struct stat *'
  258 |         struct stat64 *__restrict __buf, int __flag)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~

Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
---
 libc/sysdeps/linux/common/openat64.c | 10 +++++++++-
 libc/sysdeps/linux/common/stat.c     |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libc/sysdeps/linux/common/openat64.c b/libc/sysdeps/linux/common/openat64.c
index eda3e7db1..cd1b23fa5 100644
--- a/libc/sysdeps/linux/common/openat64.c
+++ b/libc/sysdeps/linux/common/openat64.c
@@ -9,10 +9,18 @@ 
 #include <_lfs_64.h>
 #include <sys/syscall.h>
 #include <fcntl.h>
+#include <stdarg.h>
 
 #ifdef __NR_openat
-static int __openat64(int fd, const char *file, int oflag, mode_t mode)
+static int __openat64(int fd, const char *file, int oflag, ...)
 {
+	va_list ap;
+	mode_t mode;
+
+	va_start(ap, oflag);
+	mode = va_arg(ap, int);
+	va_end(ap);
+
 	return openat(fd, file, oflag | O_LARGEFILE, mode);
 }
 strong_alias_untyped(__openat64,openat64)
diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c
index a860c0c7f..99ce8d2dd 100644
--- a/libc/sysdeps/linux/common/stat.c
+++ b/libc/sysdeps/linux/common/stat.c
@@ -25,7 +25,7 @@  int stat(const char *file_name, struct stat *buf)
 
 int stat(const char *file_name, struct stat *buf)
 {
-	return fstatat64(AT_FDCWD, file_name, buf, 0);
+	return fstatat64(AT_FDCWD, file_name, (struct stat64 *)buf, 0);
 }
 #elif __NR_statx && defined __UCLIBC_HAVE_STATX__
 # include <fcntl.h>