diff --git a/Process.c b/Process.c index 7b61de0c9..4cdd8cb84 100644 --- a/Process.c +++ b/Process.c @@ -824,9 +824,9 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field char* buf = buffer; const bool lastItem = (this->indent < 0); - for (int indent = (this->indent < 0 ? -this->indent : this->indent); indent > 1; indent >>= 1) { + for (uint64_t indent = (this->indent < 0 ? -this->indent : this->indent); indent > 1; indent >>= 1) { int written, ret; - if (indent & 1) { + if (indent & 1U) { ret = xSnprintf(buf, n, "%s ", CRT_treeStr[TREE_STR_VERT]); } else { ret = xSnprintf(buf, n, " "); diff --git a/Process.h b/Process.h index a1ca50fb5..613bbb046 100644 --- a/Process.h +++ b/Process.h @@ -242,7 +242,7 @@ typedef struct Process_ { /* * Internal state for tree-mode. */ - int indent; + int64_t indent; unsigned int tree_depth; /* Has no known parent process */ diff --git a/ProcessList.c b/ProcessList.c index bbaddd862..30a1f1ad3 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -199,7 +199,7 @@ static void ProcessList_removeIndex(ProcessList* this, const Process* p, int idx assert(Vector_countEquals(this->processes, Hashtable_count(this->processTable))); } -static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level, int indent, bool show) { +static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, unsigned int level, int64_t indent, bool show) { // On OpenBSD the kernel thread 'swapper' has pid 0. // Do not treat it as root of any tree. if (pid == 0) @@ -239,7 +239,7 @@ static void ProcessList_buildTreeBranch(ProcessList* this, pid_t pid, int level, Vector_add(this->displayList, process); - int nextIndent = indent | (1 << level); + int64_t nextIndent = indent | ((int64_t)1 << MINIMUM(level, sizeof(process->indent) * 8 - 2)); ProcessList_buildTreeBranch(this, process->pid, level + 1, (i < lastShown) ? nextIndent : indent, process->show && process->showChildren); if (i == lastShown) { process->indent = -nextIndent;