From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 64FC6385E449 for ; Wed, 30 Mar 2022 19:47:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 64FC6385E449 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,223,1643702400"; d="scan'208";a="73645695" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 30 Mar 2022 11:47:07 -0800 IronPort-SDR: M6ZPZGTNgNChGzWEqZ426bGYh8YZkMCtTA64cybyPfKcUQHlJHAwyXUj0Em3nRUgqRKTAE7EHo EKsE3HBxAfcfovb/z7feFFpbf/zKa2KJwFPNaVhm30/NEDc28qoFC35kkSqkeUr6bT78UJD5QB 1WHt0uGKQGPwCeD/k4moInPw8hyhAOcEoRd6vCf72UKaUy9To3MbC/MN6KiLwSw0blmtT1tQIm hzlvjHBujFp2gDrRmGYbCv629zcrozEF+an5BZ5mBKylJYc/K605JEWYcP9uhg57Rx9sksctdL JfE= Date: Wed, 30 Mar 2022 19:47:01 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Noah Goldstein CC: Fangrui Song , GNU C Library Subject: Re: [PATCH v2] Add .clang-format style file In-Reply-To: Message-ID: References: <20220330170200.2867894-1-goldstein.w.n@gmail.com> <20220330181711.jeq2gvllahoz7or7@google.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3114.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2022 19:47:09 -0000 On Wed, 30 Mar 2022, Noah Goldstein via Libc-alpha wrote: > clang-format cleans up excess whitespace before the first comment > [MaxEmptyLinesToKeep: 1] and realigns part of the comments: > > - > /* A reader--writer lock that fulfills the POSIX requirements (but operations > on this lock are not necessarily full barriers, as one may interpret the > POSIX requirement about "synchronizing memory"). All critical sections are > @@ -71,18 +70,18 @@ > #1 0 0 0 0 Lock is idle (and in a read phase). > #2 0 0 >0 0 Readers have acquired the lock. > #3 0 1 0 0 Lock is not acquired; a writer will try to start a > - write phase. > + write phase. But the indentation is correct as-is. The general rule in glibc is that any multiple of 8 blank columns at the start of a line is represented by the corresponding number of TAB characters. There may be a case for using spaces instead of tabs, but that's not the current style (except maybe for some files shared with gnulib). > It also fixes difficult to ready indentation: > > { > rnew = r - (1 << PTHREAD_RWLOCK_READER_SHIFT); > /* If we are the last reader, we also need to unblock any readers > - that are waiting for a writer to go first (PTHREAD_RWLOCK_RWAITING) > - so that they can register while the writer is active. */ > + that are waiting for a writer to go first (PTHREAD_RWLOCK_RWAITING) > + so that they can register while the writer is active. */ > if ((rnew >> PTHREAD_RWLOCK_READER_SHIFT) == 0) > - { > - if ((rnew & PTHREAD_RWLOCK_WRLOCKED) != 0) > - rnew |= PTHREAD_RWLOCK_WRPHASE; > - rnew &= ~(unsigned int) PTHREAD_RWLOCK_RWAITING; > - } > + { > + if ((rnew & PTHREAD_RWLOCK_WRLOCKED) != 0) > + rnew |= PTHREAD_RWLOCK_WRPHASE; > + rnew &= ~(unsigned int) PTHREAD_RWLOCK_RWAITING; > + } Again, the indentation looks fine as-is; it's using TABs. > aligns conditions nicely: > > while ((r & PTHREAD_RWLOCK_WRPHASE) == 0 > - && (r & PTHREAD_RWLOCK_WRLOCKED) != 0 > - && (r >> PTHREAD_RWLOCK_READER_SHIFT) > 0) > > + && (r & PTHREAD_RWLOCK_WRLOCKED) != 0 > + && (r >> PTHREAD_RWLOCK_READER_SHIFT) > 0) Likewise, the indentation is already correct, using TABs. > and cleans up some obvious style mistakes > > - done: > +done: I don't think that's a style mistake either. Emacs indents a label in the outermost block of a function like that (one-column indent rather than zero columns), and I think it's deliberate to support tools such as "diff -p", where it's desirable that, at any point within a function, the previous line starting with a letter is the line with the function name, not a line with a label somewhere within the function. -- Joseph S. Myers joseph@codesourcery.com