This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED PATCH] Minor cleanups in libio/iofdopen.c
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Mon, 23 Mar 2015 14:15:25 -0700 (PDT)
- Subject: [COMMITTED PATCH] Minor cleanups in libio/iofdopen.c
- Authentication-results: sourceware.org; auth=none
This fixes some -Werror unused variable warnings for the [!F_GETFL] case.
Tested x86_64-linux-gnu.
Thanks,
Roland
2015-03-23 Roland McGrath <roland@hack.frob.com>
* libio/iofdopen.c: Move FD_FLAGS declaration into its first use,
inside [F_GETFL]. Remove POSIX_MODE local variable, just test the
_IO_IS_APPENDING bit in READ_WRITE instead.
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -46,7 +46,6 @@ _IO_new_fdopen (fd, mode)
const char *mode;
{
int read_write;
- int posix_mode = 0;
struct locked_FILE
{
struct _IO_FILE_plus fp;
@@ -55,7 +54,6 @@ _IO_new_fdopen (fd, mode)
#endif
struct _IO_wide_data wd;
} *new_f;
- int fd_flags;
int i;
int use_mmap = 0;
@@ -73,7 +71,6 @@ _IO_new_fdopen (fd, mode)
read_write = _IO_NO_READS;
break;
case 'a':
- posix_mode = O_APPEND;
read_write = _IO_NO_READS|_IO_IS_APPENDING;
break;
default:
@@ -101,7 +98,7 @@ _IO_new_fdopen (fd, mode)
break;
}
#ifdef F_GETFL
- fd_flags = _IO_fcntl (fd, F_GETFL);
+ int fd_flags = _IO_fcntl (fd, F_GETFL);
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
@@ -131,7 +128,7 @@ _IO_new_fdopen (fd, mode)
though that would seem consistent) because that would be more
likely to break historical programs.
*/
- if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
+ if ((read_write & _IO_IS_APPENDING) && !(fd_flags & O_APPEND))
{
do_seek = true;
#ifdef F_SETFL