Skip to content

Commit

Permalink
cppcheck: Add inline suppressions for false-positives
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed May 2, 2024
1 parent a235afb commit fbd308f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions geanyctags/src/geanyctags.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ static void spawn_cmd(const gchar *cmd, const gchar *dir)
msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s", out);
}

/* cppcheck-suppress mismatchAllocDealloc symbolName=argv
* argv is built manually, but is a valid GStrv */
g_strfreev(argv);
g_free(working_dir);
g_free(out);
Expand Down
1 change: 1 addition & 0 deletions geanygendoc/src/ggd-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ggd_opt_group_add_entry (GgdOptGroup *group,

g_array_append_val (group->prefs, entry);

/* cppcheck-suppress memleak symbolName=entry.key */
return &g_array_index (group->prefs, GgdOptEntry, group->prefs->len -1);
}

Expand Down
3 changes: 3 additions & 0 deletions geniuspaste/src/geniuspaste.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ static gchar *pastebin_get_language(const Pastebin *pastebin,
gchar *lang = g_key_file_get_string(pastebin->config, PASTEBIN_GROUP_LANGUAGES,
geany_ft_name, NULL);

/* cppcheck-suppress memleak symbolName=lang
* obvious cppcheck bug */
return lang ? lang : pastebin_get_default(pastebin, "language", "");
}

Expand Down Expand Up @@ -752,6 +754,7 @@ static void show_msgbox(GtkMessageType type, GtkButtonsType buttons,
gtk_widget_destroy(dlg);

g_free(markup);
/* cppcheck-suppress memleak symbolName=dlg */
}

static void debug_log_message_body(SoupMessage *msg,
Expand Down
1 change: 1 addition & 0 deletions git-changebar/src/gcb-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ get_cached_blob_contents_async (const gchar *path,
}

g_async_queue_push (G_queue, job);
/* cppcheck-suppress memleak symbolName=job */
}
}

Expand Down
4 changes: 4 additions & 0 deletions scope/src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ static void create_send_source(void)
g_source_set_callback(send_source, (GSourceFunc) send_commands_cb, NULL,
send_source_destroy_cb);
send_source_id = g_source_attach(send_source, NULL);
/* cppcheck-suppress memleak symbolName=send_source
* the source is attached and managed through its ID */
}

#define HAS_SPAWN_LEAVE_STDIN_OPEN 0
Expand Down Expand Up @@ -347,6 +349,8 @@ static void gdb_finalize(void)
if (send_channel)
{
g_io_channel_shutdown(send_channel, FALSE, NULL);
/* cppcheck-suppress doubleFree symbolName=send_channel
* erroneously thinks g_io_channel_shutdown() frees the channel */
g_io_channel_unref(send_channel);
send_channel = NULL;

Expand Down
2 changes: 2 additions & 0 deletions vimode/src/cmd-runner.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx, gboolean ins_mode)
}
else if (!consumed && ctx->kpl)
{
/* cppcheck-suppress deallocuse symbolName=kpl
* Not sure how cppcheck gets this wrong here, but all seem OK */
g_free(ctx->kpl->data);
ctx->kpl = g_slist_delete_link(ctx->kpl, ctx->kpl);
}
Expand Down
6 changes: 6 additions & 0 deletions workbench/src/sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ static void sidebar_create_branch(gint level, const gchar *abs_base_dir, GSList
FILEVIEW_COLUMN_ICON, icon_dir,
FILEVIEW_COLUMN_NAME, last_dir_name,
FILEVIEW_COLUMN_DATA_ID, DATA_ID_SUB_DIRECTORY,
/* cppcheck-suppress leakNoVarFunctionCall
* type is gpointer, but admittedly I don't see where it's freed? */
FILEVIEW_COLUMN_ASSIGNED_DATA_POINTER, g_strdup(full),
-1);

Expand All @@ -235,6 +237,8 @@ static void sidebar_create_branch(gint level, const gchar *abs_base_dir, GSList
FILEVIEW_COLUMN_ICON, icon_dir,
FILEVIEW_COLUMN_NAME, last_dir_name,
FILEVIEW_COLUMN_DATA_ID, DATA_ID_SUB_DIRECTORY,
/* cppcheck-suppress leakNoVarFunctionCall
* type is gpointer, but admittedly I don't see where it's freed? */
FILEVIEW_COLUMN_ASSIGNED_DATA_POINTER, g_strdup(full),
-1);
g_free(full);
Expand Down Expand Up @@ -440,6 +444,8 @@ static void sidebar_add_file (WB_PROJECT *prj, WB_PROJECT_DIR *root, const gchar
FILEVIEW_COLUMN_ICON, icon,
FILEVIEW_COLUMN_NAME, name,
FILEVIEW_COLUMN_DATA_ID, dataid,
/* cppcheck-suppress leakNoVarFunctionCall
* type is gpointer, but admittedly I don't see where it's freed? */
FILEVIEW_COLUMN_ASSIGNED_DATA_POINTER, g_strdup(filepath),
-1);

Expand Down
4 changes: 4 additions & 0 deletions workbench/src/wb_project.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ static guint wb_project_dir_rescan_int(WB_PROJECT *prj, WB_PROJECT_DIR *root)

if (path)
{
/* cppcheck-suppress leakNoVarFunctionCall -- key is freed automatically */
g_hash_table_add(root->file_table, g_strdup(path));
filenum++;
}
Expand Down Expand Up @@ -757,6 +758,7 @@ static void wb_project_dir_add_file_int(WB_PROJECT *prj, WB_PROJECT_DIR *root, c
}

/* Update file table and counters. */
/* cppcheck-suppress leakNoVarFunctionCall -- key is freed automatically */
g_hash_table_add(root->file_table, g_strdup(filepath));
if (g_file_test(filepath, G_FILE_TEST_IS_DIR))
{
Expand Down Expand Up @@ -818,6 +820,7 @@ static void wb_project_dir_update_tags(WB_PROJECT_DIR *root)
gchar *locale_path = utils_get_locale_from_utf8(utf8_path);

g_ptr_array_add(files, g_strdup(key));
/* cppcheck-suppress leakNoVarFunctionCall -- key is freed automatically */
g_hash_table_add(root->file_table, g_strdup(utf8_path));
g_free(locale_path);
}
Expand Down Expand Up @@ -960,6 +963,7 @@ static void wb_project_dir_regenerate_tags(WB_PROJECT_DIR *root, G_GNUC_UNUSED g
}

/* Add all files to the file-table (files and dirs)! */
/* cppcheck-suppress leakNoVarFunctionCall -- key is freed automatically */
g_hash_table_add(file_table, g_strdup(key));
}
g_hash_table_destroy(root->file_table);
Expand Down

0 comments on commit fbd308f

Please sign in to comment.