all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Low priority] Some minor complaints from cppcheck about emacs 26.2
@ 2019-04-30 21:38 Adam Richter
  2019-04-30 22:23 ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Adam Richter @ 2019-04-30 21:38 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]

Hi, everyone.

I just tried running the version of cppcheck from the github
repository (which fixes at least one false positive report that I have
been seeing from cppcheck 1.86) on emacs 26.2 sources, and cppcheck
appears to have a found a few bugs that probably don't cause external
misbehavior, but I'm not sure are completely safe.  So, I am sending
this message with the cppcheck output attached, in the hopes that by
saving emacs developers the time of building the latest cppcheck and
doing a superficial check of the warnings, one or more people on the
list might find it worth taking a glance that the messages that I
could not rule out as completely spurious, and also in the hopes of
saving time for anyone else who runs cppcheck on emacs and sees the
same warnings.

Here is a list of files listed in the attached cppcheck and my notes about them.

lib-src/ebrowse.c  <-- Not a bug.  strdup is supposed to "leak" a malloc.

lib-src/update-game-score.c <-- I submitted a patch attached to a
message to this mailing list a few minutes ago, which I think fixes
the legitimate complaints.  The last complaint ("realloc mistake")
does not appear to be a bug.

lib/stdint.h  <-- This is a real typographical bug and I don't know
what the author intended.

lib/nstrftime.c <-- Possibly a real bug, but only if multibyte is
disabled.  A local variable "width", set to -1, is used by a macro
that I think may expect a positive value, but I am not sure of this
fix.

nt/preprep.c <-- These are complaints about
copy_executable_and_move_sections() where the variable
import_delta_rva might not be set if import_section == NULL and
rva_to_section() also returns NULL.  I am not sure if this really can
happen and if the resultant undefined value is consequential in that
case.

src/regex.c <--I think the tiny memory leak for compile_stack.stack is
real.  Everything else is probably not a legitimate complaint,
although I'm not 100% sure about that.  I think the "Uninitialized
variable" complaints about len and buf_charlen are all wrong, possibly
due to cppcheck trying all combinations of #ifdef's and perhaps
finding one that does not define the macros that set these variables.

src/regex.h <-- This complaint seems completely spurious (use of
#ifdef in the middle of a function declaration).

lib-src/etags.c <-- I believe that this complaint about a possible
null pointer dereference is spurious because filename_is_absolute()
would need to return true in one place and false in another with the
same data in order for that to happen.

Anyhow, if anyone has any questions, please feel free to ask me or
discuss on this list, as you think appropriate.  I hope this
information is helpful.

Adam

[-- Attachment #2: emacs-26.2.cppcheck.log --]
[-- Type: application/octet-stream, Size: 2497 bytes --]

[lib-src/ebrowse.c:532]: (error) Allocation with xmalloc, strcpy doesn't release it.
[lib-src/update-game-score.c:329]: (error) Memory leak: filedata
[lib-src/update-game-score.c:334]: (error) Memory leak: filedata
[lib-src/update-game-score.c:339]: (error) Memory leak: filedata
[lib-src/update-game-score.c:410]: (error) Common realloc mistake: 'newscores' nulled but not freed upon failure
[lib/stdint.h:537]: (error) Syntax error in #if
[lib/nstrftime.c:660]: (error) Invalid memset() argument nr 3. The value is -2 but the valid values are '0:'.
[lib/nstrftime.c:660]: (error) Invalid wmemset() argument nr 3. The value is -2 but the valid values are '0:'.
[nt/preprep.c:570]: (error) Uninitialized variable: import_delta_rva
[nt/preprep.c:597]: (error) Uninitialized variable: import_delta_rva
[nt/preprep.c:663]: (error) Uninitialized variable: end_block
[nt/preprep.c:669]: (error) Uninitialized variable: end_block
[src/regex.c:2563]: (error) Memory leak: compile_stack.stack
[src/regex.c:5085]: (error) Pointer addition with NULL pointer.
[src/regex.c:2563]: (error) Uninitialized variable: len
[src/regex.c:2681]: (error) Uninitialized variable: len
[src/regex.c:2688]: (error) Uninitialized variable: len
[src/regex.c:2897]: (error) Uninitialized variable: len
[src/regex.c:2904]: (error) Uninitialized variable: len
[src/regex.c:2920]: (error) Uninitialized variable: len
[src/regex.c:2923]: (error) Uninitialized variable: len
[src/regex.c:3059]: (error) Uninitialized variable: len
[src/regex.c:3076]: (error) Uninitialized variable: len
[src/regex.c:3079]: (error) Uninitialized variable: len
[src/regex.c:3270]: (error) Uninitialized variable: len
[src/regex.c:3273]: (error) Uninitialized variable: len
[src/regex.c:3288]: (error) Uninitialized variable: len
[src/regex.c:3488]: (error) Uninitialized variable: len
[src/regex.c:4327]: (error) Uninitialized variable: buf_charlen
[src/regex.c:4328]: (error) Uninitialized variable: buf_charlen
[src/regex.c:4357]: (error) Uninitialized variable: buf_charlen
[src/regex.c:4358]: (error) Uninitialized variable: buf_charlen
[src/regex.c:5445]: (error) Uninitialized variable: buf_charlen
[src/regex.c:5498]: (error) Uninitialized variable: len
[src/regex.h:485]: (error) failed to expand 're_compile_pattern', it is invalid to use a preprocessor directive as macro parameter
[lib-src/etags.c:1708] -> [lib-src/etags.c:7162] -> [lib-src/etags.c:7027]: (error) Null pointer dereference: s1

real	3m46.640s
user	3m45.640s
sys	0m0.552s

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-03  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-30 21:38 [Low priority] Some minor complaints from cppcheck about emacs 26.2 Adam Richter
2019-04-30 22:23 ` Paul Eggert
     [not found]   ` <CAGn-TggO=e07moZFCE8UoHPhpVkoL7C5Bu5u_MBRz4+zNC1FwA@mail.gmail.com>
2019-04-30 23:19     ` Adam Richter
2019-05-03  9:30   ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.