Documentation/process/coding-style.rst explicitly notes that if only one
branch of a conditional statement is a single statement, braces should
be used in both branches. Enforce this in mm/hugetlb.c.
No functional change intended.
Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
---
mm/hugetlb.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 432a5054ca1d..75f002f18365 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -578,8 +578,9 @@ hugetlb_resv_map_add(struct resv_map *map, struct list_head *rg, long from,
record_hugetlb_cgroup_uncharge_info(cg, h, map, nrg);
list_add(&nrg->link, rg);
coalesce_file_region(map, nrg);
- } else
+ } else {
*regions_needed += 1;
+ }
return to - from;
}
@@ -1247,8 +1248,9 @@ void hugetlb_dup_vma_private(struct vm_area_struct *vma)
if (vma_lock && vma_lock->vma != vma)
vma->vm_private_data = NULL;
- } else
+ } else {
vma->vm_private_data = NULL;
+ }
}
/*
@@ -2076,8 +2078,9 @@ int dissolve_free_hugetlb_folio(struct folio *folio)
h->max_huge_pages++;
goto out;
}
- } else
+ } else {
rc = 0;
+ }
update_and_free_hugetlb_folio(h, folio, false);
return rc;
@@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
* be consumed on a subsequent allocation.
*/
folio_set_hugetlb_restore_reserve(folio);
- } else
+ } else {
/*
* No reservation present, do nothing
*/
vma_end_reservation(h, vma, address);
+
+ }
}
}
@@ -4703,10 +4708,12 @@ static void hugetlb_vm_op_open(struct vm_area_struct *vma)
if (vma_lock->vma != vma) {
vma->vm_private_data = NULL;
hugetlb_vma_lock_alloc(vma);
- } else
+ } else {
pr_warn("HugeTLB: vma_lock already exists in %s.\n", __func__);
- } else
+ }
+ } else {
hugetlb_vma_lock_alloc(vma);
+ }
}
}
--
2.47.3
On 1/15/26 19:14, Joshua Hahn wrote:
> Documentation/process/coding-style.rst explicitly notes that if only one
> branch of a conditional statement is a single statement, braces should
> be used in both branches. Enforce this in mm/hugetlb.c.
>
> No functional change intended.
>
> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> ---
[...]
> update_and_free_hugetlb_folio(h, folio, false);
> return rc;
> @@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
> * be consumed on a subsequent allocation.
> */
> folio_set_hugetlb_restore_reserve(folio);
> - } else
> + } else {
> /*
> * No reservation present, do nothing
> */
> vma_end_reservation(h, vma, address);
> +
But why the empty line? :)
> + }
> }
> }
--
Cheers
David
On Thu, 15 Jan 2026 21:10:41 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:
> On 1/15/26 19:14, Joshua Hahn wrote:
> > Documentation/process/coding-style.rst explicitly notes that if only one
> > branch of a conditional statement is a single statement, braces should
> > be used in both branches. Enforce this in mm/hugetlb.c.
> >
> > No functional change intended.
> >
> > Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> > ---
>
> [...]
>
> > update_and_free_hugetlb_folio(h, folio, false);
> > return rc;
> > @@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
> > * be consumed on a subsequent allocation.
> > */
> > folio_set_hugetlb_restore_reserve(folio);
> > - } else
> > + } else {
> > /*
> > * No reservation present, do nothing
> > */
> > vma_end_reservation(h, vma, address);
> > +
>
> But why the empty line? :)
Hello David,
Whoops, I totally forgot to run checkpatch on this one. I think Andrew
also noticed this, he sent a fixlet for it. Sorry for this! I'll fix it up
in v2.
Thanks again, have a great day David!
Joshua
On Thu, 15 Jan 2026 16:14:46 -0500 Joshua Hahn <joshua.hahnjy@gmail.com> wrote:
> On Thu, 15 Jan 2026 21:10:41 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:
>
> > On 1/15/26 19:14, Joshua Hahn wrote:
> > > Documentation/process/coding-style.rst explicitly notes that if only one
> > > branch of a conditional statement is a single statement, braces should
> > > be used in both branches. Enforce this in mm/hugetlb.c.
> > >
> > > No functional change intended.
> > >
> > > Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> > > ---
> >
> > [...]
> >
> > > update_and_free_hugetlb_folio(h, folio, false);
> > > return rc;
> > > @@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
> > > * be consumed on a subsequent allocation.
> > > */
> > > folio_set_hugetlb_restore_reserve(folio);
> > > - } else
> > > + } else {
> > > /*
> > > * No reservation present, do nothing
> > > */
> > > vma_end_reservation(h, vma, address);
> > > +
> >
> > But why the empty line? :)
>
> Hello David,
>
> Whoops, I totally forgot to run checkpatch on this one. I think Andrew
> also noticed this, he sent a fixlet for it.
I did.
> Sorry for this! I'll fix it up in v2.
I'm not actually seeing a need for a v2, unless something else changed?
On 1/15/26 22:14, Joshua Hahn wrote:
> On Thu, 15 Jan 2026 21:10:41 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:
>
>> On 1/15/26 19:14, Joshua Hahn wrote:
>>> Documentation/process/coding-style.rst explicitly notes that if only one
>>> branch of a conditional statement is a single statement, braces should
>>> be used in both branches. Enforce this in mm/hugetlb.c.
>>>
>>> No functional change intended.
>>>
>>> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
>>> ---
>>
>> [...]
>>
>>> update_and_free_hugetlb_folio(h, folio, false);
>>> return rc;
>>> @@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
>>> * be consumed on a subsequent allocation.
>>> */
>>> folio_set_hugetlb_restore_reserve(folio);
>>> - } else
>>> + } else {
>>> /*
>>> * No reservation present, do nothing
>>> */
>>> vma_end_reservation(h, vma, address);
>>> +
>>
>> But why the empty line? :)
>
> Hello David,
>
> Whoops, I totally forgot to run checkpatch on this one. I think Andrew
> also noticed this, he sent a fixlet for it. Sorry for this! I'll fix it up
> in v2.
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
with that ;)
--
Cheers
David
On Thu, 15 Jan 2026 22:16:12 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:
> On 1/15/26 22:14, Joshua Hahn wrote:
> > On Thu, 15 Jan 2026 21:10:41 +0100 "David Hildenbrand (Red Hat)" <david@kernel.org> wrote:
> >
> >> On 1/15/26 19:14, Joshua Hahn wrote:
> >>> Documentation/process/coding-style.rst explicitly notes that if only one
> >>> branch of a conditional statement is a single statement, braces should
> >>> be used in both branches. Enforce this in mm/hugetlb.c.
> >>>
> >>> No functional change intended.
> >>>
> >>> Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>
> >>> ---
> >>
> >> [...]
> >>
> >>> update_and_free_hugetlb_folio(h, folio, false);
> >>> return rc;
> >>> @@ -2672,11 +2675,13 @@ void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,
> >>> * be consumed on a subsequent allocation.
> >>> */
> >>> folio_set_hugetlb_restore_reserve(folio);
> >>> - } else
> >>> + } else {
> >>> /*
> >>> * No reservation present, do nothing
> >>> */
> >>> vma_end_reservation(h, vma, address);
^ The space here seems unnecessary?
> >>> +
> >>
> >> But why the empty line? :)
> >
> > Hello David,
> >
> > Whoops, I totally forgot to run checkpatch on this one. I think Andrew
> > also noticed this, he sent a fixlet for it. Sorry for this! I'll fix it up
> > in v2.
>
> Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
>
> with that ;)
Regardless of my finding, but assuming you will fix David's finding ;) please
feel free to add below to the v2.
Reviewed-by: SeongJae PArk <sj@kernel.org>
Thanks,
SJ
[...]
© 2016 - 2026 Red Hat, Inc.