From patchwork Sun Feb 11 16:35:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 25909 Received: (qmail 43660 invoked by alias); 11 Feb 2018 16:36:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 43548 invoked by uid 89); 11 Feb 2018 16:36:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=4817, 4013 X-HELO: l2mail1.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, adhemerval.zanella@linaro.org Subject: [PATCH 4/6] Remove _IO_file_flags define. Date: Sun, 11 Feb 2018 11:35:56 -0500 Message-Id: <20180211163558.14124-5-zackw@panix.com> In-Reply-To: <20180211163558.14124-1-zackw@panix.com> References: <20180211163558.14124-1-zackw@panix.com> MIME-Version: 1.0 This entirely mechanical (except for some indentation fixups) patch replaces all uses of _IO_file_flags with _flags and removes the #define. * libio/libio.h (_IO_file_flags): Remove macro. All uses changed to _flags. --- debug/fgets_chk.c | 8 ++++---- debug/fgets_u_chk.c | 9 ++++----- debug/fgetws_chk.c | 6 +++--- debug/fgetws_u_chk.c | 9 ++++----- debug/gets_chk.c | 8 ++++---- libio/fileops.c | 2 +- libio/iofclose.c | 6 +++--- libio/iofgets.c | 9 ++++----- libio/iofgets_u.c | 9 ++++----- libio/iofgetws.c | 6 +++--- libio/iofgetws_u.c | 9 ++++----- libio/iogets.c | 8 ++++---- libio/iosetvbuf.c | 12 ++++++------ libio/libio.h | 3 --- libio/libioP.h | 4 ++-- libio/oldfileops.c | 2 +- libio/oldiofclose.c | 6 +++--- libio/strfile.h | 2 +- libio/strops.c | 2 +- stdio-common/vfprintf.c | 4 ++-- 20 files changed, 58 insertions(+), 66 deletions(-) diff --git a/debug/fgets_chk.c b/debug/fgets_chk.c index f2236533700..d86454f3e81 100644 --- a/debug/fgets_chk.c +++ b/debug/fgets_chk.c @@ -40,12 +40,12 @@ __fgets_chk (char *buf, size_t size, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - int old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + int old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getline (fp, buf, MIN ((size_t) n - 1, size), '\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else if (count >= size) @@ -55,7 +55,7 @@ __fgets_chk (char *buf, size_t size, int n, FILE *fp) buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; _IO_release_lock (fp); return result; } diff --git a/debug/fgets_u_chk.c b/debug/fgets_u_chk.c index 317ae5649df..924634c17bc 100644 --- a/debug/fgets_u_chk.c +++ b/debug/fgets_u_chk.c @@ -39,13 +39,12 @@ __fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - int old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + int old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getline (fp, buf, MIN ((size_t) n - 1, size), '\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) - && errno != EAGAIN)) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else if (count >= size) __chk_fail (); @@ -54,6 +53,6 @@ __fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp) buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; return result; } diff --git a/debug/fgetws_chk.c b/debug/fgetws_chk.c index 8ea6635b30e..2380059f0f1 100644 --- a/debug/fgetws_chk.c +++ b/debug/fgetws_chk.c @@ -32,8 +32,8 @@ __fgetws_chk (wchar_t *buf, size_t size, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getwline (fp, buf, MIN ((size_t) n - 1, size), L'\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ @@ -46,7 +46,7 @@ __fgetws_chk (wchar_t *buf, size_t size, int n, FILE *fp) buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; _IO_release_lock (fp); return result; } diff --git a/debug/fgetws_u_chk.c b/debug/fgetws_u_chk.c index 42dad6bc8b5..8147eb1e36c 100644 --- a/debug/fgetws_u_chk.c +++ b/debug/fgetws_u_chk.c @@ -40,13 +40,12 @@ __fgetws_unlocked_chk (wchar_t *buf, size_t size, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getwline (fp, buf, MIN ((size_t) n - 1, size), L'\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) - && errno != EAGAIN)) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else if (count >= size) __chk_fail (); @@ -55,6 +54,6 @@ __fgetws_unlocked_chk (wchar_t *buf, size_t size, int n, FILE *fp) buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; return result; } diff --git a/debug/gets_chk.c b/debug/gets_chk.c index df3f947e705..2b1416b295e 100644 --- a/debug/gets_chk.c +++ b/debug/gets_chk.c @@ -51,17 +51,17 @@ __gets_chk (char *buf, size_t size) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - int old_error = _IO_stdin->_IO_file_flags & _IO_ERR_SEEN; - _IO_stdin->_IO_file_flags &= ~_IO_ERR_SEEN; + int old_error = _IO_stdin->_flags & _IO_ERR_SEEN; + _IO_stdin->_flags &= ~_IO_ERR_SEEN; buf[0] = (char) ch; count = _IO_getline (_IO_stdin, buf + 1, size - 1, '\n', 0) + 1; - if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN) + if (_IO_stdin->_flags & _IO_ERR_SEEN) { retval = NULL; goto unlock_return; } else - _IO_stdin->_IO_file_flags |= old_error; + _IO_stdin->_flags |= old_error; } if (count >= size) __chk_fail (); diff --git a/libio/fileops.c b/libio/fileops.c index 1162b1b1442..fb39bec63cd 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -109,7 +109,7 @@ _IO_new_file_init_internal (struct _IO_FILE_plus *fp) of our file descriptor. Hence we actually don't know the actual position before we do the first fseek (and until a following fflush). */ fp->file._offset = _IO_pos_BAD; - fp->file._IO_file_flags |= CLOSED_FILEBUF_FLAGS; + fp->file._flags |= CLOSED_FILEBUF_FLAGS; _IO_link_in (fp); fp->file._fileno = -1; diff --git a/libio/iofclose.c b/libio/iofclose.c index c7c44ed9b47..7a8b89f9f54 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -45,11 +45,11 @@ _IO_new_fclose (FILE *fp) #endif /* First unlink the stream. */ - if (fp->_IO_file_flags & _IO_IS_FILEBUF) + if (fp->_flags & _IO_IS_FILEBUF) _IO_un_link ((struct _IO_FILE_plus *) fp); _IO_acquire_lock (fp); - if (fp->_IO_file_flags & _IO_IS_FILEBUF) + if (fp->_flags & _IO_IS_FILEBUF) status = _IO_file_close_it (fp); else status = fp->_flags & _IO_ERR_SEEN ? -1 : 0; @@ -73,7 +73,7 @@ _IO_new_fclose (FILE *fp) } if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr) { - fp->_IO_file_flags = 0; + fp->_flags = 0; free(fp); } diff --git a/libio/iofgets.c b/libio/iofgets.c index b15b59d3bf6..68177dbe22d 100644 --- a/libio/iofgets.c +++ b/libio/iofgets.c @@ -48,20 +48,19 @@ _IO_fgets (char *buf, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getline (fp, buf, n - 1, '\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) - && errno != EAGAIN)) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else { buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; _IO_release_lock (fp); return result; } diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c index 90916446857..9d33a376219 100644 --- a/libio/iofgets_u.c +++ b/libio/iofgets_u.c @@ -47,20 +47,19 @@ __fgets_unlocked (char *buf, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getline (fp, buf, n - 1, '\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) - && errno != EAGAIN)) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else { buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; return result; } libc_hidden_def (__fgets_unlocked) diff --git a/libio/iofgetws.c b/libio/iofgetws.c index 0e2d515df5e..292a161757d 100644 --- a/libio/iofgetws.c +++ b/libio/iofgetws.c @@ -48,8 +48,8 @@ fgetws (wchar_t *buf, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getwline (fp, buf, n - 1, L'\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ @@ -60,7 +60,7 @@ fgetws (wchar_t *buf, int n, FILE *fp) buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; _IO_release_lock (fp); return result; } diff --git a/libio/iofgetws_u.c b/libio/iofgetws_u.c index a930b47a6df..46431a278b5 100644 --- a/libio/iofgetws_u.c +++ b/libio/iofgetws_u.c @@ -47,19 +47,18 @@ fgetws_unlocked (wchar_t *buf, int n, FILE *fp) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - old_error = fp->_IO_file_flags & _IO_ERR_SEEN; - fp->_IO_file_flags &= ~_IO_ERR_SEEN; + old_error = fp->_flags & _IO_ERR_SEEN; + fp->_flags &= ~_IO_ERR_SEEN; count = _IO_getwline (fp, buf, n - 1, L'\n', 1); /* If we read in some bytes and errno is EAGAIN, that error will be reported for next read. */ - if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN) - && errno != EAGAIN)) + if (count == 0 || ((fp->_flags & _IO_ERR_SEEN) && errno != EAGAIN)) result = NULL; else { buf[count] = '\0'; result = buf; } - fp->_IO_file_flags |= old_error; + fp->_flags |= old_error; return result; } diff --git a/libio/iogets.c b/libio/iogets.c index 19048f6d03d..c2223e6ecc0 100644 --- a/libio/iogets.c +++ b/libio/iogets.c @@ -48,17 +48,17 @@ _IO_gets (char *buf) /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ - int old_error = _IO_stdin->_IO_file_flags & _IO_ERR_SEEN; - _IO_stdin->_IO_file_flags &= ~_IO_ERR_SEEN; + int old_error = _IO_stdin->_flags & _IO_ERR_SEEN; + _IO_stdin->_flags &= ~_IO_ERR_SEEN; buf[0] = (char) ch; count = _IO_getline (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1; - if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN) + if (_IO_stdin->_flags & _IO_ERR_SEEN) { retval = NULL; goto unlock_return; } else - _IO_stdin->_IO_file_flags |= old_error; + _IO_stdin->_flags |= old_error; } buf[count] = 0; retval = buf; diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c index b29a93be548..a35d866d827 100644 --- a/libio/iosetvbuf.c +++ b/libio/iosetvbuf.c @@ -39,7 +39,7 @@ _IO_setvbuf (FILE *fp, char *buf, int mode, size_t size) switch (mode) { case _IOFBF: - fp->_IO_file_flags &= ~(_IO_LINE_BUF|_IO_UNBUFFERED); + fp->_flags &= ~(_IO_LINE_BUF|_IO_UNBUFFERED); if (buf == NULL) { if (fp->_IO_buf_base == NULL) @@ -62,15 +62,15 @@ _IO_setvbuf (FILE *fp, char *buf, int mode, size_t size) result = EOF; goto unlock_return; } - fp->_IO_file_flags &= ~_IO_LINE_BUF; + fp->_flags &= ~_IO_LINE_BUF; } result = 0; goto unlock_return; } break; case _IOLBF: - fp->_IO_file_flags &= ~_IO_UNBUFFERED; - fp->_IO_file_flags |= _IO_LINE_BUF; + fp->_flags &= ~_IO_UNBUFFERED; + fp->_flags |= _IO_LINE_BUF; if (buf == NULL) { result = 0; @@ -78,8 +78,8 @@ _IO_setvbuf (FILE *fp, char *buf, int mode, size_t size) } break; case _IONBF: - fp->_IO_file_flags &= ~_IO_LINE_BUF; - fp->_IO_file_flags |= _IO_UNBUFFERED; + fp->_flags &= ~_IO_LINE_BUF; + fp->_flags |= _IO_UNBUFFERED; buf = NULL; size = 0; break; diff --git a/libio/libio.h b/libio/libio.h index a3c679ca666..d1516185667 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -60,9 +60,6 @@ typedef union #include -/* compatibility defines */ -#define _IO_file_flags _flags - /* open modes */ #define _IOS_INPUT 1 #define _IOS_OUTPUT 2 diff --git a/libio/libioP.h b/libio/libioP.h index 5064bdf69d4..ee23296ddba 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -761,7 +761,7 @@ extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; #else /* This is part of the kludge for binary compatibility with old stdio. */ # define COERCE_FILE(FILE) \ - (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ + (((FILE)->_flags & _IO_MAGIC_MASK) == _OLD_MAGIC_MASK \ && (FILE) = *(FILE**)&((int*)fp)[1]) #endif @@ -775,7 +775,7 @@ extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf; # define CHECK_FILE(FILE, RET) \ if ((FILE) == NULL) { MAYBE_SET_EINVAL; return RET; } \ else { COERCE_FILE(FILE); \ - if (((FILE)->_IO_file_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ + if (((FILE)->_flags & _IO_MAGIC_MASK) != _IO_MAGIC) \ { MAYBE_SET_EINVAL; return RET; }} #else # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE) diff --git a/libio/oldfileops.c b/libio/oldfileops.c index 5b6e81c4967..5a0f246411c 100644 --- a/libio/oldfileops.c +++ b/libio/oldfileops.c @@ -102,7 +102,7 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp) of our file descriptor. Hence we actually don't know the actual position before we do the first fseek (and until a following fflush). */ fp->file._old_offset = _IO_pos_BAD; - fp->file._IO_file_flags |= CLOSED_FILEBUF_FLAGS; + fp->file._flags |= CLOSED_FILEBUF_FLAGS; _IO_link_in (fp); fp->file._vtable_offset = ((int) sizeof (struct _IO_FILE) diff --git a/libio/oldiofclose.c b/libio/oldiofclose.c index 432a7dd89a4..f414502fe01 100644 --- a/libio/oldiofclose.c +++ b/libio/oldiofclose.c @@ -46,11 +46,11 @@ _IO_old_fclose (FILE *fp) return _IO_new_fclose (fp); /* First unlink the stream. */ - if (fp->_IO_file_flags & _IO_IS_FILEBUF) + if (fp->_flags & _IO_IS_FILEBUF) _IO_un_link ((struct _IO_FILE_plus *) fp); _IO_acquire_lock (fp); - if (fp->_IO_file_flags & _IO_IS_FILEBUF) + if (fp->_flags & _IO_IS_FILEBUF) status = _IO_old_file_close_it (fp); else status = fp->_flags & _IO_ERR_SEEN ? -1 : 0; @@ -60,7 +60,7 @@ _IO_old_fclose (FILE *fp) _IO_free_backup_area (fp); if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr) { - fp->_IO_file_flags = 0; + fp->_flags = 0; free(fp); } diff --git a/libio/strfile.h b/libio/strfile.h index b96fd0fb0ae..46ac81809a3 100644 --- a/libio/strfile.h +++ b/libio/strfile.h @@ -59,7 +59,7 @@ typedef struct _IO_strfile_ /* frozen: set when the program has requested that the array object not be altered, reallocated, or freed. */ -#define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF) +#define _IO_STR_FROZEN(FP) ((FP)->_f._flags & _IO_USER_BUF) typedef struct { diff --git a/libio/strops.c b/libio/strops.c index adfa80749c1..eddd722c093 100644 --- a/libio/strops.c +++ b/libio/strops.c @@ -74,7 +74,7 @@ void _IO_str_init_readonly (_IO_strfile *sf, const char *ptr, int size) { _IO_str_init_static_internal (sf, (char *) ptr, size < 0 ? -1 : size, NULL); - sf->_sbf._f._IO_file_flags |= _IO_NO_WRITES; + sf->_sbf._f._flags |= _IO_NO_WRITES; } int diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c index 27d3a2c1bf7..8f0a6f8cf28 100644 --- a/stdio-common/vfprintf.c +++ b/stdio-common/vfprintf.c @@ -62,7 +62,7 @@ return -1; \ } \ } while (0) -#define UNBUFFERED_P(S) ((S)->_IO_file_flags & _IO_UNBUFFERED) +#define UNBUFFERED_P(S) ((S)->_flags & _IO_UNBUFFERED) #define done_add(val) \ do { \ @@ -2307,7 +2307,7 @@ buffered_vfprintf (FILE *s, const CHAR_T *format, va_list args) _IO_setp (hp, buf, buf + sizeof buf); hp->_mode = -1; #endif - hp->_IO_file_flags = _IO_MAGIC|_IO_NO_READS|_IO_USER_LOCK; + hp->_flags = _IO_MAGIC|_IO_NO_READS|_IO_USER_LOCK; #if _IO_JUMPS_OFFSET hp->_vtable_offset = 0; #endif