!248 posix: Fix attribute access mode on getcwd [BZ #27476],Suppress -Wcast-qual warnings in bsearch

From: @liqingqing_1229
Reviewed-by: @wswsamao
Signed-off-by: @wswsamao
This commit is contained in:
openeuler-ci-bot 2021-11-16 09:33:42 +00:00 committed by Gitee
commit 36a2ba3359
3 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From a725ff1de965f4cc4f36a7e8ae795d40ca0350d7 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <jwakely@redhat.com>
Date: Wed, 19 May 2021 16:48:19 +0100
Subject: [PATCH] Suppress -Wcast-qual warnings in bsearch
The first cast to (void *) is redundant but should be (const void *)
anyway, because that's the type of the lvalue being assigned to.
The second cast is necessary and intentionally not const-correct, so
tell the compiler not to warn about it.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
---
bits/stdlib-bsearch.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h
index 4132dc6..d688ed2 100644
--- a/bits/stdlib-bsearch.h
+++ b/bits/stdlib-bsearch.h
@@ -29,14 +29,21 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
while (__l < __u)
{
__idx = (__l + __u) / 2;
- __p = (void *) (((const char *) __base) + (__idx * __size));
+ __p = (const void *) (((const char *) __base) + (__idx * __size));
__comparison = (*__compar) (__key, __p);
if (__comparison < 0)
__u = __idx;
else if (__comparison > 0)
__l = __idx + 1;
else
+#if __GNUC_PREREQ(4, 6)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
return (void *) __p;
+#if __GNUC_PREREQ(4, 6)
+# pragma GCC diagnostic pop
+#endif
}
return NULL;
--
1.8.3.1

View File

@ -65,7 +65,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 24 Release: 25
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -132,6 +132,8 @@ Patch45: elf-Avoid-deadlock-between-pthread_create-and-ctors-.patch
Patch46: ld.so-Replace-DL_RO_DYN_SECTION-with-dl_relocate_ld-.patch Patch46: ld.so-Replace-DL_RO_DYN_SECTION-with-dl_relocate_ld-.patch
Patch47: ld.so-Initialize-bootstrap_map.l_ld_readonly-BZ-2834.patch Patch47: ld.so-Initialize-bootstrap_map.l_ld_readonly-BZ-2834.patch
Patch48: Avoid-warning-overriding-recipe-for-.-tst-ro-dynamic.patch Patch48: Avoid-warning-overriding-recipe-for-.-tst-ro-dynamic.patch
Patch49: posix-Fix-attribute-access-mode-on-getcwd-BZ-27476.patch
Patch50: Suppress-Wcast-qual-warnings-in-bsearch.patch
#Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch #Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1321,6 +1323,10 @@ fi
%endif %endif
%changelog %changelog
* Mon Nov 15 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-25
- fix attribute access mode on getcwd [BZ #27476]
- supress -Wcast-qual warnings in bsearch
* Mon Nov 15 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-24 * Mon Nov 15 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-24
- elf: fix ld.so crash while loading a DSO with a read-only dynamic section - elf: fix ld.so crash while loading a DSO with a read-only dynamic section
https://sourceware.org/bugzilla/show_bug.cgi?id=28340 https://sourceware.org/bugzilla/show_bug.cgi?id=28340

View File

@ -0,0 +1,50 @@
From 433ec4f14a5753c7689c83c20c9972915c53c204 Mon Sep 17 00:00:00 2001
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Fri, 10 Sep 2021 19:39:35 +0200
Subject: [PATCH] posix: Fix attribute access mode on getcwd [BZ #27476]
There is a GNU extension that allows to call getcwd(NULL, >0). It is
described in the documentation, but also directly in the unistd.h
header, just above the declaration.
Therefore the attribute access mode added in commit 06febd8c6705
is not correct. Drop it.
---
posix/bits/unistd.h | 5 ++---
posix/unistd.h | 3 +--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h
index f083138..622adeb 100644
--- a/posix/bits/unistd.h
+++ b/posix/bits/unistd.h
@@ -199,10 +199,9 @@ __NTH (readlinkat (int __fd, const char *__restrict __path,
#endif
extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
- __THROW __wur __attr_access ((__write_only__, 1, 2));
+ __THROW __wur;
extern char *__REDIRECT_NTH (__getcwd_alias,
- (char *__buf, size_t __size), getcwd)
- __wur __attr_access ((__write_only__, 1, 2));
+ (char *__buf, size_t __size), getcwd) __wur;
extern char *__REDIRECT_NTH (__getcwd_chk_warn,
(char *__buf, size_t __size, size_t __buflen),
__getcwd_chk)
diff --git a/posix/unistd.h b/posix/unistd.h
index 3dca657..8224c5f 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -528,8 +528,7 @@ extern int fchdir (int __fd) __THROW __wur;
an array is allocated with `malloc'; the array is SIZE
bytes long, unless SIZE == 0, in which case it is as
big as necessary. */
-extern char *getcwd (char *__buf, size_t __size) __THROW __wur
- __attr_access ((__write_only__, 1, 2));
+extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
#ifdef __USE_GNU
/* Return a malloc'd string containing the current directory name.
--
1.8.3.1