[SOLVED] Re: Cppcheck: 'TimeBuffer' is not assigned a value in basic module

Julien Nabet serval2412 at yahoo.fr
Tue Feb 12 03:00:47 PST 2013


On 12/02/2013 11:00, Noel Power wrote:
> Hi Julien
> On 12/02/13 09:00, julien2412 wrote:
>> Cppcheck reported this:
>> basic/source/comp/sbcomp.cxx
>> 600    unassignedVariable    style    Variable 'TimeBuffer' is not 
>> assigned a value.
>> ...
>>
>> By taking a look at the file, I notice there was 1 #ifdef 
>> DBG_TRACE_BASIC
>> and several blocks of #ifdef DBG_TRACE_PROFILING. Is it really useful 
>> to keep both? What about removing DBG_TRACE_PROFILING and considerin 
>> that
>> DBG_TRACE_BASIC should enable all debug (Basic + profiling) ?
>>
> I never used this snazy debug support but always wanted to check it 
> out, being able to dump out the pcode ( which at a quick glance seems 
> to be supported ) is *very* useful.
> I am not convinced the timing information support offered when 
> DBG_TRACE_PROFILING is really useful ( cachegrind etc seem a better 
> choice for that ) But.. then again a cheap and nasty indicator doesn't 
> do any harm, personally I would not lump the 2 together I would guess 
> the timer related output if it were always on would introduce lots of 
> *noise* into the trace info. For me the choice would be either squash 
> the warning or remove (carefully) the DBG_TRACE_PROFILING related 
> functionality ( and the offending variable).
> Now IMHO removing that stuff is probably more effort than it's worth 
> and squashing the warning would be the easiest thing to do.
>
> would
> TimerBuffer[0]  = '\0' satisfy cppcheck or is the following statement 
> legal
> char TimeBuffer[200="";
> ( it works for me on gcc but would not bet its really valid c++ )
Thank you Noel for your detailed answer. I pushed a fix on master (see 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=fc27fec0543009dbb6c6ca002283564215aae4b1).

After having read some forums like stackoverflow, it seems the standard 
and secure way was "memset". (std::fill seemed to me appropriate for 
more "C++ish" elements like vectors than for an array of chars)

Julien


More information about the LibreOffice mailing list