* [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning
@ 2025-03-01 23:16 Miguel Ojeda
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-01 23:16 UTC (permalink / raw)
To: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Miguel Ojeda, Alex Gaynor
Cc: dri-devel, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel, patches
Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
Clippy warns:
error: manually reimplementing `div_ceil`
--> drivers/gpu/drm/drm_panic_qr.rs:548:26
|
548 | let pad_offset = (offset + 7) / 8;
| ^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `offset.div_ceil(8)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
And similarly for `stride`. Thus apply the suggestion to both.
The behavior (and thus codegen) is not exactly equivalent [1][2], since
`div_ceil()` returns the right value for the values that currently
would overflow.
Link: https://github.com/rust-lang/rust-clippy/issues/14333 [1]
Link: https://godbolt.org/z/dPq6nGnv3 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
drivers/gpu/drm/drm_panic_qr.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_panic_qr.rs b/drivers/gpu/drm/drm_panic_qr.rs
index bcf248f69252..8bb5e52d75cc 100644
--- a/drivers/gpu/drm/drm_panic_qr.rs
+++ b/drivers/gpu/drm/drm_panic_qr.rs
@@ -545,7 +545,7 @@ fn add_segments(&mut self, segments: &[&Segment<'_>]) {
}
self.push(&mut offset, (MODE_STOP, 4));
- let pad_offset = (offset + 7) / 8;
+ let pad_offset = offset.div_ceil(8);
for i in pad_offset..self.version.max_data() {
self.data[i] = PADDING[(i & 1) ^ (pad_offset & 1)];
}
@@ -659,7 +659,7 @@ struct QrImage<'a> {
impl QrImage<'_> {
fn new<'a, 'b>(em: &'b EncodedMsg<'b>, qrdata: &'a mut [u8]) -> QrImage<'a> {
let width = em.version.width();
- let stride = (width + 7) / 8;
+ let stride = width.div_ceil(8);
let data = qrdata;
let mut qr_image = QrImage {
base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
@ 2025-03-01 23:16 ` Miguel Ojeda
2025-03-02 6:54 ` Miguel Ojeda
` (2 more replies)
2025-03-02 6:54 ` [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
` (3 subsequent siblings)
4 siblings, 3 replies; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-01 23:16 UTC (permalink / raw)
To: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Miguel Ojeda, Alex Gaynor
Cc: dri-devel, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel, patches
Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
Clippy warns:
error: doc list item overindented
--> drivers/gpu/drm/drm_panic_qr.rs:914:5
|
914 | /// will be encoded as binary segment, otherwise it will be encoded
| ^^^ help: try using ` ` (2 spaces)
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
The overindentation is slightly hard to notice, since all the items
start with a backquote that makes it look OK, but it is there.
Thus fix it.
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
---
drivers/gpu/drm/drm_panic_qr.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_panic_qr.rs b/drivers/gpu/drm/drm_panic_qr.rs
index 8bb5e52d75cc..6903e2010cb9 100644
--- a/drivers/gpu/drm/drm_panic_qr.rs
+++ b/drivers/gpu/drm/drm_panic_qr.rs
@@ -911,16 +911,16 @@ fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
///
/// * `url`: The base URL of the QR code. It will be encoded as Binary segment.
/// * `data`: A pointer to the binary data, to be encoded. if URL is NULL, it
-/// will be encoded as binary segment, otherwise it will be encoded
-/// efficiently as a numeric segment, and appended to the URL.
+/// will be encoded as binary segment, otherwise it will be encoded
+/// efficiently as a numeric segment, and appended to the URL.
/// * `data_len`: Length of the data, that needs to be encoded, must be less
-/// than data_size.
+/// than data_size.
/// * `data_size`: Size of data buffer, it should be at least 4071 bytes to hold
-/// a V40 QR code. It will then be overwritten with the QR code image.
+/// a V40 QR code. It will then be overwritten with the QR code image.
/// * `tmp`: A temporary buffer that the QR code encoder will use, to write the
-/// segments and ECC.
+/// segments and ECC.
/// * `tmp_size`: Size of the temporary buffer, it must be at least 3706 bytes
-/// long for V40.
+/// long for V40.
///
/// # Safety
///
--
2.48.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
@ 2025-03-02 6:54 ` Miguel Ojeda
2025-03-03 8:05 ` Alice Ryhl
` (2 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-02 6:54 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 12:17 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: manually reimplementing `div_ceil`
> --> drivers/gpu/drm/drm_panic_qr.rs:548:26
> |
> 548 | let pad_offset = (offset + 7) / 8;
> | ^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `offset.div_ceil(8)`
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
>
> And similarly for `stride`. Thus apply the suggestion to both.
>
> The behavior (and thus codegen) is not exactly equivalent [1][2], since
> `div_ceil()` returns the right value for the values that currently
> would overflow.
>
> Link: https://github.com/rust-lang/rust-clippy/issues/14333 [1]
> Link: https://godbolt.org/z/dPq6nGnv3 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Cc: stable@vger.kernel.org # Needed in 6.12.y and 6.13.y only (Rust is
pinned in older LTSs).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
@ 2025-03-02 6:54 ` Miguel Ojeda
2025-03-02 16:50 ` Jarkko Sakkinen
2025-03-03 8:04 ` Alice Ryhl
2025-03-03 9:41 ` Jocelyn Falempe
2 siblings, 1 reply; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-02 6:54 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 12:17 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: doc list item overindented
> --> drivers/gpu/drm/drm_panic_qr.rs:914:5
> |
> 914 | /// will be encoded as binary segment, otherwise it will be encoded
> | ^^^ help: try using ` ` (2 spaces)
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
>
> The overindentation is slightly hard to notice, since all the items
> start with a backquote that makes it look OK, but it is there.
>
> Thus fix it.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
Cc: stable@vger.kernel.org # Needed in 6.12.y and 6.13.y only (Rust is
pinned in older LTSs).
Cheers,
Miguel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-02 6:54 ` Miguel Ojeda
@ 2025-03-02 16:50 ` Jarkko Sakkinen
2025-03-02 17:45 ` Miguel Ojeda
0 siblings, 1 reply; 13+ messages in thread
From: Jarkko Sakkinen @ 2025-03-02 16:50 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Jocelyn Falempe, Thomas Böhler,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 02, 2025 at 07:54:00AM +0100, Miguel Ojeda wrote:
> On Sun, Mar 2, 2025 at 12:17 AM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> > Clippy warns:
> >
> > error: doc list item overindented
> > --> drivers/gpu/drm/drm_panic_qr.rs:914:5
> > |
> > 914 | /// will be encoded as binary segment, otherwise it will be encoded
> > | ^^^ help: try using ` ` (2 spaces)
> > |
> > = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
> >
> > The overindentation is slightly hard to notice, since all the items
> > start with a backquote that makes it look OK, but it is there.
> >
> > Thus fix it.
> >
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>
> Fixes: cb5164ac43d0 ("drm/panic: Add a QR code panic screen")
> Cc: stable@vger.kernel.org # Needed in 6.12.y and 6.13.y only (Rust is
> pinned in older LTSs).
(cosmetic) Nit:
I think you could just:
Cc: stable@vger.kernel.org # v6.12+
>
> Cheers,
> Miguel
>
BR, Jarkko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-02 16:50 ` Jarkko Sakkinen
@ 2025-03-02 17:45 ` Miguel Ojeda
2025-03-02 18:31 ` Jarkko Sakkinen
0 siblings, 1 reply; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-02 17:45 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Miguel Ojeda, Jocelyn Falempe, Thomas Böhler,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 5:50 PM Jarkko Sakkinen <jarkko@kernel.org> wrote:
>
> (cosmetic) Nit:
>
> I think you could just:
>
> Cc: stable@vger.kernel.org # v6.12+
Thanks Jarkko -- I did something similar in the past, but sometimes
patches got backported too much because they could be applied.
Normally they don't hurt, but I try to be more explicit nowadays so
that the stable team can decide, and thus I copy-paste that line for
changes that are related to new compiler cleanups and similar.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-02 17:45 ` Miguel Ojeda
@ 2025-03-02 18:31 ` Jarkko Sakkinen
2025-03-02 19:52 ` Miguel Ojeda
0 siblings, 1 reply; 13+ messages in thread
From: Jarkko Sakkinen @ 2025-03-02 18:31 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Jocelyn Falempe, Thomas Böhler,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 02, 2025 at 06:45:13PM +0100, Miguel Ojeda wrote:
> On Sun, Mar 2, 2025 at 5:50 PM Jarkko Sakkinen <jarkko@kernel.org> wrote:
> >
> > (cosmetic) Nit:
> >
> > I think you could just:
> >
> > Cc: stable@vger.kernel.org # v6.12+
>
> Thanks Jarkko -- I did something similar in the past, but sometimes
> patches got backported too much because they could be applied.
>
> Normally they don't hurt, but I try to be more explicit nowadays so
> that the stable team can decide, and thus I copy-paste that line for
> changes that are related to new compiler cleanups and similar.
Ah, ok, I guessed that you might have some backing idea on what you put
:-) Thanks for the explanation.
>
> Cheers,
> Miguel
>
BR, Jarkko
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-02 18:31 ` Jarkko Sakkinen
@ 2025-03-02 19:52 ` Miguel Ojeda
0 siblings, 0 replies; 13+ messages in thread
From: Miguel Ojeda @ 2025-03-02 19:52 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Miguel Ojeda, Jocelyn Falempe, Thomas Böhler,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 7:31 PM Jarkko Sakkinen <jarkko@kernel.org> wrote:
>
> Ah, ok, I guessed that you might have some backing idea on what you put
> :-) Thanks for the explanation.
You're welcome!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
2025-03-02 6:54 ` Miguel Ojeda
@ 2025-03-03 8:04 ` Alice Ryhl
2025-03-03 9:41 ` Jocelyn Falempe
2 siblings, 0 replies; 13+ messages in thread
From: Alice Ryhl @ 2025-03-03 8:04 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 12:17 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: doc list item overindented
> --> drivers/gpu/drm/drm_panic_qr.rs:914:5
> |
> 914 | /// will be encoded as binary segment, otherwise it will be encoded
> | ^^^ help: try using ` ` (2 spaces)
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
>
> The overindentation is slightly hard to notice, since all the items
> start with a backquote that makes it look OK, but it is there.
>
> Thus fix it.
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
2025-03-02 6:54 ` [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
@ 2025-03-03 8:05 ` Alice Ryhl
2025-03-03 9:40 ` Jocelyn Falempe
2025-03-10 7:49 ` Jocelyn Falempe
4 siblings, 0 replies; 13+ messages in thread
From: Alice Ryhl @ 2025-03-03 8:05 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Jocelyn Falempe, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor, dri-devel, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, rust-for-linux, linux-kernel, patches
On Sun, Mar 2, 2025 at 12:17 AM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: manually reimplementing `div_ceil`
> --> drivers/gpu/drm/drm_panic_qr.rs:548:26
> |
> 548 | let pad_offset = (offset + 7) / 8;
> | ^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `offset.div_ceil(8)`
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
>
> And similarly for `stride`. Thus apply the suggestion to both.
>
> The behavior (and thus codegen) is not exactly equivalent [1][2], since
> `div_ceil()` returns the right value for the values that currently
> would overflow.
>
> Link: https://github.com/rust-lang/rust-clippy/issues/14333 [1]
> Link: https://godbolt.org/z/dPq6nGnv3 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
` (2 preceding siblings ...)
2025-03-03 8:05 ` Alice Ryhl
@ 2025-03-03 9:40 ` Jocelyn Falempe
2025-03-10 7:49 ` Jocelyn Falempe
4 siblings, 0 replies; 13+ messages in thread
From: Jocelyn Falempe @ 2025-03-03 9:40 UTC (permalink / raw)
To: Miguel Ojeda, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor
Cc: dri-devel, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel, patches
On 02/03/2025 00:16, Miguel Ojeda wrote:
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: manually reimplementing `div_ceil`
> --> drivers/gpu/drm/drm_panic_qr.rs:548:26
> |
> 548 | let pad_offset = (offset + 7) / 8;
> | ^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `offset.div_ceil(8)`
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
>
> And similarly for `stride`. Thus apply the suggestion to both.
>
> The behavior (and thus codegen) is not exactly equivalent [1][2], since
> `div_ceil()` returns the right value for the values that currently
> would overflow.
Thanks, so that's the DIV_ROUND_UP equivalent I was looking for.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>
> Link: https://github.com/rust-lang/rust-clippy/issues/14333 [1]
> Link: https://godbolt.org/z/dPq6nGnv3 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> drivers/gpu/drm/drm_panic_qr.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_panic_qr.rs b/drivers/gpu/drm/drm_panic_qr.rs
> index bcf248f69252..8bb5e52d75cc 100644
> --- a/drivers/gpu/drm/drm_panic_qr.rs
> +++ b/drivers/gpu/drm/drm_panic_qr.rs
> @@ -545,7 +545,7 @@ fn add_segments(&mut self, segments: &[&Segment<'_>]) {
> }
> self.push(&mut offset, (MODE_STOP, 4));
>
> - let pad_offset = (offset + 7) / 8;
> + let pad_offset = offset.div_ceil(8);
> for i in pad_offset..self.version.max_data() {
> self.data[i] = PADDING[(i & 1) ^ (pad_offset & 1)];
> }
> @@ -659,7 +659,7 @@ struct QrImage<'a> {
> impl QrImage<'_> {
> fn new<'a, 'b>(em: &'b EncodedMsg<'b>, qrdata: &'a mut [u8]) -> QrImage<'a> {
> let width = em.version.width();
> - let stride = (width + 7) / 8;
> + let stride = width.div_ceil(8);
> let data = qrdata;
>
> let mut qr_image = QrImage {
>
> base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] drm/panic: fix overindented list items in documentation
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
2025-03-02 6:54 ` Miguel Ojeda
2025-03-03 8:04 ` Alice Ryhl
@ 2025-03-03 9:41 ` Jocelyn Falempe
2 siblings, 0 replies; 13+ messages in thread
From: Jocelyn Falempe @ 2025-03-03 9:41 UTC (permalink / raw)
To: Miguel Ojeda, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor
Cc: dri-devel, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel, patches
On 02/03/2025 00:16, Miguel Ojeda wrote:
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: doc list item overindented
> --> drivers/gpu/drm/drm_panic_qr.rs:914:5
> |
> 914 | /// will be encoded as binary segment, otherwise it will be encoded
> | ^^^ help: try using ` ` (2 spaces)
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_overindented_list_items
>
> The overindentation is slightly hard to notice, since all the items
> start with a backquote that makes it look OK, but it is there.
>
> Thus fix it.
Thanks, it looks good to me.
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> drivers/gpu/drm/drm_panic_qr.rs | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_panic_qr.rs b/drivers/gpu/drm/drm_panic_qr.rs
> index 8bb5e52d75cc..6903e2010cb9 100644
> --- a/drivers/gpu/drm/drm_panic_qr.rs
> +++ b/drivers/gpu/drm/drm_panic_qr.rs
> @@ -911,16 +911,16 @@ fn draw_all(&mut self, data: impl Iterator<Item = u8>) {
> ///
> /// * `url`: The base URL of the QR code. It will be encoded as Binary segment.
> /// * `data`: A pointer to the binary data, to be encoded. if URL is NULL, it
> -/// will be encoded as binary segment, otherwise it will be encoded
> -/// efficiently as a numeric segment, and appended to the URL.
> +/// will be encoded as binary segment, otherwise it will be encoded
> +/// efficiently as a numeric segment, and appended to the URL.
> /// * `data_len`: Length of the data, that needs to be encoded, must be less
> -/// than data_size.
> +/// than data_size.
> /// * `data_size`: Size of data buffer, it should be at least 4071 bytes to hold
> -/// a V40 QR code. It will then be overwritten with the QR code image.
> +/// a V40 QR code. It will then be overwritten with the QR code image.
> /// * `tmp`: A temporary buffer that the QR code encoder will use, to write the
> -/// segments and ECC.
> +/// segments and ECC.
> /// * `tmp_size`: Size of the temporary buffer, it must be at least 3706 bytes
> -/// long for V40.
> +/// long for V40.
> ///
> /// # Safety
> ///
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
` (3 preceding siblings ...)
2025-03-03 9:40 ` Jocelyn Falempe
@ 2025-03-10 7:49 ` Jocelyn Falempe
4 siblings, 0 replies; 13+ messages in thread
From: Jocelyn Falempe @ 2025-03-10 7:49 UTC (permalink / raw)
To: Miguel Ojeda, Thomas Böhler, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
Alex Gaynor
Cc: dri-devel, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
rust-for-linux, linux-kernel, patches
On 02/03/2025 00:16, Miguel Ojeda wrote:
> Starting with the upcoming Rust 1.86.0 (to be released 2025-04-03),
> Clippy warns:
>
> error: manually reimplementing `div_ceil`
> --> drivers/gpu/drm/drm_panic_qr.rs:548:26
> |
> 548 | let pad_offset = (offset + 7) / 8;
> | ^^^^^^^^^^^^^^^^ help: consider using `.div_ceil()`: `offset.div_ceil(8)`
> |
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
>
> And similarly for `stride`. Thus apply the suggestion to both.
>
> The behavior (and thus codegen) is not exactly equivalent [1][2], since
> `div_ceil()` returns the right value for the values that currently
> would overflow.
I pushed both patches to drm-misc-fixes, with the "Cc" tag added.
Thanks a lot for your contributions.
--
Jocelyn
>
> Link: https://github.com/rust-lang/rust-clippy/issues/14333 [1]
> Link: https://godbolt.org/z/dPq6nGnv3 [2]
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> drivers/gpu/drm/drm_panic_qr.rs | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_panic_qr.rs b/drivers/gpu/drm/drm_panic_qr.rs
> index bcf248f69252..8bb5e52d75cc 100644
> --- a/drivers/gpu/drm/drm_panic_qr.rs
> +++ b/drivers/gpu/drm/drm_panic_qr.rs
> @@ -545,7 +545,7 @@ fn add_segments(&mut self, segments: &[&Segment<'_>]) {
> }
> self.push(&mut offset, (MODE_STOP, 4));
>
> - let pad_offset = (offset + 7) / 8;
> + let pad_offset = offset.div_ceil(8);
> for i in pad_offset..self.version.max_data() {
> self.data[i] = PADDING[(i & 1) ^ (pad_offset & 1)];
> }
> @@ -659,7 +659,7 @@ struct QrImage<'a> {
> impl QrImage<'_> {
> fn new<'a, 'b>(em: &'b EncodedMsg<'b>, qrdata: &'a mut [u8]) -> QrImage<'a> {
> let width = em.version.width();
> - let stride = (width + 7) / 8;
> + let stride = width.div_ceil(8);
> let data = qrdata;
>
> let mut qr_image = QrImage {
>
> base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-03-10 7:49 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-01 23:16 [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
2025-03-01 23:16 ` [PATCH 2/2] drm/panic: fix overindented list items in documentation Miguel Ojeda
2025-03-02 6:54 ` Miguel Ojeda
2025-03-02 16:50 ` Jarkko Sakkinen
2025-03-02 17:45 ` Miguel Ojeda
2025-03-02 18:31 ` Jarkko Sakkinen
2025-03-02 19:52 ` Miguel Ojeda
2025-03-03 8:04 ` Alice Ryhl
2025-03-03 9:41 ` Jocelyn Falempe
2025-03-02 6:54 ` [PATCH 1/2] drm/panic: use `div_ceil` to clean Clippy warning Miguel Ojeda
2025-03-03 8:05 ` Alice Ryhl
2025-03-03 9:40 ` Jocelyn Falempe
2025-03-10 7:49 ` Jocelyn Falempe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.