check-syntax: update arguments for astyle v3.2 (possibly earlier)
Paul Moore
maintainerPATCH 1/3 check-syntax: update arguments for astyle v3.2 (possibly earlier)
Update the astyle arguments in tools/check-syntax to work with modern version of astyle.
It is worth mentioning that astyle v3.6.3 appears to have a problem with aligning/indenting continuation lines, preferring blind indentation over alignment.
--- tools/check-syntax | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/check-syntax +1 -2
@@ -57,10 +57,9 @@ function tool_c_style() { astyle --options=none --lineend=linux --mode=c \ --style=linux \ --indent=force-tab=8 \ - --indent-preprocessor \ --indent-col1-comments \ --min-conditional-indent=0 \ - --max-instatement-indent=80 \ + --max-continuation-indent=80 \ --pad-oper \ --align-pointer=name \ --align-reference=name \
Signature · 1 line
2.47.0
Paul Moore
maintainerPATCH 2/3 check-syntax: ignore "bad" astyle versions
Create a list of known bad versions of astyle and ignore them.
--- tools/check-syntax | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
tools/check-syntax +20 -11
@@ -54,17 +54,26 @@ EOF # 1 Source file # function tool_c_style() { - astyle --options=none --lineend=linux --mode=c \ - --style=linux \ - --indent=force-tab=8 \ - --indent-col1-comments \ - --min-conditional-indent=0 \ - --max-continuation-indent=80 \ - --pad-oper \ - --align-pointer=name \ - --align-reference=name \ - --max-code-length=80 \ - --break-after-logical < "$1" + # filter on astyle version + case "$(astyle -V)" in + "Artistic Style Version 3.6.3") + # continuation lines indented vs aligned + cat "$1" + ;; + *) + astyle --options=none --lineend=linux --mode=c \ + --style=linux \ + --indent=force-tab=8 \ + --indent-col1-comments \ + --min-conditional-indent=0 \ + --max-continuation-indent=80 \ + --pad-oper \ + --align-pointer=name \ + --align-reference=name \ + --max-code-length=80 \ + --break-after-logical < "$1" + ;; + esac } #
Signature · 1 line
2.47.0
Paul Moore
maintainerPATCH 3/3 all: coding style fixes
In reply to Paul MooreFixed using astyle v3.6.2.
--- tests/file/test_sigiotask.c | 2 +- tests/ioctl/test_noioctl.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
tests/file/test_sigiotask.c +1 -1
@@ -58,7 +58,7 @@ int main(int argc, char **argv)/* * Spawn off the child process to handle the information protocol. */ -if ( (pid =fork ()) <0 ) { +if ((pid =fork ()) <0 ) {perror ("test_sigiotask:fork" );exit (2 ); }
tests/ioctl/test_noioctl.c +2 -2
@@ -63,7 +63,7 @@ int main(int argc, char **argv)* < 2.6.27 or >= 2.6.39: Should only check FD__USE and succeed. */ rc =ioctl (fd,FIONBIO , &val); -if ( !rc == !useaccessmode ) { +if (!rc == !useaccessmode ) {printf ("test_noioctl:FIONBIO" );exit (1 ); }
@@ -74,7 +74,7 @@ int main(int argc, char **argv)* Old: Should hit the FILE__GETATTR test and fail. */ rc =ioctl (fd,FS_IOC_GETVERSION , &val); -if ( (useaccessmode && rc ==0 ) || +if ((useaccessmode && rc ==0 ) || (!useaccessmode && rc <0 && errno !=ENOTTY ) ) {perror ("test_noioctl:FS_IOC_GETVERSION" );exit (1 );
Signature · 1 line
2.47.0
Quoted 30 lines · Paul Moore
Update the astyle arguments in
tools/check-syntaxto work with modern version of astyle.It is worth mentioning that astyle v3.6.3 appears to have a problem with aligning/indenting continuation lines, preferring blind indentation over alignment.
Signed-off-by Paul Moore <[email protected]>--- tools/check-syntax | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tools/check-syntax +1
-3@@ -57,10 +57,9 @@ function tool_c_style() { astyle --options=none --lineend=linux --mode=c \ --style=linux \ --indent=force-tab=8 \ - --indent-preprocessor \ --indent-col1-comments \ --min-conditional-indent=0 \ - --max-instatement-indent=80 \ + --max-continuation-indent=80 \ --pad-oper \ --align-pointer=name \ --align-reference=name \ --
Quoted 3 lines
2.47.0
Thanks! I applied these with some changes:
1. I dropped patch 2 because I don't like the idea of filtering out known bad versions.
2. I updated patch 3 with what astyle 3.6.6 enforces (this version is now in Fedora 41 and it finally doesn't have buggy behavior with the testsuite's inputs).
The style-check job now passes successfully.
https://github.com/SELinuxProject/selinux-testsuite/commit/0f3dec2ab35e8739bb31bab8e6fcae51010c557c
https://github.com/SELinuxProject/selinux-testsuite/commit/68ff0417fd8ac0e5c9c5897a31dd3c7d17201306
--
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel Red Hat, Inc.