Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Jonathon Reinhart <jonathon.reinhart@gmail.com>
Cc: cocci@inria.fr
Subject: Re: [cocci] Converting strncmp() to strcmp() with SmPL
Date: Sat, 10 Dec 2022 20:10:12 +0100	[thread overview]
Message-ID: <18d760dd-fee1-97f4-4460-566f978a21f6@web.de> (raw)
In-Reply-To: <CAPFHKzeapJcz_LNYajjsKPefeCfO3ZgtYprtVBWLunk8=YgNMw@mail.gmail.com>


>> I suggest to take the following SmPL code variant also into account.
>>
>> -strncmp
>> +strcmp
>>  (x, literal
>> -           , n
>>  )
> Thanks for the suggestion. I did see that variant, and I like it for
> removing a parameter,


That is nice.



> but I feel it is less clear in this situation.


I hope that such a view can be reconsidered a bit more.

Did you get used to the expectation from other (software) areas
that only the essential changes should be specified in any code?


> Good to know that I'm not missing some other easier approach.

Further development options (and solution ideas) are in some waiting queues.


> I shouldn't have said the examples with constraints are scarce

We can get different impressions from statistics.


> -- I should have said they are difficult to locate amongst all
> of the examples that exist.
>
> Then again, I'm brand new to Coccinelle,

Further learning experiences will evolve accordingly, won't they?


> so I imagine locating the right information gets easier.

You got used to some other information sources already.



> 1. strncmp(foo, "bar", strlen("bar"))
> 2. strncmp(foo, "bar", sizeof("bar"))
>
> Neither is "wrong", per se, but the behavior is different because
> sizeof("bar") includes the NUL terminator, and thus sizeof("bar") ==
> strlen("bar")+1.


Such code specifications are questionable for some reasons.
They were discussed several times before, weren't they?

Regards,
Markus



      reply	other threads:[~2022-12-10 19:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-10  8:03 [cocci] Converting strncmp() to strcmp(): constraint on variable cannot be evaluated due to disjunction Jonathon Reinhart
2022-12-10  9:31 ` Julia Lawall
2022-12-10 12:20 ` Markus Elfring
2022-12-10 16:16   ` Jonathon Reinhart
2022-12-10 19:10     ` Markus Elfring [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18d760dd-fee1-97f4-4460-566f978a21f6@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=jonathon.reinhart@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).