public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Noah Goldstein <goldstein.w.n@gmail.com>
Cc: Fangrui Song <maskray@google.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH v2] Add .clang-format style file
Date: Wed, 30 Mar 2022 19:47:01 +0000	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2203301941120.450807@digraph.polyomino.org.uk> (raw)
In-Reply-To: <CAFUsyfJhrr8vx02V81x2MpF_8G71cr9U8+9nhvXeMRHnAR8GUw@mail.gmail.com>

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

  reply	other threads:[~2022-03-30 19:47 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28 19:12 [PATCH v1] " Noah Goldstein
2022-03-30  0:26 ` Fangrui Song
2022-03-30  1:33   ` Noah Goldstein
2022-03-30 17:02     ` [PATCH v2] " Noah Goldstein
2022-03-30 18:17       ` Fangrui Song
2022-03-30 19:30         ` Noah Goldstein
2022-03-30 19:47           ` Joseph Myers [this message]
2022-03-30 20:11             ` Noah Goldstein
2022-03-30 20:16             ` Noah Goldstein
2022-03-30 20:21               ` Joseph Myers
2022-03-30 20:59               ` Andreas Schwab
2022-03-30 19:27 ` [PATCH v3] " Noah Goldstein
2022-03-30 19:59   ` Fangrui Song
2022-03-30 20:01   ` Florian Weimer
2022-03-30 20:09     ` Noah Goldstein
2022-03-30 20:14       ` Florian Weimer
2022-03-30 20:21         ` Noah Goldstein
2022-03-30 20:10 ` [PATCH v4] " Noah Goldstein
2022-03-30 20:24 ` [PATCH v5] " Noah Goldstein
2022-04-04 14:13   ` Carlos O'Donell
2022-04-04 16:57     ` Noah Goldstein
2022-04-04 16:56 ` [PATCH v6] " Noah Goldstein
2022-04-11 14:18   ` Carlos O'Donell
2022-04-11 15:52     ` Noah Goldstein

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2203301941120.450807@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).