aboutsummaryrefslogtreecommitdiffstats
path: root/linux/IOPriorityPanel.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-12-07 10:26:02 +0100
committerDaniel Lange <DLange@git.local>2020-12-07 10:26:02 +0100
commitd67ee86091f9e07f8d85c1fb77c7c58989e676bb (patch)
tree900f5e62bfd8e8c082be75a94f5348dea819beba /linux/IOPriorityPanel.c
parent3cbc50cde37fee19ce98ee8260b0a6095b829c4c (diff)
parent65357c8c46154de4e4eca14075bfe5523bb5fc14 (diff)
downloaddebian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.gz
debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.tar.bz2
debian_htop-d67ee86091f9e07f8d85c1fb77c7c58989e676bb.zip
Update upstream source from tag 'upstream/3.0.3'
Update to upstream version '3.0.3' with Debian dir 8a3a733dc80e45b1cde220f88fcfd815869742f0
Diffstat (limited to 'linux/IOPriorityPanel.c')
-rw-r--r--linux/IOPriorityPanel.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/linux/IOPriorityPanel.c b/linux/IOPriorityPanel.c
index ebb77bf..c5a4a4c 100644
--- a/linux/IOPriorityPanel.c
+++ b/linux/IOPriorityPanel.c
@@ -1,20 +1,33 @@
/*
htop - IOPriorityPanel.c
(C) 2004-2012 Hisham H. Muhammad
-Released under the GNU GPL, see the COPYING file
+Released under the GNU GPLv2, see the COPYING file
in the source distribution for its full text.
*/
#include "IOPriorityPanel.h"
+#include <stdbool.h>
+#include <stddef.h>
+
+#include "FunctionBar.h"
+#include "ListItem.h"
+#include "Object.h"
+#include "XUtils.h"
+
Panel* IOPriorityPanel_new(IOPriority currPrio) {
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Set ", "Cancel "));
Panel_setHeader(this, "IO Priority:");
Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
- if (currPrio == IOPriority_None) Panel_setSelected(this, 0);
- static const struct { int klass; const char* name; } classes[] = {
+ if (currPrio == IOPriority_None) {
+ Panel_setSelected(this, 0);
+ }
+ static const struct {
+ int klass;
+ const char* name;
+ } classes[] = {
{ .klass = IOPRIO_CLASS_RT, .name = "Realtime" },
{ .klass = IOPRIO_CLASS_BE, .name = "Best-effort" },
{ .klass = 0, .name = NULL }
@@ -22,17 +35,22 @@ Panel* IOPriorityPanel_new(IOPriority currPrio) {
for (int c = 0; classes[c].name; c++) {
for (int i = 0; i < 8; i++) {
char name[50];
- xSnprintf(name, sizeof(name)-1, "%s %d %s", classes[c].name, i, i == 0 ? "(High)" : (i == 7 ? "(Low)" : ""));
+ xSnprintf(name, sizeof(name), "%s %d %s", classes[c].name, i, i == 0 ? "(High)" : (i == 7 ? "(Low)" : ""));
IOPriority ioprio = IOPriority_tuple(classes[c].klass, i);
Panel_add(this, (Object*) ListItem_new(name, ioprio));
- if (currPrio == ioprio) Panel_setSelected(this, Panel_size(this) - 1);
+ if (currPrio == ioprio) {
+ Panel_setSelected(this, Panel_size(this) - 1);
+ }
}
}
Panel_add(this, (Object*) ListItem_new("Idle", IOPriority_Idle));
- if (currPrio == IOPriority_Idle) Panel_setSelected(this, Panel_size(this) - 1);
+ if (currPrio == IOPriority_Idle) {
+ Panel_setSelected(this, Panel_size(this) - 1);
+ }
return this;
}
IOPriority IOPriorityPanel_getIOPriority(Panel* this) {
- return (IOPriority) ( ((ListItem*) Panel_getSelected(this))->key );
+ const ListItem* selected = (ListItem*) Panel_getSelected(this);
+ return selected ? selected->key : IOPriority_None;
}

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