summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authordumbbell <dumbbell@FreeBSD.org>2012-04-30 11:28:17 +0000
committerdumbbell <dumbbell@FreeBSD.org>2012-04-30 11:28:17 +0000
commit06fcd8e3650f3af601351d654aa343bf915496f2 (patch)
tree148ec2f8f1b6360bd4088be9bfaee7cad80331ac /lib/libc
parentb600972ec65464e2b002beea0ad6e80c5fd11ef1 (diff)
downloadFreeBSD-src-06fcd8e3650f3af601351d654aa343bf915496f2.zip
FreeBSD-src-06fcd8e3650f3af601351d654aa343bf915496f2.tar.gz
Remove incorrect __restrict qualifier on several pointers
The typical case was: static __inline int convert_ccl(FILE *fp, char * __restrict p, [...]) { [...] if (p == SUPPRESS_PTR) { [...] } else { [...] } [...] } This qualifier says that the pointer is the only one at that time pointing to the resource. Here, clang considers that "p" will never match "SUPPRESS_PTR" and optimize the if{} block out. This leads to segfaults in programs calling vfscanf(3) and vfwscanf(3) with just the format string (no arguments following it). The following softwares were reported to abort with segmentation fault and this patch fixes it: o cmake o smartd o devel/ORBit2 dim@ opened an LLVM PR to discuss this clang optimization: http://llvm.org/bugs/show_bug.cgi?id=12656 Tested by: bsam@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdio/vfscanf.c10
-rw-r--r--lib/libc/stdio/vfwscanf.c8
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 4fe40e3..8f9d3d0 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -125,7 +125,7 @@ static const mbstate_t initial_mbs;
*/
static __inline int
-convert_char(FILE *fp, char * __restrict p, int width)
+convert_char(FILE *fp, char * p, int width)
{
int n;
@@ -151,7 +151,7 @@ convert_char(FILE *fp, char * __restrict p, int width)
return (sum);
} else {
size_t r = __fread(p, 1, width, fp);
-
+
if (r == 0)
return (-1);
return (r);
@@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, int width, locale_t locale)
}
static __inline int
-convert_ccl(FILE *fp, char * __restrict p, int width, const char *ccltab)
+convert_ccl(FILE *fp, char * p, int width, const char *ccltab)
{
char *p0;
int n;
@@ -249,7 +249,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab,
}
static __inline int
-convert_string(FILE *fp, char * __restrict p, int width)
+convert_string(FILE *fp, char * p, int width)
{
char *p0;
int n;
@@ -387,7 +387,7 @@ parseint(FILE *fp, char * __restrict buf, int width, int base, int flags)
goto ok;
}
break;
-
+
/*
* x ok iff flag still set & 2nd char (or 3rd char if
* we have a sign).
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index c542084..28e2c03 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -138,7 +138,7 @@ static const mbstate_t initial_mbs;
*/
static __inline int
-convert_char(FILE *fp, char * __restrict mbp, int width, locale_t locale)
+convert_char(FILE *fp, char * mbp, int width, locale_t locale)
{
mbstate_t mbs;
size_t nconv;
@@ -179,7 +179,7 @@ convert_wchar(FILE *fp, wchar_t *wcp, int width, locale_t locale)
}
static __inline int
-convert_ccl(FILE *fp, char * __restrict mbp, int width, const struct ccl *ccl,
+convert_ccl(FILE *fp, char * mbp, int width, const struct ccl *ccl,
locale_t locale)
{
mbstate_t mbs;
@@ -237,7 +237,7 @@ convert_wccl(FILE *fp, wchar_t *wcp, int width, const struct ccl *ccl,
}
static __inline int
-convert_string(FILE *fp, char * __restrict mbp, int width, locale_t locale)
+convert_string(FILE *fp, char * mbp, int width, locale_t locale)
{
mbstate_t mbs;
size_t nconv;
@@ -372,7 +372,7 @@ parseint(FILE *fp, wchar_t *buf, int width, int base, int flags,
goto ok;
}
break;
-
+
/*
* x ok iff flag still set & 2nd char (or 3rd char if
* we have a sign).
OpenPOWER on IntegriCloud