From: Yury Norov <ynorov@caviumnetworks.com>
To: <libc-alpha@sourceware.org>
Cc: Yury Norov <ynorov@caviumnetworks.com>
Subject: [RFC PATCH] __fxstat: replace if() with #if when checking version
Date: Tue, 06 Sep 2016 12:55:00 -0000 [thread overview]
Message-ID: <1473166521-24827-1-git-send-email-ynorov@caviumnetworks.com> (raw)
__fxstat() is always passed with _STAT_VER as vers parameter and it's
in internal namespace.
It means we can replace runtime argument check with compile-time #ifdef.
It helps to make the body of _fxstat() smaller, and suppresses errors
if struct kernel_stat or __xstat_conv() is not declared, when they
are not needed.
If patch is found reasonable, I can check and fix other platforms and
stat syscalls. Could someone explain me, what for we need 'vers',
if we pass it with the only value everywhere. Maybe it's time to remove it
completely?
* sysdeps/unix/sysv/linux/fxstat.c: Replace if() with #if
when checking version
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
sysdeps/unix/sysv/linux/fxstat.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/fxstat.c b/sysdeps/unix/sysv/linux/fxstat.c
index e33023b..2e79f8b 100644
--- a/sysdeps/unix/sysv/linux/fxstat.c
+++ b/sysdeps/unix/sysv/linux/fxstat.c
@@ -35,20 +35,22 @@
int
__fxstat (int vers, int fd, struct stat *buf)
{
- if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (fstat, 2, fd, buf);
+#if _STAT_VER == _STAT_VER_KERNEL
+ return INLINE_SYSCALL (fstat, 2, fd, buf);
+#else
-#ifdef STAT_IS_KERNEL_STAT
+# ifdef STAT_IS_KERNEL_STAT
return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-#else
+# else
struct kernel_stat kbuf;
int result;
result = INLINE_SYSCALL (fstat, 2, fd, &kbuf);
if (result == 0)
- result = __xstat_conv (vers, &kbuf, buf);
+ result = __xstat_conv (_STAT_VER, &kbuf, buf);
return result;
+# endif
#endif
}
--
2.7.4
next reply other threads:[~2016-09-06 12:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 12:55 Yury Norov [this message]
2016-09-06 13:09 ` Andreas Schwab
2016-09-06 15:59 ` Yury Norov
2016-09-06 16:06 ` Yury Norov
2016-09-06 16:47 ` Zack Weinberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473166521-24827-1-git-send-email-ynorov@caviumnetworks.com \
--to=ynorov@caviumnetworks.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).