mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
This is an update to one of Red Hat's patches. The strdup change is from CentOS: https://git.centos.org/rpms/ksh/blob/c8s/f/SOURCES/ksh-20120801-annocheck.patch The reason why gcc (and also clang) optimize out the null check is because the glibc string.h header gives 's' a nonnull attribute (in other words, this is a glibc compatibility bug, not a compiler bug). Clang gives the following informative warning when compiling strdup: > /home/johno/GitRepos/KornShell/ksh/src/lib/libast/string/strdup.c:66:10: warning: nonnull parameter 's' will evaluate to 'true' on > return (s && (t = oldof(0, char, n = strlen(s) + 1, 0))) ? (char*)memcpy(t, s, n) : (char*)0; > ^ ~~ > /usr/include/string.h:172:35: note: declared 'nonnull' here > __THROW __attribute_malloc__ __nonnull ((1)); > ^ > /usr/include/sys/cdefs.h:303:44: note: expanded from macro '__nonnull' > # define __nonnull(params) __attribute__ ((__nonnull__ params)) The proper fix is to rename the function in strdup.c to '_ast_strdup'. This avoids the string.h conflict and fixes the Red Hat bug. I've also made a similar change to getopt.c, since clang was throwing a nonnull warning there as well. src/lib/libast/features/map.c (which generates FEATURE/map which is indirectly included by everything) is updated to always map getopt to _ast_getopt and strdup to _ast_strdup. |
||
|---|---|---|
| .. | ||
| cmd | ||
| lib | ||
| Mamfile | ||