The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] cgroup: drop unneeded semicolon
@ 2026-08-01 19:09 Julia Lawall
  2026-08-01 23:37 ` Waiman Long
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2026-08-01 19:09 UTC (permalink / raw)
  To: Tejun Heo
  Cc: kernel-janitors, Johannes Weiner, Michal Koutný, cgroups,
	linux-kernel

When a function-like macro expands to an expression, that expression
doesn't need a semicolon after it.  All uses have been verified to
have their own semicolons.

This was found using the following Coccinelle semantic patch:

@r@
identifier i : script:ocaml() { String.lowercase_ascii i = i };
expression e;
@@

*#define i(...) e;

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 kernel/cgroup/cgroup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 38f8d9df8..f87fc4550 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -104,7 +104,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
 #define cgroup_assert_mutex_or_rcu_locked()				\
 	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&			\
 			   !lockdep_is_held(&cgroup_mutex),		\
-			   "cgroup_mutex or RCU read lock required");
+			   "cgroup_mutex or RCU read lock required")
 
 /*
  * cgroup destruction makes heavy use of work items and there can be a lot


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cgroup: drop unneeded semicolon
  2026-08-01 19:09 [PATCH] cgroup: drop unneeded semicolon Julia Lawall
@ 2026-08-01 23:37 ` Waiman Long
  2026-08-02  3:11   ` Tejun Heo
  2026-08-02  6:47   ` Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: Waiman Long @ 2026-08-01 23:37 UTC (permalink / raw)
  To: Julia Lawall, Tejun Heo
  Cc: kernel-janitors, Johannes Weiner, Michal Koutný, cgroups,
	linux-kernel

On 8/1/26 3:09 PM, Julia Lawall wrote:
> When a function-like macro expands to an expression, that expression
> doesn't need a semicolon after it.  All uses have been verified to
> have their own semicolons.
>
> This was found using the following Coccinelle semantic patch:
>
> @r@
> identifier i : script:ocaml() { String.lowercase_ascii i = i };
> expression e;
> @@
>
> *#define i(...) e;
>
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
>
> ---
>   kernel/cgroup/cgroup.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index 38f8d9df8..f87fc4550 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -104,7 +104,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
>   #define cgroup_assert_mutex_or_rcu_locked()				\
>   	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&			\
>   			   !lockdep_is_held(&cgroup_mutex),		\
> -			   "cgroup_mutex or RCU read lock required");
> +			   "cgroup_mutex or RCU read lock required")
>   
>   /*
>    * cgroup destruction makes heavy use of work items and there can be a lot
>
The RCU_LOCKDEP_WARN() macro is basically a "do { ...} while (0...)" 
statement. It doesn't have a ';' at the end.  So your commit log isn't 
right.

An additional semicolon at the end doesn't harm. By removing the 
semicolon, even if not needed, may make people wonder if it is right 
when reading the code wasting their time to figure out if it is all 
right. So I don't see any advantage in removing it.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cgroup: drop unneeded semicolon
  2026-08-01 23:37 ` Waiman Long
@ 2026-08-02  3:11   ` Tejun Heo
  2026-08-02  3:31     ` Waiman Long
  2026-08-02  6:47   ` Julia Lawall
  1 sibling, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2026-08-02  3:11 UTC (permalink / raw)
  To: Waiman Long
  Cc: Julia Lawall, kernel-janitors, Johannes Weiner,
	Michal Koutný, cgroups, linux-kernel

Hello,

On Sat, Aug 01, 2026 at 07:37:13PM -0400, Waiman Long wrote:
> > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> > index 38f8d9df8..f87fc4550 100644
> > --- a/kernel/cgroup/cgroup.c
> > +++ b/kernel/cgroup/cgroup.c
> > @@ -104,7 +104,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
> >   #define cgroup_assert_mutex_or_rcu_locked()				\
> >   	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&			\
> >   			   !lockdep_is_held(&cgroup_mutex),		\
> > -			   "cgroup_mutex or RCU read lock required");
> > +			   "cgroup_mutex or RCU read lock required")
> >   /*
> >    * cgroup destruction makes heavy use of work items and there can be a lot
> > 
> The RCU_LOCKDEP_WARN() macro is basically a "do { ...} while (0...)"
> statement. It doesn't have a ';' at the end.  So your commit log isn't
> right.
> 
> An additional semicolon at the end doesn't harm. By removing the semicolon,
> even if not needed, may make people wonder if it is right when reading the
> code wasting their time to figure out if it is all right. So I don't see any
> advantage in removing it.

I think the extra semicolon can hurt. Imagine something like this:

        if (blah)
                cgroup_assert_mutex_or_rcu_locked();
        else
                something else;

This should work but with the extra semicolon, it doesn't. I don't see why
we wouldn't fix this. It's obviously wrong.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cgroup: drop unneeded semicolon
  2026-08-02  3:11   ` Tejun Heo
@ 2026-08-02  3:31     ` Waiman Long
  0 siblings, 0 replies; 5+ messages in thread
From: Waiman Long @ 2026-08-02  3:31 UTC (permalink / raw)
  To: Tejun Heo
  Cc: Julia Lawall, kernel-janitors, Johannes Weiner,
	Michal Koutný, cgroups, linux-kernel

On 8/1/26 11:11 PM, Tejun Heo wrote:
> Hello,
>
> On Sat, Aug 01, 2026 at 07:37:13PM -0400, Waiman Long wrote:
>>> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
>>> index 38f8d9df8..f87fc4550 100644
>>> --- a/kernel/cgroup/cgroup.c
>>> +++ b/kernel/cgroup/cgroup.c
>>> @@ -104,7 +104,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
>>>    #define cgroup_assert_mutex_or_rcu_locked()				\
>>>    	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&			\
>>>    			   !lockdep_is_held(&cgroup_mutex),		\
>>> -			   "cgroup_mutex or RCU read lock required");
>>> +			   "cgroup_mutex or RCU read lock required")
>>>    /*
>>>     * cgroup destruction makes heavy use of work items and there can be a lot
>>>
>> The RCU_LOCKDEP_WARN() macro is basically a "do { ...} while (0...)"
>> statement. It doesn't have a ';' at the end.  So your commit log isn't
>> right.
>>
>> An additional semicolon at the end doesn't harm. By removing the semicolon,
>> even if not needed, may make people wonder if it is right when reading the
>> code wasting their time to figure out if it is all right. So I don't see any
>> advantage in removing it.
> I think the extra semicolon can hurt. Imagine something like this:
>
>          if (blah)
>                  cgroup_assert_mutex_or_rcu_locked();
>          else
>                  something else;
>
> This should work but with the extra semicolon, it doesn't. I don't see why
> we wouldn't fix this. It's obviously wrong.

OK, I think I have misread the patch. Right, the extra ';' should be 
removed. Sorry for the noise.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cgroup: drop unneeded semicolon
  2026-08-01 23:37 ` Waiman Long
  2026-08-02  3:11   ` Tejun Heo
@ 2026-08-02  6:47   ` Julia Lawall
  1 sibling, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2026-08-02  6:47 UTC (permalink / raw)
  To: Waiman Long
  Cc: Tejun Heo, kernel-janitors, Johannes Weiner, Michal Koutný,
	cgroups, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1875 bytes --]



On Sat, 1 Aug 2026, Waiman Long wrote:

> On 8/1/26 3:09 PM, Julia Lawall wrote:
> > When a function-like macro expands to an expression, that expression
> > doesn't need a semicolon after it.  All uses have been verified to
> > have their own semicolons.
> >
> > This was found using the following Coccinelle semantic patch:
> >
> > @r@
> > identifier i : script:ocaml() { String.lowercase_ascii i = i };
> > expression e;
> > @@
> >
> > *#define i(...) e;
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
> >
> > ---
> >   kernel/cgroup/cgroup.c |    2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> > index 38f8d9df8..f87fc4550 100644
> > --- a/kernel/cgroup/cgroup.c
> > +++ b/kernel/cgroup/cgroup.c
> > @@ -104,7 +104,7 @@ DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
> >   #define cgroup_assert_mutex_or_rcu_locked()				\
> >   	RCU_LOCKDEP_WARN(!rcu_read_lock_held() &&			\
> >   			   !lockdep_is_held(&cgroup_mutex),		\
> > -			   "cgroup_mutex or RCU read lock required");
> > +			   "cgroup_mutex or RCU read lock required")
> >     /*
> >    * cgroup destruction makes heavy use of work items and there can be a lot
> >
> The RCU_LOCKDEP_WARN() macro is basically a "do { ...} while (0...)"
> statement. It doesn't have a ';' at the end.  So your commit log isn't right.

OK.  Indeed I didn't take into account the definition of the macro.  The
usage context does have another semincolon, which is what is mentioned in
the commit log.

>
> An additional semicolon at the end doesn't harm. By removing the semicolon,
> even if not needed, may make people wonder if it is right when reading the
> code wasting their time to figure out if it is all right. So I don't see any
> advantage in removing it.

No problem to drop the patch if you don't think it's useful.

julia

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-02  6:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-01 19:09 [PATCH] cgroup: drop unneeded semicolon Julia Lawall
2026-08-01 23:37 ` Waiman Long
2026-08-02  3:11   ` Tejun Heo
2026-08-02  3:31     ` Waiman Long
2026-08-02  6:47   ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox