GNOME Bugzilla – Bug 740382
Fixing Cppcheck warnings
Last modified: 2014-11-20 12:32:09 UTC
Created attachment 291023 [details] [review] Patch Cppcheck found a few issues in gedit. Attached patch fixes a typo and a few memory leaks.
Created attachment 291024 [details] Cppcheck plain text report Cppcheck detects more issues, mostly memory leaks in plugins and wrong memory usage. Attach contains a list of remaining issues.
Review of attachment 291023 [details] [review]: Thanks. A few comments below, otherwise it looks good. ::: gedit/gedit-preferences-dialog.c @@ +658,3 @@ + if (!g_file_set_contents (dest_name, contents, length, error)) { + g_free (contents); The code convention in gedit is: if (blah) { } Normally around one-line blocks too, but some old code doesn't always do that. ::: gedit/gedit-print-preview.c @@ +568,3 @@ priv = preview->priv; + if (priv->tile_h <= 0 || priv->tile_w <= 0) Please create a separate commit for this change.
(In reply to comment #1) > Cppcheck detects more issues, mostly memory leaks in plugins and wrong memory > usage. Attach contains a list of remaining issues. It looks like a very useful tool.
(In reply to comment #2) Fixed, make a patchset for these two changes.
Created attachment 291054 [details] [review] Patch fixing memory leaks
Created attachment 291055 [details] [review] Patch fixing typo
(In reply to comment #3) > > It looks like a very useful tool. Yep, it can found many common mistakes. You need to set it flags correctly to have a good result. I run it on gedit like this: [gedit root dir] $ cppcheck --library=gtk --force --enable=warning,performance,style --inconclusive --suppressions-list=sup.list 2>errors.log Suppressions list contains these two lines, for warnings which appear in C projects a lot: unusedStructMember variableScope Also, Cppcheck can generate xml and then produce a nice html report. I've set up a regular checking of some free projects with it, including gedit. I'll try to fix more warnings later =)
Thanks, I've pushed the commits to the master branch (it'll also be available for the 3.14 version).