Repository navigation
Adjust source formatting - #29383
Closed
levitte wants to merge 7 commits into
Closed
Adjust source formatting#29383levitte wants to merge 7 commits into
levitte wants to merge 7 commits into
Conversation
For some reason, source reformatting didn't catch everything.
This resulted in an adjustment of reformatting that is a bit less trippy in some places.
I looked for them with the following grep pipe, and then read through
the output to discern what are actual type definitions, and converted
what I found manually.
git grep -En -e '#define [a-zA-Z_0-9]+ ' -- '*.h' \
| sed -e 's|//.*||' -e 's|/\*.*\*/||g' \
| grep -Ev ' ([0-9]|.*".*|.*\\$)'
levitte
force-pushed
the
adjust-formatting
branch
from
December 12, 2025 16:18
fe9a045 to
90223d8
Compare
Contributor
|
To me this highlights the premature application of the enforced source formatting 😞 |
Member
|
In general this should be backported to all the active branches except for the define -> typedef changes in public headers. Those have to stay as defines in stable branches. |
levitte
marked this pull request as ready for review
December 15, 2025 19:46
Member
Author
|
Made this ready for review |
t8m
previously approved these changes
Dec 15, 2025
mattcaswell
reviewed
Dec 16, 2025
levitte
force-pushed
the
adjust-formatting
branch
from
December 16, 2025 08:51
90223d8 to
877dd86
Compare
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
This resulted in some source reformatting becoming a bit less trippy
This is the script I used to run clang-format appropriately enough:
#! /bin/bash
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
known_generated=( crypto/bn/bn_prime.h
crypto/objects/obj_dat.h
crypto/objects/obj_xref.h
include/openssl/obj_mac.h
crypto/conf/conf_def.h
crypto/asn1/charmap.h
'*_err.c'
'*err.h' )
exclusions=()
for g in "${known_generated[@]}"; do
# Convert pattern to a regex
g=${g//\./\\.}
g=${g//\*/.\*}
exclusions+=( "^${g}\$" )
done
# Join all exclusions into one regex
exclude_re=$(IFS='|'; echo "${exclusions[*]}")
(set -x; git ls-files | grep -E $include_re | grep -Ev $exclude_re | xargs clang-format -i)
levitte
force-pushed
the
adjust-formatting
branch
from
December 16, 2025 09:26
877dd86 to
2d5b28a
Compare
Member
Author
|
I found a couple of more things, so included them too. This PR needs another review |
Member
Author
Yeah, it also seems like I must make a separate PR for those branches |
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 23, 2025
Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 23, 2025
Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
For some reason, source reformatting didn't catch everything. Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
I looked for them with the following grep pipe, and then read through
the output to discern what are actual type definitions, and converted
what I found manually.
git grep -En -e '#define [a-zA-Z_0-9]+ ' -- '*.h' \
| sed -e 's|//.*||' -e 's|/\*.*\*/||g' \
| grep -Ev ' ([0-9]|.*".*|.*\\$)'
Reviewed-by: Paul Yang <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
(Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Reviewed-by: Paul Yang <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
(Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
This resulted in some source reformatting becoming a bit less trippy
This is the script I used to run clang-format appropriately enough:
#! /bin/bash
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
known_generated=( crypto/bn/bn_prime.h
crypto/objects/obj_dat.h
crypto/objects/obj_xref.h
include/openssl/obj_mac.h
crypto/conf/conf_def.h
crypto/asn1/charmap.h
'*_err.c'
'*err.h' )
exclusions=()
for g in "${known_generated[@]}"; do
# Convert pattern to a regex
g=${g//\./\\.}
g=${g//\*/.\*}
exclusions+=( "^${g}\$" )
done
# Join all exclusions into one regex
exclude_re=$(IFS='|'; echo "${exclusions[*]}")
(set -x; git ls-files | grep -E $include_re | grep -Ev $exclude_re | xargs clang-format -i)
Reviewed-by: Paul Yang <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
(Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
websurfer5
pushed a commit
to websurfer5/openssl
that referenced
this pull request
Dec 29, 2025
Reviewed-by: Paul Yang <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> Reviewed-by: Matt Caswell <[email protected]> Reviewed-by: Neil Horman <[email protected]> (Merged from openssl#29383)
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: openssl#29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: openssl#29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
Original-PR: openssl#29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: openssl#29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: openssl#29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
Original-PR: openssl#29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: openssl#29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: openssl#29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
Original-PR: openssl#29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: openssl#29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: openssl#29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
Original-PR: openssl#29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: openssl#29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: openssl#29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
esyr
pushed a commit
to esyr/openssl
that referenced
this pull request
Apr 1, 2026
Original-PR: openssl#29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust"
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: #29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros" Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Neil Horman <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> MergeDate: Fri Apr 3 14:48:52 2026 (Merged from #29822)
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: #29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Fri Apr 3 14:48:54 2026
(Merged from #29822)
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
Original-PR: #29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust" Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Neil Horman <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> MergeDate: Fri Apr 3 14:48:55 2026 (Merged from #29822)
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
This resulted in an adjustment of reformatting that is a bit less trippy in some places. Original-PR: #29383 Original-Commit: 821b265 "Add a few more ASN.1 related StatementMacros" Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> MergeDate: Fri Apr 3 14:47:51 2026 (Merged from #29821)
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
This was done by calling a script I made on the spot:
bash add-types-to-clang-format > .clang-format.new && mv .clang-format.new .clang-format
This is what that script looked like:
#! /bin/bash
sed -ne '1,/^CommentPragmas:/p' < .clang-format
cat <<_____
# OpenSSL uses typedefs extensively. Tell clang-format about them.
TypeNames:
_____
include_re=$(yq -r '.repos.[].hooks.[] | select(.id == "clang-format") | .files' < .pre-commit-config.yaml)
include_dirs=( apps crypto include providers ssl )
git ls-files "${include_dirs[@]}" \
| grep -E $include_re \
| xargs ctags -f - \
| awk -F "\t" -- '$2 ~ /\.h/ && $4 == "t" { printf " - \"%s\"\n", $1 }' \
| sort \
| uniq
cat <<_____
# The following types are macros, and need to remain that way, unfortunately
- "HASH_CTX"
- "HASH_LONG"
- "MD32_REG_T"
_____
sed -ne '/^# OpenSSL uses macros extensively/,$p' < .clang-format
Original-PR: #29383
Original-Commit: aa9defa "Dump all known typedefs into .clang-format"
Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
MergeDate: Fri Apr 3 14:47:52 2026
(Merged from #29821)
openssl-machine
pushed a commit
that referenced
this pull request
Apr 3, 2026
Original-PR: #29383 Original-Commit: 16fa01b "Add a couple of DH related StatementMacros, and adjust" Reviewed-by: Nikola Pajkovsky <[email protected]> Reviewed-by: Tomas Mraz <[email protected]> MergeDate: Fri Apr 3 14:47:53 2026 (Merged from #29821)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When reformatting the source, a few spots were missed.
Furthermore, a few more StatementMacros are needed, and reformatting
following that became a bit less trippy.
Finally, OpenSSL has a huge number of typedefs that clang-format had
no information about. Also, some types were macros, which makes them
hard to find, so they are converted to proper typedefs. With all this
added to .clang-format, another reformat results in more trippiness
being made less trippy.