[V2,4/6] Android NDK: __errno is already defined as a function

Submitted by Zhang, Ning A on April 2, 2019, 2:43 a.m.

Details

Message ID 20190402024304.9899-5-ning.a.zhang@intel.com
State Accepted
Series "patches for build CRIU with Android NDK"
Commit f4fa53cf9b0f9d828199996bcd342e12df0fed49
Headers show

Commit Message

Zhang, Ning A April 2, 2019, 2:43 a.m.
From: Zhang Ning <ning.a.zhang@intel.com>

criu/log.c:356:16: error: called object type 'int' is not a function or function pointer
        int __errno = errno;
                      ^~~~~
/root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'
                ~~~~~~~^
criu/log.c:391:2: error: called object type 'int' is not a function or function pointer
        errno =  __errno;
        ^~~~~
/root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'

in Android NDK's errno.h:

42: int* __errno(void) __attribute_const__;
43: #define errno (*__errno())

so rename __errno to _errno to pass build

Cc: Chen Hu <hu1.chen@intel.com>
Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/log.c          | 4 ++--
 test/zdtm/lib/msg.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/log.c b/criu/log.c
index 060d1ee6..edd2511c 100644
--- a/criu/log.c
+++ b/criu/log.c
@@ -353,7 +353,7 @@  static void early_vprint(const char *format, unsigned int loglevel, va_list para
 void vprint_on_level(unsigned int loglevel, const char *format, va_list params)
 {
 	int fd, size, ret, off = 0;
-	int __errno = errno;
+	int _errno = errno;
 
 	if (unlikely(loglevel == LOG_MSG)) {
 		fd = STDOUT_FILENO;
@@ -388,7 +388,7 @@  void vprint_on_level(unsigned int loglevel, const char *format, va_list params)
 	if (loglevel == LOG_ERROR)
 		log_note_err(buffer + buf_off);
 
-	errno =  __errno;
+	errno =  _errno;
 }
 
 void print_on_level(unsigned int loglevel, const char *format, ...)
diff --git a/test/zdtm/lib/msg.c b/test/zdtm/lib/msg.c
index 04cd4016..fe099407 100644
--- a/test/zdtm/lib/msg.c
+++ b/test/zdtm/lib/msg.c
@@ -40,7 +40,7 @@  void test_msg(const char *format, ...)
 	va_list arg;
 	int off = 0;
 	char buf[TEST_MSG_BUFFER_SIZE];
-	int __errno = errno;
+	int _errno = errno;
 	struct timeval tv;
 	struct tm *tm;
 
@@ -65,5 +65,5 @@  skip:
 	va_end(arg);
 
 	write(2, buf, off);
-	errno = __errno;
+	errno = _errno;
 }

Comments

Dmitry Safonov April 2, 2019, 2:45 p.m.
On Tue, 2 Apr 2019 at 03:44, <ning.a.zhang@intel.com> wrote:
>
> From: Zhang Ning <ning.a.zhang@intel.com>
>
> criu/log.c:356:16: error: called object type 'int' is not a function or function pointer
>         int __errno = errno;
>                       ^~~~~
> /root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'
>                 ~~~~~~~^
> criu/log.c:391:2: error: called object type 'int' is not a function or function pointer
>         errno =  __errno;
>         ^~~~~
> /root/android-ndk/toolchains/llvm/prebuilt/linux-x86_64//sysroot/usr/include/errno.h:43:24: note: expanded from macro 'errno'
>
> in Android NDK's errno.h:
>
> 42: int* __errno(void) __attribute_const__;
> 43: #define errno (*__errno())
>
> so rename __errno to _errno to pass build
>
> Cc: Chen Hu <hu1.chen@intel.com>
> Signed-off-by: Zhang Ning <ning.a.zhang@intel.com>
> Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>

Thanks for the improvement to the message - now we know further
why we shouldn't introduce a new __errno variable and have
a reference on the patch to describe why.

Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>

> ---
>  criu/log.c          | 4 ++--
>  test/zdtm/lib/msg.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/criu/log.c b/criu/log.c
> index 060d1ee6..edd2511c 100644
> --- a/criu/log.c
> +++ b/criu/log.c
> @@ -353,7 +353,7 @@ static void early_vprint(const char *format, unsigned int loglevel, va_list para
>  void vprint_on_level(unsigned int loglevel, const char *format, va_list params)
>  {
>         int fd, size, ret, off = 0;
> -       int __errno = errno;
> +       int _errno = errno;
>
>         if (unlikely(loglevel == LOG_MSG)) {
>                 fd = STDOUT_FILENO;
> @@ -388,7 +388,7 @@ void vprint_on_level(unsigned int loglevel, const char *format, va_list params)
>         if (loglevel == LOG_ERROR)
>                 log_note_err(buffer + buf_off);
>
> -       errno =  __errno;
> +       errno =  _errno;
>  }
>
>  void print_on_level(unsigned int loglevel, const char *format, ...)
> diff --git a/test/zdtm/lib/msg.c b/test/zdtm/lib/msg.c
> index 04cd4016..fe099407 100644
> --- a/test/zdtm/lib/msg.c
> +++ b/test/zdtm/lib/msg.c
> @@ -40,7 +40,7 @@ void test_msg(const char *format, ...)
>         va_list arg;
>         int off = 0;
>         char buf[TEST_MSG_BUFFER_SIZE];
> -       int __errno = errno;
> +       int _errno = errno;
>         struct timeval tv;
>         struct tm *tm;
>
> @@ -65,5 +65,5 @@ skip:
>         va_end(arg);
>
>         write(2, buf, off);
> -       errno = __errno;
> +       errno = _errno;
>  }
> --
> 2.20.1
>
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu