On Thu Jan 29, 2026 at 9:58 AM JST, John Hubbard wrote:
> On 1/28/26 4:20 PM, Danilo Krummrich wrote:
>> On Wed Jan 28, 2026 at 4:14 PM CET, Joel Fernandes wrote:
>>> On 1/28/2026 5:53 AM, Danilo Krummrich wrote:
>>>> On Mon Jan 26, 2026 at 9:23 PM CET, Joel Fernandes wrote:
>>>>> @@ -267,7 +264,12 @@ fn new_fwsec(dev: &Device<device::Bound>, bios: 
>>>>> &Vbios, cmd: FwsecCommand) -> Re
>>>>>            let ucode = bios.fwsec_image().ucode(&desc)?;
>>>>>            let mut dma_object = DmaObject::from_data(dev, ucode)?;
>>>>>    
>>>>> -        let hdr_offset = usize::from_safe_cast(desc.imem_load_size() + 
>>>>> desc.interface_offset());
>>>>> +        // Compute hdr_offset = imem_load_size + interface_offset.
>>>>
>>>> I do get the idea behind those comments, but are we sure that's really a 
>>>> good
>>>> idea? How do we ensure to keep them up to date in case we have to change 
>>>> the
>>>> code?
>>>>
>>>> If we really want this, I'd at least chose a common syntax, e.g.
>>>>
>>>>    // CALC: `imem_load_size + interface_offset`
>>>>
>>>> without the variable name the resulting value is assigned to.
>>>>
>>>> But I'd rather prefer to just drop those comments.
>>> The idea of adding these comments was to improve readability. However, I
>>> can drop them in the v3, that's fine with me.
>> 
>> Yeah, that's why I wrote "I get the idea". :) But as I write above, I'm
>> concerned about the comments getting outdated or inconsistent over time.
>> 
>> Besides that, it more seems like something your favorite editor should help 
>> with
>> instead.
>> 
>>> Do you want me to wait for additional comments on this series, or should
>>> I make the update and repost it?  Thanks,
>> 
>> As mentioned, I tend to think we should just drop them, but I'm happy to hear
>> some more opinions on this if any.
>
> Yes, please drop the comments. They were just echoing the code for
> the most part, so the code itself will be easier to read without
> them.

I agree that if the operation is a simple `checked_add`, then comments
are not necessarily useful.

However, we also have stuff like 

  let entry_offset = hdr_offset
      .checked_add(usize::from(hdr.header_size))
      .and_then(|o| o.checked_add(i.checked_mul(usize::from(hdr.entry_size))?))

Where the order of operation matters, and for these I think it is safer
to have a quick confirmation.

Thus for anything non-trivial, I'd like to keep a `// CALC: ` header
describing the intended operation. I also noticed that LLMs check that
the code is in accordance with comments, which provides an additional
layer of checking.

Reply via email to