From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 80A0F388883E for ; Wed, 30 Mar 2022 20:11:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80A0F388883E Received: by mail-pf1-x42b.google.com with SMTP id u22so19843024pfg.6 for ; Wed, 30 Mar 2022 13:11:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vsXG2EbEp+IP1h0sr7k9UwD3iikh4pY+V7z84/HlSN8=; b=1kSE/QzSss8m3siaZJSXllTiUVTqJahcHUUop0chGoJ4bsoTYKFdvQaYqiPoFBM4J8 R1dVnXD2laXMSA9PbVBF2IatgRlv+wmYy9KZEW/7F+rxvo1dDnXPpSwUuVaP3MInkyir nq54HSvbFQhveo8R/Pdkcv+C4c83Hm2sj3ZbFSroumhCNrrhTcEVRoyMZYPQ2394aP1X wsl7PaLuF3DrYlyc2EHuHGhj3Vh+EZHSclPUP5qdW+IXcog58/YsDl3ofZl+iW5tZJ3+ cQlsx6BKRxFqVqv2lBNqrniOUDIIN4O8TBGYg7nLCUU93Xo14A8mntrimCoJRxnFT4VQ PjJA== X-Gm-Message-State: AOAM531U9ITH3wFb20C4YSbSHWjehiw3Ntz5rwro8cHs7d/93MXDO/jG O698dqZaCoqBjgJvJObirmfOGgVU16CRGpNtpyOzwiHZ X-Google-Smtp-Source: ABdhPJzTj+OzRezqMgtvl59HEFuJSxgpe/uJCB8SA28oTaVjqguSsBVe0Gl+HONX407BPPj8PJpE/iAhNy1pm74dVF0= X-Received: by 2002:a63:d44c:0:b0:380:8c48:e040 with SMTP id i12-20020a63d44c000000b003808c48e040mr7757923pgj.14.1648671072473; Wed, 30 Mar 2022 13:11:12 -0700 (PDT) MIME-Version: 1.0 References: <20220330170200.2867894-1-goldstein.w.n@gmail.com> <20220330181711.jeq2gvllahoz7or7@google.com> In-Reply-To: From: Noah Goldstein Date: Wed, 30 Mar 2022 15:11:01 -0500 Message-ID: Subject: Re: [PATCH v2] Add .clang-format style file To: Joseph Myers Cc: Fangrui Song , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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 20:11:15 -0000 On Wed, Mar 30, 2022 at 2:47 PM Joseph Myers wrote: > > 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). My mistake, fixed in v4. > > > 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