From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 0/5] CodingGUidelines: C99 updates
Date: Mon, 10 Oct 2022 13:37:55 -0700 [thread overview]
Message-ID: <20221010203800.2154698-1-gitster@pobox.com> (raw)
In-Reply-To: <cover-0.5-00000000000-20221007T092505Z-avarab@gmail.com>
As this is otherwise clearly good series, I got sick of waiting for
a trivial update, so here is what I did to update them myself.
Updates are in patches 3 and 4. We promised to revisit the issue of
allowing "for (int i = 0; ..." in November this year, so we are
merely "proposing" to go ahead and allow it with this patch, and
will merge only after gaining consensus. The wording has been
redone to avoid sounding like it is a fait accompli.
Patch 4 has been updated to avoid starting the latter clause with a
capitalized word in two independent clauses joined with a semicolon.
Ævar Arnfjörð Bjarmason (5):
CodingGuidelines: update for C99
CodingGuidelines: mention dynamic C99 initializer elements
CodingGuidelines: allow declaring variables in for loops
CodingGuidelines: mention C99 features we can't use
CodingGuidelines: recommend against unportable C99 struct syntax
Documentation/CodingGuidelines | 34 ++++++++++++++++++++++++----------
revision.c | 7 -------
2 files changed, 24 insertions(+), 17 deletions(-)
Range-diff against v1:
1: 3e3dd9cbd5 = 1: 3e3dd9cbd5 CodingGuidelines: update for C99
2: fb6c58ef52 = 2: fb6c58ef52 CodingGuidelines: mention dynamic C99 initializer elements
3: 719e235f9f ! 3: f3237c88f8 CodingGuidelines: allow declaring variables in for loops
@@ Commit message
cb2607759e2 (merge-ort: store more specific conflict information,
2022-06-18) released with v2.38.0.
- As November 2022 is within the window of this upcoming release let's
- update the guideline to allow this, and revert the recent
- 6983f4e3b20 (test-parse-options.c: don't use for loop initial
- declaration, 2022-09-05).
-
- It's better to update the guidelines than to have back & forth churn
- like that, we clearly don't have portability issues related to this
- syntax.
+ As November 2022 is within the window of this upcoming release,
+ let's update the guideline to allow this. We can have the promised
+ "revisit" discussion while this patch cooks, and drop it if it turns
+ out that it is still premature, which is not expected to happen at
+ this moment.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
@@ revision.c: static inline int want_ancestry(const struct rev_info *revs);
for (const char *p = name; *p && *p != '\n'; p++)
fputc(*p, out);
fputc('\n', out);
-
- ## t/helper/test-parse-options.c ##
-@@ t/helper/test-parse-options.c: int cmd__parse_options(int argc, const char **argv)
-
- static void print_args(int argc, const char **argv)
- {
-- int i;
-- for (i = 0; i < argc; i++)
-+ for (int i = 0; i < argc; i++)
- printf("arg %02d: %s\n", i, argv[i]);
- }
-
4: 3d1edfd825 ! 4: 9d2479220d CodingGuidelines: mention C99 features we can't use
@@ Documentation/CodingGuidelines: For C programs:
+
+ . %z and %zu as a printf() argument for a size_t (the %z being for
+ the POSIX-specific ssize_t). Instead you should use
-+ printf("%"PRIuMAX, (uintmax_t)v); These days the MSVC version we
++ printf("%"PRIuMAX, (uintmax_t)v). These days the MSVC version we
+ rely on supports %z, but the C library used by MinGW does not.
+
- Variables have to be declared at the beginning of the block, before
5: 139b0f8cfd ! 5: ef22b1756a CodingGuidelines: recommend against unportable C99 struct syntax
@@ Commit message
## Documentation/CodingGuidelines ##
@@ Documentation/CodingGuidelines: For C programs:
- printf("%"PRIuMAX, (uintmax_t)v); These days the MSVC version we
+ printf("%"PRIuMAX, (uintmax_t)v). These days the MSVC version we
rely on supports %z, but the C library used by MinGW does not.
+ . Shorthand like ".a.b = *c" in struct assignments is known to trip
--
2.38.0-167-gf9a88ca9e9
next prev parent reply other threads:[~2022-10-10 20:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 9:30 [PATCH 0/5] CodingGuidelines: various C99 updates Ævar Arnfjörð Bjarmason
2022-10-07 9:30 ` [PATCH 1/5] CodingGuidelines: update for C99 Ævar Arnfjörð Bjarmason
2022-10-07 18:08 ` Junio C Hamano
2022-10-07 9:30 ` [PATCH 2/5] CodingGuidelines: mention dynamic C99 initializer elements Ævar Arnfjörð Bjarmason
2022-10-07 9:30 ` [PATCH 3/5] CodingGuidelines: allow declaring variables in for loops Ævar Arnfjörð Bjarmason
2022-10-07 18:12 ` Junio C Hamano
2022-10-07 9:30 ` [PATCH 4/5] CodingGuidelines: mention C99 features we can't use Ævar Arnfjörð Bjarmason
2022-10-07 18:13 ` Junio C Hamano
2022-10-07 9:30 ` [PATCH 5/5] CodingGuidelines: recommend against unportable C99 struct syntax Ævar Arnfjörð Bjarmason
2022-10-07 17:54 ` [PATCH 0/5] CodingGuidelines: various C99 updates Junio C Hamano
2022-10-07 18:15 ` Junio C Hamano
2022-10-10 20:37 ` Junio C Hamano [this message]
2022-10-10 20:37 ` [PATCH v2 1/5] CodingGuidelines: update for C99 Junio C Hamano
2022-10-10 20:37 ` [PATCH v2 2/5] CodingGuidelines: mention dynamic C99 initializer elements Junio C Hamano
2022-10-10 20:37 ` [PATCH v2 3/5] CodingGuidelines: allow declaring variables in for loops Junio C Hamano
2022-10-10 20:37 ` [PATCH v2 4/5] CodingGuidelines: mention C99 features we can't use Junio C Hamano
2022-10-10 20:38 ` [PATCH v2 5/5] CodingGuidelines: recommend against unportable C99 struct syntax Junio C Hamano
2022-10-11 0:09 ` Jeff King
2022-10-11 0:26 ` Junio C Hamano
2022-10-11 0:39 ` Jeff King
2022-10-11 8:30 ` Ævar Arnfjörð Bjarmason
2022-10-11 15:01 ` Junio C Hamano
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=20221010203800.2154698-1-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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 NNTP newsgroup(s).