POV-Ray : Newsgroups : povray.programming : code cleanup : code cleanup Server Time
10 Oct 2024 03:13:56 EDT (-0400)
  code cleanup  
From: hexcoder
Date: 15 Aug 2017 15:55:01
Message: <web.599340ed879ff37936107e040@news.povray.org>
Hi,
i just ran cppcheck for povray sources:

[libraries/tiff/libtiff/tif_ojpeg.c:925]: (error) Invalid number of character
'(' when these macros are defined: 'C_LOSSLESS_SUPPORTED;OJPEG_SUPPORT;never'.

ok, 'never' should obviously never be defined, otherwise it would not compile.

[libraries/tiff/contrib/stream/tiffstream.cpp:117]: (error) Uninitialized
variable: ostr

 ostream* ostr;
 if(ts->m_outStream != NULL) {
     ostr = ts->m_outStream;
 } else if(ts->m_ioStream != NULL) {
     ostr = ts->m_ioStream;
 }

 streampos start = ostr->tellp();

Here another else branch would be good in order to handle the case of
ts->m_outStream == NULL and ts->m_ioStream == NULL
(if that is possible (who knows))

[libraries/tiff/tools/tiffsplit.c:64]: (error) Buffer overrun possible for long
command line arguments.

might be triggered from the outside, if tiffsplit is used at all.


[source/base/povmscpp.cpp:1757]: (error) Memory leak: nodeptr

In case of an exception nodeptr cannot be freed anymore...

[source/base/povmscpp.cpp:1781]: (error) Memory leak: nodeptr

In case of an exception nodeptr cannot be freed anymore...

In both cases could

 err = POVMS_InstallReceiver(context, ReceiveHandler, hclass, hid, (void
*)this);
 if(err != pov_base::kNoErr)
  throw POV_EXCEPTION_CODE(err);

be moved to the beginning of the method? I see no dependency to local variables
here.

[windows/cmedit/ccodemax.cpp:289]:
[windows/cmedit/ccodemax.cpp:305]:
[windows/cmedit/ccodemax.cpp:321]:
[windows/cmedit/ccodemax.cpp:685]:
[windows/cmedit/ccodemax.cpp:699]:
The return value of malloc() should be checked before usage.

Hope you find that useful, best regards Heiko


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.