mirror of https://github.com/xzeldon/htop.git
Merge branch 'natoscott-coverity-scan'
This commit is contained in:
commit
a155fd0f8b
|
@ -271,12 +271,14 @@ static void ScreenSettings_readFields(ScreenSettings* ss, Hashtable* columns, co
|
||||||
|
|
||||||
ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults) {
|
ScreenSettings* Settings_newScreen(Settings* this, const ScreenDefaults* defaults) {
|
||||||
int sortKey = defaults->sortKey ? toFieldIndex(this->dynamicColumns, defaults->sortKey) : PID;
|
int sortKey = defaults->sortKey ? toFieldIndex(this->dynamicColumns, defaults->sortKey) : PID;
|
||||||
|
int sortDesc = (sortKey >= 0 && sortKey < LAST_PROCESSFIELD) ? Process_fields[sortKey].defaultSortDesc : 1;
|
||||||
|
|
||||||
ScreenSettings* ss = xMalloc(sizeof(ScreenSettings));
|
ScreenSettings* ss = xMalloc(sizeof(ScreenSettings));
|
||||||
*ss = (ScreenSettings) {
|
*ss = (ScreenSettings) {
|
||||||
.name = xStrdup(defaults->name),
|
.name = xStrdup(defaults->name),
|
||||||
.fields = xCalloc(LAST_PROCESSFIELD, sizeof(ProcessField)),
|
.fields = xCalloc(LAST_PROCESSFIELD, sizeof(ProcessField)),
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.direction = (Process_fields[sortKey].defaultSortDesc) ? -1 : 1,
|
.direction = sortDesc ? -1 : 1,
|
||||||
.treeDirection = 1,
|
.treeDirection = 1,
|
||||||
.sortKey = sortKey,
|
.sortKey = sortKey,
|
||||||
.treeSortKey = PID,
|
.treeSortKey = PID,
|
||||||
|
@ -625,7 +627,6 @@ int Settings_write(const Settings* this, bool onCrash) {
|
||||||
printSettingInteger("tree_view_always_by_pid", this->screens[0]->treeViewAlwaysByPID);
|
printSettingInteger("tree_view_always_by_pid", this->screens[0]->treeViewAlwaysByPID);
|
||||||
printSettingInteger("all_branches_collapsed", this->screens[0]->allBranchesCollapsed);
|
printSettingInteger("all_branches_collapsed", this->screens[0]->allBranchesCollapsed);
|
||||||
|
|
||||||
if (this->screens && this->screens[0]) {
|
|
||||||
for (unsigned int i = 0; i < this->nScreens; i++) {
|
for (unsigned int i = 0; i < this->nScreens; i++) {
|
||||||
ScreenSettings* ss = this->screens[i];
|
ScreenSettings* ss = this->screens[i];
|
||||||
fprintf(fd, "screen:%s=", ss->name);
|
fprintf(fd, "screen:%s=", ss->name);
|
||||||
|
@ -638,7 +639,6 @@ int Settings_write(const Settings* this, bool onCrash) {
|
||||||
printSettingInteger(".tree_sort_direction", ss->treeDirection);
|
printSettingInteger(".tree_sort_direction", ss->treeDirection);
|
||||||
printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
|
printSettingInteger(".all_branches_collapsed", ss->allBranchesCollapsed);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#undef printSettingString
|
#undef printSettingString
|
||||||
#undef printSettingInteger
|
#undef printSettingInteger
|
||||||
|
|
Loading…
Reference in New Issue