summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2022-04-30 13:55:56 +1000
committerNathan Scott <nathans@redhat.com>2022-04-30 13:55:56 +1000
commitcde72dd0b0bcc971ffa0a343e4a5177eed1b8765 (patch)
tree2a4b0eb423c409bf986eff9866861f5f29edab40
parentcb61865bb93999e02852438d53c06def3d8d623b (diff)
Remove redundant null checks on Settings_write (covscan)
Coverity scan reports that there is dead code in Settings_write checking for nulls that have already been dereferenced on every code path leading to the check. This is likely a hangover from times when the screens pointer was only conditionally allocated - they're not needed anymore.
-rw-r--r--Settings.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/Settings.c b/Settings.c
index a825b56a..0b8050d8 100644
--- a/Settings.c
+++ b/Settings.c
@@ -631,19 +631,17 @@ int Settings_write(const Settings* this, bool onCrash) {
printSettingInteger("tree_view_always_by_pid", this->screens[0]->treeViewAlwaysByPID);
printSettingInteger("all_branches_collapsed", this->screens[0]->allBranchesCollapsed);
- if (this->screens && this->screens[0]) {
- for (unsigned int i = 0; i < this->nScreens; i++) {
- ScreenSettings* ss = this->screens[i];
- fprintf(fd, "screen:%s=", ss->name);
- writeFields(fd, ss->fields, this->dynamicColumns, true, separator);
- printSettingString(".sort_key", toFieldName(this->dynamicColumns, ss->sortKey));
- printSettingString(".tree_sort_key", toFieldName(this->dynamicColumns, ss->treeSortKey));
- printSettingInteger(".tree_view", ss->treeView);
- printSettingInteger(".tree_view_always_by_pid", ss->treeViewAlwaysByPID);
- printSettingInteger(".sort_direction", ss->direction);
- printSettingInteger(".tree_sort_direction", ss->treeDirection);
- printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
- }
+ for (unsigned int i = 0; i < this->nScreens; i++) {
+ ScreenSettings* ss = this->screens[i];
+ fprintf(fd, "screen:%s=", ss->name);
+ writeFields(fd, ss->fields, this->dynamicColumns, true, separator);
+ printSettingString(".sort_key", toFieldName(this->dynamicColumns, ss->sortKey));
+ printSettingString(".tree_sort_key", toFieldName(this->dynamicColumns, ss->treeSortKey));
+ printSettingInteger(".tree_view", ss->treeView);
+ printSettingInteger(".tree_view_always_by_pid", ss->treeViewAlwaysByPID);
+ printSettingInteger(".sort_direction", ss->direction);
+ printSettingInteger(".tree_sort_direction", ss->treeDirection);
+ printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
}
#undef printSettingString

© 2014-2024 Faster IT GmbH | imprint | privacy policy