Re: Latest SQLite vs. Xcode's Analyze : 61 issues
Re: Latest SQLite vs. Xcode's Analyze : 61 issues
- Subject: Re: Latest SQLite vs. Xcode's Analyze : 61 issues
- From: Jens Alfke <email@hidden>
- Date: Thu, 13 Sep 2012 10:19:05 -0700
On Sep 13, 2012, at 12:31 AM, Dix Lorenz < email@hidden> wrote: That's the difference. The analyzer is saying "This is code that can easily be misused. Consider rewriting it.", not "this code is wrong”.
I disagree about “can easily be misused”. Pointer parameters are pretty ubiquitous. Adding NULL checks on every function call that takes a pointer adds overhead (which is quite significant in a low-level performance-sensitive library like SQLite). It also either adds error conditions that the caller then has to check, or results in something like an assertion failure which is the moral equivalent of a crash so it hasn’t really improved reliability. I prefer interfaces that cannot be misused to "pretty likely currently not being misused”.
In general it’s impossible to create interfaces that can’t be misused. Any API of any complexity has requirements about how you call it. For example if this interface could be changed to pass a reference (no idea if this is C or C++), there would not be the shadow of a doubt that you must pass a valid object. SQLite is C. It’s also an extremely reliable and very widely-deployed piece of software, so don’t casually dismiss its approach to reliability and testing.
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden