Message ID | 20240722040742.11513-12-yaoxt.fnst@fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | make range overlap check more readable | expand |
On 22/7/24 06:07, Yao Xingtao via wrote: > use ranges_overlap() instead of open-coding the overlap check to improve > the readability of the code. > > Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> > --- > crypto/block-luks.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
On Mon, Jul 22, 2024 at 12:07:40AM -0400, Yao Xingtao wrote: > use ranges_overlap() instead of open-coding the overlap check to improve > the readability of the code. > > Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> > --- > crypto/block-luks.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> With regards, Daniel
diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 5b777c15d3cd..45347adeeb71 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -33,6 +33,7 @@ #include "qemu/uuid.h" #include "qemu/bitmap.h" +#include "qemu/range.h" /* * Reference for the LUKS format implemented here is @@ -572,7 +573,7 @@ qcrypto_block_luks_check_header(const QCryptoBlockLUKS *luks, header_sectors, slot2->stripes); - if (start1 + len1 > start2 && start2 + len2 > start1) { + if (ranges_overlap(start1, len1, start2, len2)) { error_setg(errp, "Keyslots %zu and %zu are overlapping in the header", i, j);
use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> --- crypto/block-luks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)