about summary refs log tree commit diff
path: root/io
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-05-25 14:41:55 +0000
committerUlrich Drepper <drepper@redhat.com>2007-05-25 14:41:55 +0000
commit47ad95ab96a69424d2291714ebe99f1eb87057da (patch)
tree421aecd3cba6abd7936db924fadf565f70a3f79a /io
parent86acd5963441f4bfc087ceca8c30f8d72c6a5fa6 (diff)
downloadglibc-47ad95ab96a69424d2291714ebe99f1eb87057da.tar.gz
glibc-47ad95ab96a69424d2291714ebe99f1eb87057da.tar.xz
glibc-47ad95ab96a69424d2291714ebe99f1eb87057da.zip
* io/bits/fcntl2.h (__open_2): Add nonnull attribute.
	(open): Fix comment typos.  Don't call __open_2 if flags
	is a compile time constant without O_CREAT.
	(__open64_2): Add nonnull attribute.
	(open64): Fix comment typos.  Don't call __open64_2 if flags
	is a compile time constant without O_CREAT.
	(__openat_2): Add nonnull attribute, fix nonnull attribute
	on redirect.
	(openat): Fix comment typos.  Don't call __openat_2 if flags
	is a compile time constant without O_CREAT.
	(__openat64_2): Add nonnull attribute, fix nonnull attribute
	on redirect.
	(openat64): Fix comment typos.  Don't call __openat64_2 if flags
	is a compile time constant without O_CREAT.
Diffstat (limited to 'io')
-rw-r--r--io/bits/fcntl2.h74
1 files changed, 48 insertions, 26 deletions
diff --git a/io/bits/fcntl2.h b/io/bits/fcntl2.h
index 25ca4110b3..a1b03f6194 100644
--- a/io/bits/fcntl2.h
+++ b/io/bits/fcntl2.h
@@ -24,7 +24,7 @@
 /* Check that calls to open and openat with O_CREAT set have an
    appropriate third/fourth parameter.  */
 #ifndef __USE_FILE_OFFSET64
-extern int __open_2 (__const char *__path, int __oflag);
+extern int __open_2 (__const char *__path, int __oflag) __nonnull ((1));
 #else
 extern int __REDIRECT (__open_2, (__const char *__file, int __oflag),
 		       __open64_2) __nonnull ((1));
@@ -33,22 +33,27 @@ extern int __REDIRECT (__open_2, (__const char *__file, int __oflag),
 #define open(fname, flags, ...) \
   ({ int ___r;								      \
      /* If the compiler complains about an invalid type, excess elements, etc \
-	in the initialization this means a paraleter of the wrong type has    \
+	in the initialization this means a parameter of the wrong type has    \
 	been passed to open. */						      \
      int ___arr[] = { __VA_ARGS__ };					      \
      if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0)	      \
        {								      \
-	 /* If the compile complains about the size of this array type the    \
-	    the mode parameter is missing since O_CREAT has been used.  */    \
+	 /* If the compiler complains about the size of this array type the   \
+	    mode parameter is missing since O_CREAT has been used.  */	      \
 	 typedef int __open_missing_mode[((flags) & O_CREAT) != 0	      \
 					 ? ((long int) sizeof (___arr)	      \
 					    - (long int) sizeof (int)) : 1];  \
        }								      \
      if (sizeof (___arr) == 0)						      \
-       ___r = __open_2 (fname, flags);					      \
+       {								      \
+	 if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0)	      \
+	   ___r = open (fname, flags);					      \
+	 else     							      \
+	   ___r = __open_2 (fname, flags);				      \
+       }								      \
      else								      \
        {								      \
-	 /* If the compile complains about the size of this array type too    \
+	 /* If the compiler complains about the size of this array type too   \
 	    many parameters have been passed to open.  */		      \
 	 typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \
 	 ___r = open (fname, flags, ___arr[0]);				      \
@@ -58,27 +63,32 @@ extern int __REDIRECT (__open_2, (__const char *__file, int __oflag),
 
 
 #ifdef __USE_LARGEFILE64
-extern int __open64_2 (__const char *__path, int __oflag);
+extern int __open64_2 (__const char *__path, int __oflag) __nonnull ((1));
 
 # define open64(fname, flags, ...) \
   ({ int ___r;								      \
      /* If the compiler complains about an invalid type, excess elements, etc \
-	in the initialization this means a paraleter of the wrong type has    \
+	in the initialization this means a parameter of the wrong type has    \
 	been passed to open64. */					      \
      int ___arr[] = { __VA_ARGS__ };					      \
      if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0)	      \
        {								      \
-	 /* If the compile complains about the size of this array type the    \
-	    the mode parameter is missing since O_CREAT has been used.  */    \
+	 /* If the compiler complains about the size of this array type the   \
+	    mode parameter is missing since O_CREAT has been used.  */	      \
 	 typedef int __open_missing_mode[((flags) & O_CREAT) != 0	      \
 					 ? ((long int) sizeof (___arr)	      \
 					    - (long int) sizeof (int)) : 1];  \
        }								      \
      if (sizeof (___arr) == 0)						      \
-       ___r = __open64_2 (fname, flags);				      \
+       {								      \
+	 if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0)	      \
+	   ___r = open64 (fname, flags);				      \
+	 else     							      \
+	   ___r = __open64_2 (fname, flags);				      \
+       }								      \
      else								      \
        {								      \
-	 /* If the compile complains about the size of this array type too    \
+	 /* If the compiler complains about the size of this array type too   \
 	    many parameters have been passed to open64.  */		      \
 	 typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \
 	 ___r = open64 (fname, flags, ___arr[0]);			      \
@@ -89,32 +99,38 @@ extern int __open64_2 (__const char *__path, int __oflag);
 
 #ifdef __USE_ATFILE
 # ifndef __USE_FILE_OFFSET64
-extern int __openat_2 (int __fd, __const char *__path, int __oflag);
+extern int __openat_2 (int __fd, __const char *__path, int __oflag)
+     __nonnull ((2));
 # else
 extern int __REDIRECT (__openat_2, (int __fd, __const char *__file,
 				    int __oflag), __openat64_2)
-     __nonnull ((1));
+     __nonnull ((2));
 # endif
 
 # define openat(fd, fname, flags, ...) \
   ({ int ___r;								      \
      /* If the compiler complains about an invalid type, excess elements, etc \
-	in the initialization this means a paraleter of the wrong type has    \
+	in the initialization this means a parameter of the wrong type has    \
 	been passed to openat. */					      \
      int ___arr[] = { __VA_ARGS__ };					      \
      if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0)	      \
        {								      \
-	 /* If the compile complains about the size of this array type the    \
-	    the mode parameter is missing since O_CREAT has been used.  */    \
+	 /* If the compiler complains about the size of this array type the   \
+	    mode parameter is missing since O_CREAT has been used.  */	      \
 	 typedef int __open_missing_mode[((flags) & O_CREAT) != 0	      \
 					 ? ((long int) sizeof (___arr)	      \
 					    - (long int) sizeof (int)) : 1];  \
        }								      \
      if (sizeof (___arr) == 0)						      \
-       ___r = __openat_2 (fd, fname, flags);				      \
+       {								      \
+	 if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0)	      \
+	   ___r = openat (fd, fname, flags);				      \
+	 else     							      \
+	   ___r = __openat_2 (fd, fname, flags);			      \
+       }								      \
      else								      \
        {								      \
-	 /* If the compile complains about the size of this array type too    \
+	 /* If the compiler complains about the size of this array type too   \
 	    many parameters have been passed to openat.  */		      \
 	 typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \
 	 ___r = openat (fd, fname, flags, ___arr[0]);			      \
@@ -124,28 +140,34 @@ extern int __REDIRECT (__openat_2, (int __fd, __const char *__file,
 
 
 # ifdef __USE_LARGEFILE64
-extern int __openat64_2 (int __fd, __const char *__path, int __oflag);
+extern int __openat64_2 (int __fd, __const char *__path, int __oflag)
+     __nonnull ((2));
 
 #  define openat64(fd, fname, flags, ...) \
   ({ int ___r;								      \
      /* If the compiler complains about an invalid type, excess elements, etc \
-	in the initialization this means a paraleter of the wrong type has    \
+	in the initialization this means a parameter of the wrong type has    \
 	been passed to openat64. */					      \
      int ___arr[] = { __VA_ARGS__ };					      \
      if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0)	      \
        {								      \
-	 /* If the compile complains about the size of this array type the    \
-	    the mode parameter is missing since O_CREAT has been used.  */    \
+	 /* If the compiler complains about the size of this array type the   \
+	    mode parameter is missing since O_CREAT has been used.  */	      \
 	 typedef int __open_missing_mode[((flags) & O_CREAT) != 0	      \
 					 ? ((long int) sizeof (___arr)	      \
 					    - (long int) sizeof (int)) : 1];  \
        }								      \
      if (sizeof (___arr) == 0)						      \
-       ___r = __openat64_2 (fd, fname, flags);				      \
+       {								      \
+	 if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0)	      \
+	   ___r = openat64 (fd, fname, flags);				      \
+	 else     							      \
+	   ___r = __openat64_2 (fd, fname, flags);			      \
+       }								      \
      else								      \
        {								      \
-	 /* If the compile complains about the size of this array type too    \
-	    many parameters have been passed to openat.  */		      \
+	 /* If the compiler complains about the size of this array type too   \
+	    many parameters have been passed to openat64.  */		      \
 	 typedef int __open_too_many_args[-(sizeof (___arr) > sizeof (int))]; \
 	 ___r = openat64 (fd, fname, flags, ___arr[0]);			      \
        }								      \