[Libreoffice] About cppcheck 2 reports for desktop/unx/source/file_image_unx.c
michael.meeks at suse.com
Mon Jan 9 02:31:36 PST 2012
On Sun, 2012-01-08 at 03:25 -0800, julien2412 wrote:
> For the file desktop/unx/source/file_image_unx.c, cppcheck tells :
> line 120 is : w.m_size -= w.m_size;
> Either this is right and it could be simplified with w.m_size = 0
> or it's wrong and what should it be ?
> (this time no overload operator trick since it's plain C :-) )
Assign to zero - it's fine ;-)
> 93 unreadVariable style Variable 'c' is assigned a value that is never used
> line 93 is : volatile char c = 0
> Should this variable just be removed or c should be used in a way ?
This is in fact deliberate; I'd add a comment in the source:
/* force touching of each page despite the optimizer */
The basic problem is that we memory map the file, and then want to
force each page in turn into memory - the issue with that is that we
don't really care what is there; so we do this bogus XOR sum in 'c' -
but without the volatile clever compilers will realise that this is not
doing anything and optimise it all away - so we will touch no pages, and
the I/O will not get done, and 'pagein' becomes a no-op ;-)
> For both of them, if there's a easy fix, I suppose I may commit/push it on
> master, but on branch 3.5 too ?
Best to have cleanups just on master I think unless they are bug fixes.
Anyhow - thanks for catching this :-)
All the best,
michael.meeks at suse.com <><, Pseudo Engineer, itinerant idiot
More information about the LibreOffice