From patchwork Mon Mar 23 21:15:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 453629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3760C1400DD for ; Tue, 24 Mar 2015 08:15:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=rfaNN5ei; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=bEmRHf7YPxE0eYuF+DUFRgLIDIRvQQnGTSE+hdbCQrgdle 7Xtnr9XOkPp6+ZuA77eXifQZaetf67vbYS5/KROLnahozwneO98lSBX9hQB2mVsw 8r+alHcKQLLnBoW1+jYiGKya8AVAmc/PZwCvKgzdrqbBsd0UqTteRjNxE02vs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=U7i198i+1Cf0UG9dNt9ZcacHFi4=; b=rfaNN5eiC3kjCVHCAHie c5M8iyJRm6LEqfuKe3MWRWEqGKeI9N71dmQKaHFAbe1KJuNev0+J9gjMY+ClCoRE NYjj9uNM1RQnxMwvo12j4/7IUNEuDEmrCiElkXFzog2xMD4Jpq6X9SZuGcu5M08e SY00bI10LnmfxSTRuev0R6E= Received: (qmail 94330 invoked by alias); 23 Mar 2015 21:15:30 -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 94282 invoked by uid 89); 23 Mar 2015 21:15:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Minor cleanups in libio/iofdopen.c Message-Id: <20150323211525.B8D532C3B93@topped-with-meat.com> Date: Mon, 23 Mar 2015 14:15:25 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=4bmZMSa9zKAaFWJChRAA:9 a=CjuIK1q_8ugA:10 This fixes some -Werror unused variable warnings for the [!F_GETFL] case. Tested x86_64-linux-gnu. Thanks, Roland 2015-03-23 Roland McGrath * 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