Re: [PATCH v2 1/2] staging: rtl8723bs: Improve code readability
From: Julia Lawall
Date: Wed Apr 09 2025 - 11:43:47 EST
> > > @@ -729,10 +721,9 @@ static void hal_ReadEFuse_WiFi(
> > > }
> > >
> > > if (offset < EFUSE_MAX_SECTION_8723B) {
> > > - u16 addr;
> > > + u16 addr = offset * PGPKT_DATA_SIZE;
> > > /* Get word enable value from PG header
> > > */
> > >
> > > - addr = offset * PGPKT_DATA_SIZE;
> >
> > I'm not sure about this one, due to the comment.
> Hello Julia, I have observed in some scenarios where the semantic patch
> deletes the comments that exist between the declaration and
> initialization which I think it's not okay and in this scenario where
> the comments are left dangling such as this. How do I go about this
> instances.
> Thank you.
Making the right choice depends on the semantics of the comment, which is
out of the scope of Coccinelle. Generally, if a complete block of code is
dropped, any comments within it are dropped as well. Here the comment is
kept, which seems reasonable. The issue is that you may have moved code
that is relevant to the comment up above the comment. Ultimately, you have
to decide what to do and what not to do. If you let Coccinelle make a
patch, and then apply the patch, in the meantime you can just remove the
parts of the patch you don't like. If you make the changes in place, you
can use git add -p to add the changes you like, and not add the others, and
then use git checkout to remove the changes you don't want to do. I would
take the former approach, but some people may take the latter.
julia