[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH 00/13] make range overlap check more readable
From: |
Xingtao Yao (Fujitsu) |
Subject: |
RE: [PATCH 00/13] make range overlap check more readable |
Date: |
Mon, 22 Jul 2024 06:59:41 +0000 |
> -----Original Message-----
> From: Philippe Mathieu-Daudé <philmd@linaro.org>
> Sent: Monday, July 22, 2024 2:43 PM
> To: Yao, Xingtao/姚 幸涛 <yaoxt.fnst@fujitsu.com>; qemu-devel@nongnu.org
> Subject: Re: [PATCH 00/13] make range overlap check more readable
>
> Hi Yao,
>
> On 22/7/24 06:07, Yao Xingtao via wrote:
> > Currently, some components still open-coding the range overlap check.
> > Sometimes this check may be fail because some patterns are missed.
>
> How did you catch all these use cases?
I used the Coccinelle to match these use cases, the pattern is below
range_overlap.cocci:
// use ranges_overlap() instead of open-coding the overlap check
@@
expression E1, E2, E3, E4;
@@
(
- E2 <= E3 || E1 >= E4
+ !ranges_overlap(E1, E2, E3, E4)
|
- (E2 <= E3) || (E1 >= E4)
+ !ranges_overlap(E1, E2, E3, E4)
|
- E1 < E4 && E2 > E3
+ ranges_overlap(E1, E2, E3, E4)
|
- (E1 < E4) && (E2 > E3)
+ ranges_overlap(E1, E2, E3, E4)
|
- (E1 >= E3 && E1 < E4) || (E2 > E3 && E2 <= E4)
+ ranges_overlap(E1, E2, E3, E4)
|
- ((E1 >= E3) && (E1 < E4)) || ((E2 > E3) && (E2 <= E4))
+ ranges_overlap(E1, E2, E3, E4)
)
then execute the command:
# spatch --macro-file scripts/cocci-macro-file.h --sp-file range_overlap.cocci
--keep-comments --in-place --use-gitgrep --dir .
but some of the matched cases are not valid and need to be
manually judged.
there may be cases that have not been matched yet.
>
> > To avoid the above problems and improve the readability of the code,
> > it is better to use the ranges_overlap() to do this check.
> >
> > Yao Xingtao (13):
> > range: Make ranges_overlap() return bool
> > arm/boot: make range overlap check more readable
> > core/loader: make range overlap check more readable
> > cxl/mailbox: make range overlap check more readable
> > display/sm501: make range overlap check more readable
> > aspeed_smc: make range overlap check more readable
> > qtest/fuzz: make range overlap check more readable
> > sparc/ldst_helper: make range overlap check more readable
> > system/memory_mapping: make range overlap check more readable
> > block/vhdx: make range overlap check more readable
> > crypto/block-luks: make range overlap check more readable
> > dump: make range overlap check more readable
> > block/qcow2-cluster: make range overlap check more readable
- [PATCH 09/13] system/memory_mapping: make range overlap check more readable, (continued)
- [PATCH 09/13] system/memory_mapping: make range overlap check more readable, Yao Xingtao, 2024/07/22
- [PATCH 07/13] qtest/fuzz: make range overlap check more readable, Yao Xingtao, 2024/07/22
- [PATCH 03/13] core/loader: make range overlap check more readable, Yao Xingtao, 2024/07/22
- [PATCH 12/13] dump: make range overlap check more readable, Yao Xingtao, 2024/07/22
- Re: [PATCH 00/13] make range overlap check more readable, Philippe Mathieu-Daudé, 2024/07/22