On Thu, Aug 20, 2015 at 10:46 AM, Scott Doctor <scott at scottdoctor.com>
wrote:

> My opinion is to keep it portable. The warning is there for a reason. you
> are worried about performance yet are calling a function that does nothing,
> which will take more memory cycles than a simple check for zero.
>

I didn't say don't make a change. I'm observing there are things to
consider. In particular the optimization strategies that the SQLite team
have pursued for several years now have been *tiny* little optimizations
that would never be justifiable on their own but that really add up,
particularly for small devices probably running on batteries.


> Trying to memset a zero length is a bug, not the warning. Add an if
> statement around it. If the variable is local, it will probably be
> optimized as a register variable and a zero check of a register is a single
> op-code.
>

Trying to memset a zero length buffer is not a bug if the length of the
sequence of bytes that needs to be set is zero. C89 in particular does not
disallow this use.


> the problem with disabling warnings is that even if this instance is not
> an error, some other part of the code may end up with the same situation
> but is an error in the coding. I would prefer code that can be compiled
> with all warnings turned on that gives no warnings than have a potential
> problem because of a glitch in the code.
>

I don't think anyone called for disabling the warning. I think it should
just be ignored in this case, just as I ignore warnings that are generated
by Visual C++ when I compile SQLite there.

-- 
Scott Robison

Reply via email to