diff mbox series

[uclibc-ng-devel,ldso] Group conditions after `&&`

Message ID 20240728115224.725666-1-dm.chestnykh@gmail.com
State Accepted
Headers show
Series [uclibc-ng-devel,ldso] Group conditions after `&&` | expand

Commit Message

Dmitriy Chestnykh July 28, 2024, 11:52 a.m. UTC
If the conditions are not grouped we can reach
this block even if `__NR_stat` is not defined.

`defined __NR_stat && ((!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__))`
gives us false but `LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))`
may give us true. So if linux headers version is below 5.1.0 and
__NR_stat is not defined we can have compilation error

Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
---
 ldso/include/dl-syscall.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Waldemar Brodkorb Aug. 1, 2024, 1:23 p.m. UTC | #1
Hi Dmitry,
Dmitry Chestnykh wrote,

> If the conditions are not grouped we can reach
> this block even if `__NR_stat` is not defined.
> 
> `defined __NR_stat && ((!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__))`
> gives us false but `LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))`
> may give us true. So if linux headers version is below 5.1.0 and
> __NR_stat is not defined we can have compilation error
> 
> Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>

Applied and pushed, thanks,
 best regards
  Waldemar
diff mbox series

Patch

diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 9ec0eac60..180d03012 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -141,7 +141,7 @@  static __always_inline int _dl_stat(const char *file_name,
 {
 	return _dl_newfstatat(AT_FDCWD, file_name, buf, 0);
 }
-#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__)) || (LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0))
+#elif defined __NR_stat && (!defined(__UCLIBC_USE_TIME64__) || defined(__sparc__) || (LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0)))
 # define __NR__dl_stat __NR_stat
 static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
                         struct stat *, buf)