diff options
author | Xi Ruoyao <xry111@mengyan1223.wang> | 2021-11-09 21:40:04 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@mengyan1223.wang> | 2021-11-14 02:32:25 +0800 |
commit | 04c5a91d068c4ca2f09c2bc206fce00db9d1790b (patch) | |
tree | 5c23604ebac352afb7ad13e079ba9d7ec65704f5 /gcc/tree-data-ref.c | |
parent | a246d7230b8f8b059b21a073e8a91c213dee9cf4 (diff) | |
download | gcc-04c5a91d068c4ca2f09c2bc206fce00db9d1790b.zip gcc-04c5a91d068c4ca2f09c2bc206fce00db9d1790b.tar.gz gcc-04c5a91d068c4ca2f09c2bc206fce00db9d1790b.tar.bz2 |
fixincludes: simplify handling for access() failure [PR21283, PR80047]
POSIX says:
On some implementations, if buf is a null pointer, getcwd() may obtain
size bytes of memory using malloc(). In this case, the pointer returned
by getcwd() may be used as the argument in a subsequent call to free().
Invoking getcwd() with buf as a null pointer is not recommended in
conforming applications.
This produces an error building GCC with --enable-werror-always:
../../../fixincludes/fixincl.c: In function ‘process’:
../../../fixincludes/fixincl.c:1356:7: error: argument 1 is null but
the corresponding size argument 2 value is 4096 [-Werror=nonnull]
It's suggested by POSIX to call getcwd() with progressively larger
buffers until it does not give an [ERANGE] error. However, it's highly
unlikely that this error-handling route is ever used.
So we can simplify it instead of writting too much code. We give up to
use getcwd(), because `make` will output a `Leaving directory ...` message
containing the path to cwd when we call abort().
fixincludes/ChangeLog:
PR other/21823
PR bootstrap/80047
* fixincl.c (process): Simplify the handling for highly
unlikely access() failure, to avoid using non-standard
extensions.
Diffstat (limited to 'gcc/tree-data-ref.c')
0 files changed, 0 insertions, 0 deletions