[LTP] [PATCH] checkpatch: relax parenthesis style checks

Andrea Cervesato andrea.cervesato@suse.com
Wed Jul 22 09:26:04 CEST 2026


Hi Petr,

> Hi Andrea, Cyril,
> 
> I found both rules useful (more readable and more consistent code). Can we put
> it back? Over the years you will recognise on the code of single test that it
> was written/modified by several people with a different styles. And that makes
> it less readable.
> 
> * PARENTHESIS_ALIGNMENT check enforces space behind 'while' or 'if'.
> i.e. instead of:
> 	while(tst_fzsync_run_b(&fzsync_pair)) {
> have:
> 	while (tst_fzsync_run_b(&fzsync_pair)) {
> 
> cve-2014-0196.c mixes 'while()' and 'while ()'. Is it that hard to be
> consistent on it?

im not sure that rule is checking for spaces after the statements. that
rule is avoiding stuff like:

	ruleset_fd = SAFE_LANDLOCK_CREATE_RULESET(ruleset_attr,
																						sizeof(struct tst_landlock_ruleset_attr_abi1), 0);

because parenthesis should allign the attributes of the functions. that
is super ugly when functions have really long names. Instead, this would
make much more sense:


	ruleset_fd = SAFE_LANDLOCK_CREATE_RULESET(ruleset_attr,
							     sizeof(struct tst_landlock_ruleset_attr_abi1), 0);

> 
> * OPEN_ENDED_LINE asks for not ending line with '(' or '['.
> i.e. instead of this:
> 	ruleset_fd = TST_EXP_FD_SILENT(
> 								   tst_syscall(__NR_landlock_create_ruleset, ruleset_attr,
> 						   sizeof(struct tst_landlock_ruleset_attr_abi1), 0));
> have this:
> 	ruleset_fd = TST_EXP_FD_SILENT(tst_syscall(__NR_landlock_create_ruleset, ruleset_attr,
> 						   sizeof(struct tst_landlock_ruleset_attr_abi1), 0));

you choose the right example, landlock testing suite has been updated to
match this rule and now it has stuff like:

	apply_landlock_fs_layer(ruleset_attr, sizeof(struct tst_landlock_ruleset_attr_abi1),
				path_beneath_attr, MNTPOINT, LANDLOCK_ACCESS_FS_IOCTL_DEV);

instead of

	apply_landlock_fs_layer(
				ruleset_attr,
				sizeof(struct tst_landlock_ruleset_attr_abi1),
				path_beneath_attr,
				MNTPOINT,
				LANDLOCK_ACCESS_FS_IOCTL_DEV
	);

that is more clear what are the functions attributes.

For the second one, maybe it's more like a personal preference, but the
first rule is actually generating a lot of weird code when functions and
attributes have long names, forcing to write long lines without staying
into the 80-100 chars.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com


More information about the ltp mailing list