summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2023-11-23 12:22:02 +0100
committerBenBE <BenBE@geshi.org>2023-12-26 15:14:19 +0100
commit6aa9ef2726e42c4ae062b55be4d5cc015767d997 (patch)
treed5bd033946b404fa99b70b0b1c560725cef302bf
parenta98fc47ffe67e88b1a83f94382795b8787a9bfe8 (diff)
Fix code style
-rw-r--r--AffinityPanel.c84
-rw-r--r--AvailableColumnsPanel.c5
-rw-r--r--AvailableMetersPanel.c6
-rw-r--r--BatteryMeter.c20
-rw-r--r--CRT.c4
-rw-r--r--ColorsPanel.c45
-rw-r--r--ColumnsPanel.c25
-rw-r--r--CommandLine.c7
-rw-r--r--DiskIOMeter.c25
-rw-r--r--DisplayOptionsPanel.c57
-rw-r--r--Header.h2
-rw-r--r--HeaderOptionsPanel.c44
-rw-r--r--InfoScreen.c80
-rw-r--r--MetersPanel.c27
-rw-r--r--NetworkIOMeter.c25
-rw-r--r--OpenFilesScreen.c122
-rw-r--r--Panel.c118
-rw-r--r--Process.c54
-rw-r--r--Process.h4
-rw-r--r--Scheduling.c28
-rw-r--r--ScreenManager.c2
-rw-r--r--ScreenTabsPanel.c91
-rw-r--r--ScreensPanel.c107
-rw-r--r--Settings.c4
-rw-r--r--Table.c4
-rw-r--r--TraceScreen.c2
-rw-r--r--Vector.c4
-rw-r--r--configure.ac2
-rw-r--r--dragonflybsd/DragonFlyBSDProcessTable.c84
-rw-r--r--freebsd/FreeBSDProcessTable.c16
-rw-r--r--linux/LinuxMachine.c111
-rw-r--r--linux/LinuxProcess.c4
-rw-r--r--linux/LinuxProcessTable.c82
-rw-r--r--linux/Platform.c4
-rw-r--r--linux/SystemdMeter.c12
-rw-r--r--netbsd/NetBSDProcessTable.c46
-rw-r--r--pcp/Instance.c2
-rw-r--r--pcp/Instance.h6
-rw-r--r--pcp/PCPDynamicColumn.c6
-rw-r--r--pcp/PCPDynamicMeter.c4
-rw-r--r--pcp/PCPDynamicScreen.c6
-rw-r--r--pcp/PCPDynamicScreen.h2
-rw-r--r--pcp/PCPProcessTable.c8
-rw-r--r--pcp/Platform.c7
-rw-r--r--solaris/SolarisMachine.c2
45 files changed, 685 insertions, 715 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 1214a84f..f4009080 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -202,57 +202,57 @@ static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
bool keepSelected = true;
switch (ch) {
- case KEY_MOUSE:
- case KEY_RECLICK:
- case ' ':
- #ifdef HAVE_LIBHWLOC
- if (selected->value == 2) {
- /* Item was selected, so remove this mask from the top cpuset. */
- hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
- selected->value = 0;
- } else {
- /* Item was not or only partial selected, so set all bits from this object
- in the top cpuset. */
- hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
- selected->value = 2;
- }
- #else
- selected->value = selected->value ? 0 : 2; /* toggle between 0 and 2 */
- #endif
+ case KEY_MOUSE:
+ case KEY_RECLICK:
+ case ' ':
+ #ifdef HAVE_LIBHWLOC
+ if (selected->value == 2) {
+ /* Item was selected, so remove this mask from the top cpuset. */
+ hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
+ selected->value = 0;
+ } else {
+ /* Item was not or only partial selected, so set all bits from this object
+ in the top cpuset. */
+ hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
+ selected->value = 2;
+ }
+ #else
+ selected->value = selected->value ? 0 : 2; /* toggle between 0 and 2 */
+ #endif
- result = HANDLED;
- break;
+ result = HANDLED;
+ break;
- #ifdef HAVE_LIBHWLOC
+#ifdef HAVE_LIBHWLOC
- case KEY_F(1):
- hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
- result = HANDLED;
- break;
+ case KEY_F(1):
+ hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
+ result = HANDLED;
+ break;
- case KEY_F(2):
- this->topoView = !this->topoView;
- keepSelected = false;
+ case KEY_F(2):
+ this->topoView = !this->topoView;
+ keepSelected = false;
- result = HANDLED;
- break;
+ result = HANDLED;
+ break;
- case KEY_F(3):
- case '-':
- case '+':
- if (selected->sub_tree)
- selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
+ case KEY_F(3):
+ case '-':
+ case '+':
+ if (selected->sub_tree)
+ selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
- result = HANDLED;
- break;
+ result = HANDLED;
+ break;
- #endif
+#endif
- case 0x0a:
- case 0x0d:
- case KEY_ENTER:
- result = BREAK_LOOP;
- break;
+ case 0x0a:
+ case 0x0d:
+ case KEY_ENTER:
+ result = BREAK_LOOP;
+ break;
}
if (HANDLED == result)
diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c
index 1b328db0..03684ff0 100644
--- a/AvailableColumnsPanel.c
+++ b/AvailableColumnsPanel.c
@@ -51,8 +51,7 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
switch (ch) {
case 13:
case KEY_ENTER:
- case KEY_F(5):
- {
+ case KEY_F(5): {
const ListItem* selected = (ListItem*) Panel_getSelected(super);
if (!selected)
break;
@@ -65,11 +64,9 @@ static HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
break;
}
default:
- {
if (0 < ch && ch < 255 && isgraph((unsigned char)ch))
result = Panel_selectByTyping(super, ch);
break;
- }
}
return result;
}
diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c
index dabb3870..f34af8fe 100644
--- a/AvailableMetersPanel.c
+++ b/AvailableMetersPanel.c
@@ -60,25 +60,22 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
case KEY_F(5):
case 'l':
case 'L':
- {
AvailableMetersPanel_addMeter(header, this->meterPanels[0], Platform_meterTypes[type], param, 0);
result = HANDLED;
update = true;
break;
- }
case 0x0a:
case 0x0d:
case KEY_ENTER:
case KEY_F(6):
case 'r':
case 'R':
- {
AvailableMetersPanel_addMeter(header, this->meterPanels[this->columns - 1], Platform_meterTypes[type], param, this->columns - 1);
result = (KEY_LEFT << 16) | SYNTH_KEY;
update = true;
break;
- }
}
+
if (update) {
Settings* settings = this->host->settings;
settings->changed = true;
@@ -88,6 +85,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) {
Header_draw(header);
ScreenManager_resize(this->scr);
}
+
return result;
}
diff --git a/BatteryMeter.c b/BatteryMeter.c
index 92eecb3f..dad7754a 100644
--- a/BatteryMeter.c
+++ b/BatteryMeter.c
@@ -40,16 +40,16 @@ static void BatteryMeter_updateValues(Meter* this) {
const char* text;
switch (isOnAC) {
- case AC_PRESENT:
- text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)";
- break;
- case AC_ABSENT:
- text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)";
- break;
- case AC_ERROR:
- default:
- text = "";
- break;
+ case AC_PRESENT:
+ text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)";
+ break;
+ case AC_ABSENT:
+ text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)";
+ break;
+ case AC_ERROR:
+ default:
+ text = "";
+ break;
}
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text);
diff --git a/CRT.c b/CRT.c
index 68020e37..96ea00d9 100644
--- a/CRT.c
+++ b/CRT.c
@@ -1113,8 +1113,8 @@ void CRT_setColors(int colorScheme) {
for (short int j = 0; j < 8; j++) {
if (ColorIndex(i, j) != ColorIndexGrayBlack && ColorIndex(i, j) != ColorIndexWhiteDefault) {
short int bg = (colorScheme != COLORSCHEME_BLACKNIGHT)
- ? (j == 0 ? -1 : j)
- : j;
+ ? (j == 0 ? -1 : j)
+ : j;
init_pair(ColorIndex(i, j), i, bg);
}
}
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 59008842..c00981e0 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -50,30 +50,31 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
ColorsPanel* this = (ColorsPanel*) super;
HandlerResult result = IGNORED;
- int mark;
switch (ch) {
- case 0x0a:
- case 0x0d:
- case KEY_ENTER:
- case KEY_MOUSE:
- case KEY_RECLICK:
- case ' ':
- mark = Panel_getSelectedIndex(super);
- assert(mark >= 0);
- assert(mark < LAST_COLORSCHEME);
- for (int i = 0; ColorSchemeNames[i] != NULL; i++)
- CheckItem_set((CheckItem*)Panel_get(super, i), false);
- CheckItem_set((CheckItem*)Panel_get(super, mark), true);
-
- this->settings->colorScheme = mark;
- this->settings->changed = true;
- this->settings->lastUpdate++;
-
- CRT_setColors(mark);
- clear();
-
- result = HANDLED | REDRAW;
+ case 0x0a:
+ case 0x0d:
+ case KEY_ENTER:
+ case KEY_MOUSE:
+ case KEY_RECLICK:
+ case ' ': {
+ int mark = Panel_getSelectedIndex(super);
+ assert(mark >= 0);
+ assert(mark < LAST_COLORSCHEME);
+
+ for (int i = 0; ColorSchemeNames[i] != NULL; i++)
+ CheckItem_set((CheckItem*)Panel_get(super, i), false);
+ CheckItem_set((CheckItem*)Panel_get(super, mark), true);
+
+ this->settings->colorScheme = mark;
+ this->settings->changed = true;
+ this->settings->lastUpdate++;
+
+ CRT_setColors(mark);
+ clear();
+
+ result = HANDLED | REDRAW;
+ }
}
return result;
diff --git a/ColumnsPanel.c b/ColumnsPanel.c
index f395d9f6..0517ea7d 100644
--- a/ColumnsPanel.c
+++ b/ColumnsPanel.c
@@ -46,7 +46,6 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
- {
if (selected < size - 1) {
this->moving = !(this->moving);
Panel_setSelectionColor(super, this->moving ? PANEL_SELECTION_FOLLOW : PANEL_SELECTION_FOCUS);
@@ -56,59 +55,45 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
result = HANDLED;
}
break;
- }
case KEY_UP:
- {
- if (!this->moving) {
+ if (!this->moving)
break;
- }
- }
/* else fallthrough */
case KEY_F(7):
case '[':
case '-':
- {
if (selected < size - 1)
Panel_moveSelectedUp(super);
result = HANDLED;
break;
- }
case KEY_DOWN:
- {
- if (!this->moving) {
+ if (!this->moving)
break;
- }
- }
/* else fallthrough */
case KEY_F(8):
case ']':
case '+':
- {
if (selected < size - 2)
Panel_moveSelectedDown(super);
result = HANDLED;
break;
- }
case KEY_F(9):
case KEY_DC:
- {
- if (selected < size - 1) {
+ if (selected < size - 1)
Panel_remove(super, selected);
- }
result = HANDLED;
break;
- }
default:
- {
if (0 < ch && ch < 255 && isgraph((unsigned char)ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
- }
}
+
if (result == HANDLED)
ColumnsPanel_update(super);
+
return result;
}
diff --git a/CommandLine.c b/CommandLine.c
index effaca48..230b721c 100644
--- a/CommandLine.c
+++ b/CommandLine.c
@@ -138,6 +138,7 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
while ((opt = getopt_long(argc, argv, "hVMCs:td:n:u::Up:F:H::", long_opts, &opti))) {
if (opt == EOF)
break;
+
switch (opt) {
case 'h':
printHelpFlag(program);
@@ -192,8 +193,7 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
return STATUS_ERROR_EXIT;
}
break;
- case 'u':
- {
+ case 'u': {
const char* username = optarg;
if (!username && optind < argc && argv[optind] != NULL &&
(argv[optind][0] != '\0' && argv[optind][0] != '-')) {
@@ -246,11 +246,10 @@ static CommandLineStatus parseArguments(int argc, char** argv, CommandLineSettin
break;
}
- case 'F': {
+ case 'F':
assert(optarg);
free_and_xStrdup(&flags->commFilter, optarg);
break;
- }
case 'H': {
const char* delay = optarg;
if (!delay && optind < argc && argv[optind] != NULL &&
diff --git a/DiskIOMeter.c b/DiskIOMeter.c
index 78ae91b6..545ebd83 100644
--- a/DiskIOMeter.c
+++ b/DiskIOMeter.c
@@ -117,24 +117,23 @@ static void DiskIOMeter_updateValues(Meter* this) {
static void DiskIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
switch (status) {
- case RATESTATUS_NODATA:
- RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
- return;
- case RATESTATUS_INIT:
- RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
- return;
- case RATESTATUS_STALE:
- RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
- return;
- case RATESTATUS_DATA:
- break;
+ case RATESTATUS_NODATA:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
+ return;
+ case RATESTATUS_INIT:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
+ return;
+ case RATESTATUS_STALE:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
+ return;
+ case RATESTATUS_DATA:
+ break;
}
char buffer[16];
- int len;
int color = cached_utilisation_diff > 40.0 ? METER_VALUE_NOTICE : METER_VALUE;
- len = xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
+ int len = xSnprintf(buffer, sizeof(buffer), "%.1f%%", cached_utilisation_diff);
RichString_appendnAscii(out, CRT_colors[color], buffer, len);
RichString_appendAscii(out, CRT_colors[METER_TEXT], " read: ");
diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c
index e74409fc..fb6fe9c4 100644
--- a/DisplayOptionsPanel.c
+++ b/DisplayOptionsPanel.c
@@ -37,37 +37,37 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
OptionItem* selected = (OptionItem*) Panel_getSelected(super);
switch (ch) {
- case '\n':
- case '\r':
- case KEY_ENTER:
- case KEY_MOUSE:
- case KEY_RECLICK:
- case ' ':
- switch (OptionItem_kind(selected)) {
- case OPTION_ITEM_TEXT:
+ case '\n':
+ case '\r':
+ case KEY_ENTER:
+ case KEY_MOUSE:
+ case KEY_RECLICK:
+ case ' ':
+ switch (OptionItem_kind(selected)) {
+ case OPTION_ITEM_TEXT:
+ break;
+ case OPTION_ITEM_CHECK:
+ CheckItem_toggle((CheckItem*)selected);
+ result = HANDLED;
+ break;
+ case OPTION_ITEM_NUMBER:
+ NumberItem_toggle((NumberItem*)selected);
+ result = HANDLED;
+ break;
+ }
break;
- case OPTION_ITEM_CHECK:
- CheckItem_toggle((CheckItem*)selected);
- result = HANDLED;
+ case '-':
+ if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
+ NumberItem_decrease((NumberItem*)selected);
+ result = HANDLED;
+ }
break;
- case OPTION_ITEM_NUMBER:
- NumberItem_toggle((NumberItem*)selected);
- result = HANDLED;
+ case '+':
+ if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
+ NumberItem_increase((NumberItem*)selected);
+ result = HANDLED;
+ }
break;
- }
- break;
- case '-':
- if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
- NumberItem_decrease((NumberItem*)selected);
- result = HANDLED;
- }
- break;
- case '+':
- if (OptionItem_kind(selected) == OPTION_ITEM_NUMBER) {
- NumberItem_increase((NumberItem*)selected);
- result = HANDLED;
- }
- break;
}
if (result == HANDLED) {
@@ -80,6 +80,7 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
Header_draw(header);
ScreenManager_resize(this->scr);
}
+
return result;
}
diff --git a/Header.h b/Header.h
index add4d76b..82e38530 100644
--- a/Header.h
+++ b/Header.h
@@ -23,7 +23,7 @@ typedef struct Header_ {
#define Header_forEachColumn(this_, i_) for (size_t (i_)=0, H_fEC_numColumns_ = HeaderLayout_getColumns((this_)->headerLayout); (i_) < H_fEC_numColumns_; ++(i_))
-Header* Header_new(Machine *host, HeaderLayout hLayout);
+Header* Header_new(Machine* host, HeaderLayout hLayout);
void Header_delete(Header* this);
diff --git a/HeaderOptionsPanel.c b/HeaderOptionsPanel.c
index 25d1ddbb..b69d85bb 100644
--- a/HeaderOptionsPanel.c
+++ b/HeaderOptionsPanel.c
@@ -33,30 +33,30 @@ static HandlerResult HeaderOptionsPanel_eventHandler(Panel* super, int ch) {
HeaderOptionsPanel* this = (HeaderOptionsPanel*) super;
HandlerResult result = IGNORED;
- int mark;
switch (ch) {
- case 0x0a:
- case 0x0d:
- case KEY_ENTER:
- case KEY_MOUSE:
- case KEY_RECLICK:
- case ' ':
- mark = Panel_getSelectedIndex(super);
- assert(mark >= 0);
- assert(mark < LAST_HEADER_LAYOUT);
-
- for (int i = 0; i < LAST_HEADER_LAYOUT; i++)
- CheckItem_set((CheckItem*)Panel_get(super, i), false);
- CheckItem_set((CheckItem*)Panel_get(super, mark), true);
-
- Header_setLayout(this->scr->header, mark);
- this->settings->changed = true;
- this->settings->lastUpdate++;
-
- ScreenManager_resize(this->scr);
-
- result = HANDLED;
+ case 0x0a:
+ case 0x0d:
+ case KEY_ENTER:
+ case KEY_MOUSE:
+ case KEY_RECLICK:
+ case ' ': {
+ int mark = Panel_getSelectedIndex(super);
+ assert(mark >= 0);
+ assert(mark < LAST_HEADER_LAYOUT);
+
+ for (int i = 0; i < LAST_HEADER_LAYOUT; i++)
+ CheckItem_set((CheckItem*)Panel_get(super, i), false);
+ CheckItem_set((CheckItem*)Panel_get(super, mark), true);
+
+ Header_setLayout(this->scr->header, mark);
+ this->settings->changed = true;
+ this->settings->lastUpdate++;
+
+ ScreenManager_resize(this->scr);
+
+ result = HANDLED;
+ }
}
return result;
diff --git a/InfoScreen.c b/InfoScreen.c
index e9f06f27..c602cd46 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -138,48 +138,48 @@ void InfoScreen_run(InfoScreen* this) {
}
switch (ch) {
- case ERR:
- continue;
- case KEY_F(3):
- case '/':
- IncSet_activate(this->inc, INC_SEARCH, panel);
- break;
- case KEY_F(4):
- case '\\':
- IncSet_activate(this->inc, INC_FILTER, panel);
- break;
- case KEY_F(5):
- clear();
- if (As_InfoScreen(this)->scan) {
- Vector_prune(this->lines);
- InfoScreen_scan(this);
- }
+ case ERR:
+ continue;
+ case KEY_F(3):
+ case '/':
+ IncSet_activate(this->inc, INC_SEARCH, panel);
+ break;
+ case KEY_F(4):
+ case '\\':
+ IncSet_activate(this->inc, INC_FILTER, panel);
+ break;
+ case KEY_F(5):
+ clear();
+ if (As_InfoScreen(this)->scan) {
+ Vector_prune(this->lines);
+ InfoScreen_scan(this);
+ }
- InfoScreen_draw(this);
- break;
- case '\014': // Ctrl+L
- clear();
- InfoScreen_draw(this);
- break;
- case 27:
- case 'q':
- case KEY_F(10):
- looping = false;
- break;
- case KEY_RESIZE:
- Panel_resize(panel, COLS, LINES - 2);
- if (As_InfoScreen(this)->scan) {
- Vector_prune(this->lines);
- InfoScreen_scan(this);
- }
+ InfoScreen_draw(this);
+ break;
+ case '\014': // Ctrl+L
+ clear();
+ InfoScreen_draw(this);
+ break;
+ case 27:
+ case 'q':
+ case KEY_F(10):
+ looping = false;
+ break;
+ case KEY_RESIZE:
+ Panel_resize(panel, COLS, LINES - 2);
+ if (As_InfoScreen(this)->scan) {
+ Vector_prune(this->lines);
+ InfoScreen_scan(this);
+ }
- InfoScreen_draw(this);
- break;
- default:
- if (As_InfoScreen(this)->onKey && InfoScreen_onKey(this, ch)) {
- continue;
- }
- Panel_onKey(panel, ch);
+ InfoScreen_draw(this);
+ break;
+ default:
+ if (As_InfoScreen(this)->onKey && InfoScreen_onKey(this, ch)) {
+ continue;
+ }
+ Panel_onKey(panel, ch);
}
}
}
diff --git a/MetersPanel.c b/MetersPanel.c
index 580e41bd..ac118e54 100644
--- a/MetersPanel.c
+++ b/MetersPanel.c
@@ -95,17 +95,14 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
case 0x0a:
case 0x0d:
case KEY_ENTER:
- {
if (!Vector_size(this->meters))
break;
MetersPanel_setMoving(this, !(this->moving));
result = HANDLED;
break;
- }
case ' ':
case KEY_F(4):
- case 't':
- {
+ case 't': {
if (!Vector_size(this->meters))
break;
Meter* meter = (Meter*) Vector_get(this->meters, selected);
@@ -118,39 +115,28 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
break;
}
case KEY_UP:
- {
- if (!this->moving) {
+ if (!this->moving)
break;
- }
- }
/* else fallthrough */
case KEY_F(7):
case '[':
case '-':
- {
Vector_moveUp(this->meters, selected);
Panel_moveSelectedUp(super);
result = HANDLED;
break;
- }
case KEY_DOWN:
- {
- if (!this->moving) {
+ if (!this->moving)
break;
- }
- }
/* else fallthrough */
case KEY_F(8):
case ']':
case '+':
- {
Vector_moveDown(this->meters, selected);
Panel_moveSelectedDown(super);
result = HANDLED;
break;
- }
case KEY_RIGHT:
- {
sideMove = moveToNeighbor(this, this->rightNeighbor, selected);
if (this->moving && !sideMove) {
// lock user here until it exits positioning-mode
@@ -159,18 +145,14 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
// if user is free, don't set HANDLED;
// let ScreenManager handle focus.
break;
- }
case KEY_LEFT:
- {
sideMove = moveToNeighbor(this, this->leftNeighbor, selected);
if (this->moving && !sideMove) {
result = HANDLED;
}
break;
- }
case KEY_F(9):
case KEY_DC:
- {
if (!Vector_size(this->meters))
break;
if (selected < Vector_size(this->meters)) {
@@ -180,8 +162,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
MetersPanel_setMoving(this, false);
result = HANDLED;
break;
- }
}
+
if (result == HANDLED || sideMove) {
Header* header = this->scr->header;
this->settings->changed = true;
@@ -189,6 +171,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
Header_calculateHeight(header);
ScreenManager_resize(this->scr);
}
+
return result;
}
diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c
index a43f4d17..1ab3a37e 100644
--- a/NetworkIOMeter.c
+++ b/NetworkIOMeter.c
@@ -135,21 +135,20 @@ static void NetworkIOMeter_updateValues(Meter* this) {
static void NetworkIOMeter_display(ATTR_UNUSED const Object* cast, RichString* out) {
switch (status) {
- case RATESTATUS_NODATA:
- RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
- return;
- case RATESTATUS_INIT:
- RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
- return;
- case RATESTATUS_STALE:
- RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
- return;
- case RATESTATUS_DATA:
- break;
+ case RATESTATUS_NODATA:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
+ return;
+ case RATESTATUS_INIT:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE], "initializing...");
+ return;
+ case RATESTATUS_STALE:
+ RichString_writeAscii(out, CRT_colors[METER_VALUE_WARN], "stale data");
+ return;
+ case RATESTATUS_DATA:
+ break;
}
char buffer[64];
- int len;
RichString_writeAscii(out, CRT_colors[METER_TEXT], "rx: ");
RichString_appendAscii(out, CRT_colors[METER_VALUE_IOREAD], cached_rxb_diff_str);
@@ -159,7 +158,7 @@ static void NetworkIOMeter_display(ATTR_UNUSED const Object* cast, RichString* o
RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], cached_txb_diff_str);
RichString_appendAscii(out, CRT_colors[METER_VALUE_IOWRITE], "iB/s");
- len = xSnprintf(buffer, sizeof(buffer), " (%u/%u pkts/s) ", cached_rxp_diff, cached_txp_diff);
+ int len = xSnprintf(buffer, sizeof(buffer), " (%u/%u pkts/s) ", cached_rxp_diff, cached_txp_diff);
RichString_appendnAscii(out, CRT_colors[METER_TEXT], buffer, len);
}
diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c
index 3077490d..bb1c70c4 100644
--- a/OpenFilesScreen.c
+++ b/OpenFilesScreen.c
@@ -44,22 +44,22 @@ typedef struct OpenFiles_FileData_ {
static size_t getIndexForType(char type) {
switch (type) {
- case 'f':
- return 0;
- case 'a':
- return 1;
- case 'D':
- return 2;
- case 'i':
- return 3;
- case 'n':
- return 4;
- case 's':
- return 5;
- case 't':
- return 6;
- case 'o':
- return 7;
+ case 'f':
+ return 0;
+ case 'a':
+ return 1;
+ case 'D':
+ return 2;
+ case 'i':
+ return 3;
+ case 'n':
+ return 4;
+ case 's':
+ return 5;
+ case 't':
+ return 6;
+ case 'o':
+ return 7;
}
/* should never reach here */
@@ -122,7 +122,7 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
xSnprintf(buffer, sizeof(buffer), "%d", pid);
// Use of NULL in variadic functions must have a pointer cast.
// The NULL constant is not required by standard to have a pointer type.
- execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", (char *)NULL);
+ execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", (char*)NULL);
exit(127);
}
close(fdpair[1]);
@@ -144,52 +144,52 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
unsigned char cmd = line[0];
switch (cmd) {
- case 'f': /* file descriptor */
- {
- OpenFiles_FileData* nextFile = xCalloc(1, sizeof(OpenFiles_FileData));
- if (fdata == NULL) {
- pdata->files = nextFile;
- } else {
- fdata->next = nextFile;
- }
- fdata = nextFile;
- item = &(fdata->data);
- } /* FALLTHRU */
- case 'a': /* file access mode */
- case 'D': /* file's major/minor device number */
- case 'i': /* file's inode number */
- case 'n': /* file name, comment, Internet address */
- case 's': /* file's size */
- case 't': /* file's type */
- {
- size_t index = getIndexForType(cmd);
- free_and_xStrdup(&item->data[index], line + 1);
- break;
- }
- case 'o': /* file's offset */
- {
- size_t index = getIndexForType(cmd);
- if (String_startsWith(line + 1, "0t")) {
- free_and_xStrdup(&item->data[index], line + 3);
- } else {
+ case 'f': /* file descriptor */
+ {
+ OpenFiles_FileData* nextFile = xCalloc(1, sizeof(OpenFiles_FileData));
+ if (fdata == NULL) {
+ pdata->files = nextFile;
+ } else {
+ fdata->next = nextFile;
+ }
+ fdata = nextFile;
+ item = &(fdata->data);
+ } /* FALLTHRU */
+ case 'a': /* file access mode */
+ case 'D': /* file's major/minor device number */
+ case 'i': /* file's inode number */
+ case 'n': /* file name, comment, Internet address */
+ case 's': /* file's size */
+ case 't': /* file's type */
+ {
+ size_t index = getIndexForType(cmd);
free_and_xStrdup(&item->data[index], line + 1);
+ break;
}
- break;
- }
- case 'c': /* process command name */
- case 'd': /* file's device character code */
- case 'g': /* process group ID */
- case 'G': /* file flags */
- case 'k': /* link count */
- case 'l': /* file's lock status */
- case 'L': /* process login name */
- case 'p': /* process ID */
- case 'P': /* protocol name */
- case 'R': /* parent process ID */
- case 'T': /* TCP/TPI information, identified by prefixes */
- case 'u': /* process user ID */
- /* ignore */
- break;
+ case 'o': /* file's offset */
+ {
+ size_t index = getIndexForType(cmd);
+ if (String_startsWith(line + 1, "0t")) {
+ free_and_xStrdup(&item->data[index], line + 3);
+ } else {
+ free_and_xStrdup(&item->data[index], line + 1);
+ }
+ break;
+ }
+ case 'c': /* process command name */
+ case 'd': /* file's device character code */
+ case 'g': /* process group ID */
+ case 'G': /* file flags */
+ case 'k': /* link count */
+ case 'l': /* file's lock status */
+ case 'L': /* process login name */
+ case 'p': /* process ID */
+ case 'P': /* protocol name */
+ case 'R': /* parent process ID */
+ case 'T': /* TCP/TPI information, identified by prefixes */
+ case 'u': /* process user ID */
+ /* ignore */
+ break;
}
if (cmd == 's')
diff --git a/Panel.c b/Panel.c
index 64982731..4784a658 100644
--- a/Panel.c
+++ b/Panel.c
@@ -273,8 +273,8 @@ void Panel_draw(Panel* this, bool force_redraw, bool focus, bool highlightSelect
int upTo = MINIMUM(first + h, size);
int selectionColor = focus
- ? CRT_colors[this->selectionColorId]
- : CRT_colors[PANEL_SELECTION_UNFOCUS];
+ ? CRT_colors[this->selectionColorId]
+ : CRT_colors[PANEL_SELECTION_UNFOCUS];
if (this->needsRedraw || force_redraw) {
int line = 0;
@@ -359,72 +359,74 @@ bool Panel_onKey(Panel* this, int key) {
} while (0)
switch (key) {
- case KEY_DOWN:
- case KEY_CTRL('N'):
- #ifdef KEY_C_DOWN
- case KEY_C_DOWN:
- #endif
- this->selected++;
- break;
-
- case KEY_UP:
- case KEY_CTRL('P'):
- #ifdef KEY_C_UP
- case KEY_C_UP:
- #endif
- this->selected--;
- break;
+ case KEY_DOWN:
+ case KEY_CTRL('N'):
+ #ifdef KEY_C_DOWN
+ case KEY_C_DOWN:
+ #endif
+ this->selected++;
+ break;
+
+ case KEY_UP:
+ case KEY_CTRL('P'):
+ #ifdef KEY_C_UP
+ case KEY_C_UP:
+ #endif
+ this->selected--;
+ break;
+
+ case KEY_LEFT:
+ case KEY_CTRL('B'):
+ if (this->scrollH > 0) {
+ this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0);
+ this->needsRedraw = true;
+ }
+ break;
- case KEY_LEFT:
- case KEY_CTRL('B'):
- if (this->scrollH > 0) {
- this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0);
+ case KEY_RIGHT:
+ case KEY_CTRL('F'):
+ this->scrollH += CRT_scrollHAmount;
this->needsRedraw = true;
- }
- break;
+ break;
- case KEY_RIGHT:
- case KEY_CTRL('F'):
- this->scrollH += CRT_scrollHAmount;
- this->needsRedraw = true;
- break;
+ case KEY_PPAGE:
+ PANEL_SCROLL(-(this->h - Panel_headerHeight(this)));
+ break;
- case KEY_PPAGE:
- PANEL_SCROLL(-(this->h - Panel_headerHeight(this)));
- break;
+ case KEY_NPAGE:
+ PANEL_SCROLL(+(this->h - Panel_headerHeight(this)));
+ break;
- case KEY_NPAGE:
- PANEL_SCROLL(+(this->h - Panel_headerHeight(this)));
- break;
+ case KEY_WHEELUP:
+ PANEL_SCROLL(-CRT_scrollWheelVAmount);
+ break;
- case KEY_WHEELUP:
- PANEL_SCROLL(-CRT_scrollWheelVAmount);
- break;
+ case KEY_WHEELDOWN:
+ PANEL_SCROLL(+CRT_scrollWheelVAmount);
+ break;
- case KEY_WHEELDOWN:
- PANEL_SCROLL(+CRT_scrollWheelVAmount);
- break;
+ case KEY_HOME:
+ this->selected = 0;
+ break;
- case KEY_HOME:
- this->selected = 0;
- break;
+ case KEY_END:
+ this->selected = size - 1;
+ break;
- case KEY_END:
- this->selected = size - 1;
- break;
+ case KEY_CTRL('A'):
+ case '^':
+ this->scrollH = 0;
+ this->needsRedraw = true;
+ break;
- case KEY_CTRL('A'):
- case '^':
- this->scrollH = 0;
- this->needsRedraw = true;
- break;
- case KEY_CTRL('E'):
- case '$':
- this->scrollH = MAXIMUM(this->selectedLen - this->w, 0);
- this->needsRedraw = true;
- break;
- default:
- return false;
+ case KEY_CTRL('E'):
+ case '$':
+ this->scrollH = MAXIMUM(this->selectedLen - this->w, 0);
+ this->needsRedraw = true;
+ break;
+
+ default:
+ return false;
}
#undef PANEL_SCROLL
diff --git a/Process.c b/Process.c
index a80d1ee8..4766c115 100644
--- a/Process.c
+++ b/Process.c
@@ -47,7 +47,7 @@ void Process_fillStarttimeBuffer(Process* this) {
strftime(this->starttime_show,
sizeof(this->starttime_show) - 1,
- (this->starttime_ctime > now - 86400) ? "%R " : (this->starttime_ctime > now - 364*86400) ? "%b%d " : " %Y ",
+ (this->starttime_ctime > now - 86400) ? "%R " : (this->starttime_ctime > now - 364 * 86400) ? "%b%d " : " %Y ",
&date);
}
@@ -650,8 +650,8 @@ void Process_writeField(const Process* this, RichString* str, RowField field) {
case NICE:
xSnprintf(buffer, n, "%3ld ", this->nice);
attr = this->nice < 0 ? CRT_colors[PROCESS_HIGH_PRIORITY]
- : this->nice > 0 ? CRT_colors[PROCESS_LOW_PRIORITY]
- : CRT_colors[PROCESS_SHADOW];
+ : this->nice > 0 ? CRT_colors[PROCESS_LOW_PRIORITY]
+ : CRT_colors[PROCESS_SHADOW];
break;
case NLWP:
if (this->nlwp == 1)
@@ -690,30 +690,30 @@ void Process_writeField(const Process* this, RichString* str, RowField field) {
case STATE:
xSnprintf(buffer, n, "%c ", processStateChar(this->state));
switch (this->state) {
- case RUNNABLE:
- case RUNNING:
- case TRACED:
- attr = CRT_colors[PROCESS_RUN_STATE];
- break;
-
- case BLOCKED:
- case DEFUNCT:
- case STOPPED:
- case UNINTERRUPTIBLE_WAIT:
- case ZOMBIE:
- attr = CRT_colors[PROCESS_D_STATE];
- break;
-
- case QUEUED:
- case WAITING:
- case IDLE:
- case SLEEPING:
- attr = CRT_colors[PROCESS_SHADOW];
- break;
-
- case UNKNOWN:
- case PAGING:
- break;
+ case RUNNABLE:
+ case RUNNING:
+ case TRACED:
+ attr = CRT_colors[PROCESS_RUN_STATE];
+ break;
+
+ case BLOCKED:
+ case DEFUNCT:
+ case STOPPED:
+ case UNINTERRUPTIBLE_WAIT:
+ case ZOMBIE:
+ attr = CRT_colors[PROCESS_D_STATE];
+ break;
+
+ case QUEUED:
+ case WAITING:
+ case IDLE:
+ case SLEEPING:
+ attr = CRT_colors[PROCESS_SHADOW];
+ break;
+
+ case UNKNOWN:
+ case PAGING:
+ break;
}
break;
case ST_UID: xSnprintf(buffer, n, "%*d ", Process_uidDigits, this->st_uid); break;
diff --git a/Process.h b/Process.h
index 92908155..0c3562ac 100644
--- a/Process.h
+++ b/Process.h
@@ -253,11 +253,11 @@ static inline pid_t Process_getThreadGroup(const Process* this) {
}
static inline void Process_setParent(Process* this, pid_t pid) {
- this->super.parent = pid;
+ this->super.parent = pid;
}
static inline pid_t Process_getParent(const Process* this) {
- return (pid_t)this->super.parent;
+ return (pid_t)this->super.parent;
}
static inline pid_t Process_getGroupOrParent(const Process* this) {
diff --git a/Scheduling.c b/Scheduling.c
index 8383cb10..42524073 100644
--- a/Scheduling.c
+++ b/Scheduling.c
@@ -133,26 +133,26 @@ const char* Scheduling_formatPolicy(int policy) {
#endif
switch (policy) {
- case SCHED_OTHER:
- return "OTHER";
- case SCHED_FIFO:
- return "FIFO";
- case SCHED_RR:
- return "RR";
+ case SCHED_OTHER:
+ return "OTHER";
+ case SCHED_FIFO:
+ return "FIFO";
+ case SCHED_RR:
+ return "RR";
#ifdef SCHED_BATCH
- case SCHED_BATCH:
- return "BATCH";
+ case SCHED_BATCH:
+ return "BATCH";
#endif
#ifdef SCHED_IDLE
- case SCHED_IDLE:
- return "IDLE";
+ case SCHED_IDLE:
+ return "IDLE";
#endif
#ifdef SCHED_DEADLINE
- case SCHED_DEADLINE:
- return "EDF";
+ case SCHED_DEADLINE:
+ return "EDF";
#endif
- default:
- return "???";
+ default:
+ return "???";
}
}
diff --git a/ScreenManager.c b/ScreenManager.c
index f4d59a42..bfecd2c7 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -318,12 +318,14 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, con
redraw = false;
continue;
}
+
switch (ch) {
case KEY_ALT('H'): ch = KEY_LEFT; break;
case KEY_ALT('J'): ch = KEY_DOWN; break;
case KEY_ALT('K'): ch = KEY_UP; break;
case KEY_ALT('L'): ch = KEY_RIGHT; break;
}
+
redraw = true;
if (Panel_eventHandlerFn(panelFocus)) {
result = Panel_eventHandler(panelFocus, ch);
diff --git a/ScreenTabsPanel.c b/ScreenTabsPanel.c
index d4757f05..fdb84248 100644
--- a/ScreenTabsPanel.c
+++ b/ScreenTabsPanel.c
@@ -91,20 +91,20 @@ static HandlerResult ScreenTabsPanel_eventHandler(Panel* super, int ch) {
break;
}
default:
- {
if (ch < 255 && isalpha(ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
- }
}
+
if (result == HANDLED) {
ScreenTabListItem* focus = (ScreenTabListItem*) Panel_getSelected(super);
if (focus) {
ScreenNamesPanel_fill(this->names, focus->ds);
}
}
+
return result;
}
@@ -210,49 +210,48 @@ static HandlerResult ScreenNamesPanel_eventHandlerRenaming(Panel* super, int ch)
super->selectedLen = strlen(this->buffer);
Panel_setCursorToSelection(super);
}
- } else {
- switch (ch) {
- case 127:
- case KEY_BACKSPACE:
- {
- if (this->cursor > 0) {
- this->cursor--;
- this->buffer[this->cursor] = '\0';
- super->selectedLen = strlen(this->buffer);
- Panel_setCursorToSelection(super);
- }
- break;
+
+ return HANDLED;
+ }
+
+ switch (ch) {
+ case 127:
+ case KEY_BACKSPACE:
+ if (this->cursor > 0) {
+ this->cursor--;
+ this->buffer[this->cursor] = '\0';
+ super->selectedLen = strlen(this->buffer);
+ Panel_setCursorToSelection(super);
}
- case '\n':
- case '\r':
- case KEY_ENTER:
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- free(this->saved);
- item->value = xStrdup(this->buffer);
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
- renameScreenSettings(this, item);
+ break;
+ case '\n':
+ case '\r':
+ case KEY_ENTER: {
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
- case 27: // Esc
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- item->value = this->saved;
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ assert(item == this->renamingItem);
+ free(this->saved);
+ item->value = xStrdup(this->buffer);
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ renameScreenSettings(this, item);
+ break;
+ }
+ case 27: { // Esc
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
+ assert(item == this->renamingItem);
+ item->value = this->saved;
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ break;
}
}
+
return HANDLED;
}
@@ -262,6 +261,7 @@ static void startRenaming(Panel* super) {
ListItem* item = (ListItem*) Panel_getSelected(super);
if (item == NULL)
return;
+
this->renamingItem = item;
super->cursorOn = true;
char* name = item->value;
@@ -289,17 +289,16 @@ static HandlerResult ScreenNamesPanel_eventHandlerNormal(Panel* super, int ch) {
ScreenNamesPanel* const this = (ScreenNamesPanel*) super;
ScreenNameListItem* oldFocus = (ScreenNameListItem*) Panel_getSelected(super);
HandlerResult result = IGNORED;
+
switch (ch) {
case '\n':
case '\r':
case KEY_ENTER:
case KEY_MOUSE:
case KEY_RECLICK:
- {
Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
result = HANDLED;
break;
- }
case EVENT_SET_SELECTED:
result = HANDLED;
break;
@@ -307,30 +306,26 @@ static HandlerResult ScreenNamesPanel_eventHandlerNormal(Panel* super, int ch) {
case KEY_PPAGE:
case KEY_HOME:
case KEY_END:
- {
Panel_onKey(super, ch);
break;
- }
case KEY_F(5):
case KEY_CTRL('N'):
- {
addNewScreen(super, this->ds);
startRenaming(super);
result = HANDLED;
break;
- }
default:
- {
if (ch < 255 && isalpha(ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
- }
}
+
ScreenNameListItem* newFocus = (ScreenNameListItem*) Panel_getSelected(super);
if (newFocus && oldFocus != newFocus)
result = HANDLED;
+
return result;
}
diff --git a/ScreensPanel.c b/ScreensPanel.c
index 69d1aeb1..bf08f2e6 100644
--- a/ScreensPanel.c
+++ b/ScreensPanel.c
@@ -71,49 +71,48 @@ static HandlerResult ScreensPanel_eventHandlerRenaming(Panel* super, int ch) {
super->selectedLen = strlen(this->buffer);
Panel_setCursorToSelection(super);
}
- } else {
- switch (ch) {
- case 127:
- case KEY_BACKSPACE:
- {
- if (this->cursor > 0) {
- this->cursor--;
- this->buffer[this->cursor] = '\0';
- super->selectedLen = strlen(this->buffer);
- Panel_setCursorToSelection(super);
- }
- break;
+
+ return HANDLED;
+ }
+
+ switch (ch) {
+ case 127:
+ case KEY_BACKSPACE:
+ if (this->cursor > 0) {
+ this->cursor--;
+ this->buffer[this->cursor] = '\0';
+ super->selectedLen = strlen(this->buffer);
+ Panel_setCursorToSelection(super);
}
- case '\n':
- case '\r':
- case KEY_ENTER:
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- free(this->saved);
- item->value = xStrdup(this->buffer);
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
- ScreensPanel_update(super);
+ break;
+ case '\n':
+ case '\r':
+ case KEY_ENTER: {
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
- case 27: // Esc
- {
- ListItem* item = (ListItem*) Panel_getSelected(super);
- if (!item)
- break;
- assert(item == this->renamingItem);
- item->value = this->saved;
- this->renamingItem = NULL;
- super->cursorOn = false;
- Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ assert(item == this->renamingItem);
+ free(this->saved);
+ item->value = xStrdup(this->buffer);
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ ScreensPanel_update(super);
+ break;
+ }
+ case 27: { // Esc
+ ListItem* item = (ListItem*) Panel_getSelected(super);
+ if (!item)
break;
- }
+ assert(item == this->renamingItem);
+ item->value = this->saved;
+ this->renamingItem = NULL;
+ super->cursorOn = false;
+ Panel_setSelectionColor(super, PANEL_SELECTION_FOCUS);
+ break;
}
}
+
return HANDLED;
}
@@ -175,14 +174,14 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
ScreenListItem* oldFocus = (ScreenListItem*) Panel_getSelected(super);
bool shouldRebuildArray = false;
HandlerResult result = IGNORED;
+
switch (ch) {
case '\n':
case '\r':
case KEY_ENTER:
case KEY_MOUSE:
- case KEY_RECLICK:
- {
- this->moving = !(this->moving);
+ case KEY_RECLICK: {
+ this->moving = !this->moving;
Panel_setSelectionColor(super, this->moving ? PANEL_SELECTION_FOLLOW : PANEL_SELECTION_FOCUS);
ListItem* item = (ListItem*) Panel_getSelected(super);
if (item)
@@ -196,20 +195,16 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
case KEY_NPAGE:
case KEY_PPAGE:
case KEY_HOME:
- case KEY_END: {
+ case KEY_END:
Panel_onKey(super, ch);
break;
- }
case KEY_F(2):
case KEY_CTRL('R'):
- {
startRenaming(super);
result = HANDLED;
break;
- }
case KEY_F(5):
case KEY_CTRL('N'):
- {
if (this->settings->dynamicScreens)
break;
addNewScreen(super);
@@ -217,59 +212,47 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_UP:
- {
if (!this->moving) {
Panel_onKey(super, ch);
break;
}
- /* else fallthrough */
- } /* FALLTHRU */
+ /* FALLTHRU */
case KEY_F(7):
case '[':
case '-':
- {
Panel_moveSelectedUp(super);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_DOWN:
- {
if (!this->moving) {
Panel_onKey(super, ch);
break;
}
- /* else fallthrough */
- } /* FALLTHRU */
+ /* FALLTHRU */
case KEY_F(8):
case ']':
case '+':
- {
Panel_moveSelectedDown(super);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
case KEY_F(9):
//case KEY_DC:
- {
if (Panel_size(super) > 1)
Panel_remove(super, selected);
shouldRebuildArray = true;
result = HANDLED;
break;
- }
default:
- {
if (ch < 255 && isalpha(ch))
result = Panel_selectByTyping(super, ch);
if (result == BREAK_LOOP)
result = IGNORED;
break;
- }
}
+
ScreenListItem* newFocus = (ScreenListItem*) Panel_getSelected(super);
if (newFocus && oldFocus != newFocus) {
Hashtable* dynamicColumns = this->settings->dynamicColumns;
@@ -277,10 +260,12 @@ static HandlerResult ScreensPanel_eventHandlerNormal(Panel* super, int ch) {
AvailableColumnsPanel_fill(this->availableColumns, newFocus->ss->dynamic, dynamicColumns);
result = HANDLED;
}
+
if (shouldRebuildArray)
rebuildSettingsArray(super, selected);
if (result == HANDLED)
ScreensPanel_update(super);
+
return result;
}
diff --git a/Settings.c b/Settings.c
index b1051a38..4e0aa21d 100644
--- a/Settings.c
+++ b/Settings.c
@@ -284,7 +284,7 @@ static void ScreenSettings_readFields(ScreenSettings* ss, Hashtable* columns, co
String_freeArray(ids);
}
-static ScreenSettings* Settings_initScreenSettings(ScreenSettings* ss, Settings* this, const char *columns) {
+static ScreenSettings* Settings_initScreenSettings(ScreenSettings* ss, Settings* this, const char* columns) {
ScreenSettings_readFields(ss, this->dynamicColumns, columns);
this->screens[this->nScreens] = ss;
this->nScreens++;
@@ -605,7 +605,7 @@ static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsi
int Settings_write(const Settings* this, bool onCrash) {
FILE* fd;
char separator;
- char *tmpFilename = NULL;
+ char* tmpFilename = NULL;
if (onCrash) {
fd = stderr;
separator = ';';
diff --git a/Table.c b/Table.c
index a5b91ab4..c31e8254 100644
--- a/Table.c
+++ b/Table.c
@@ -137,7 +137,7 @@ static void Table_buildTreeBranch(Table* this, int rowid, unsigned int level, in
}
static int compareRowByKnownParentThenNatural(const void* v1, const void* v2) {
- return Row_compareByParent((const Row*) v1, (const Row*) v2);
+ return Row_compareByParent((const Row*) v1, (const Row*) v2);
}
// Builds a sorted tree from scratch, without relying on previously gathered information
@@ -263,7 +263,7 @@ void Table_rebuildPanel(Table* this) {
foundFollowed = true;
Panel_setSelected(this->panel, idx);
/* Keep scroll position relative to followed row */
- this->panel->scrollV = idx - (currPos-currScrollV);
+ this->panel->scrollV = idx - (currPos - currScrollV);
}
idx++;
}
diff --git a/TraceScreen.c b/TraceScreen.c
index 03315482..7a1ce9ac 100644
--- a/TraceScreen.c
+++ b/TraceScreen.c
@@ -164,6 +164,7 @@ static void TraceScreen_updateTrace(InfoScreen* super) {
static bool TraceScreen_onKey(InfoScreen* super, int ch) {
TraceScreen* this = (TraceScreen*) super;
+
switch (ch) {
case 'f':
case KEY_F(8):
@@ -178,6 +179,7 @@ static bool TraceScreen_onKey(InfoScreen* super, int ch) {
InfoScreen_draw(this);
return true;
}
+
this->follow = false;
return false;
}
diff --git a/Vector.c b/Vector.c
index 15133dc5..0e08c650 100644
--- a/Vector.c
+++ b/Vector.c
@@ -103,7 +103,7 @@ void Vector_prune(Vector* this) {
this->items = 0;
this->dirty_index = -1;
this->dirty_count = 0;
- memset(this->array, '\0', this->arraySize * sizeof(Object *));
+ memset(this->array, '\0', this->arraySize * sizeof(Object*));
}
//static int comparisons = 0;
@@ -200,7 +200,7 @@ static void Vector_resizeIfNecessary(Vector* this, int newSize) {
assert(Vector_isConsistent(this));
int oldSize = this->arraySize;
this->arraySize = newSize + this->growthRate;
- this->array = (Object **)xReallocArrayZero(this->array, oldSize, this->arraySize, sizeof(Object*));
+ this->array = (Object**)xReallocArrayZero(this->array, oldSize, this->arraySize, sizeof(Object*));
}
assert(Vector_isConsistent(this));
}
diff --git a/configure.ac b/configure.ac
index 593b450e..dd7deaef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,7 +251,7 @@ AC_LINK_IFELSE([
#endif
]])],
AC_MSG_RESULT([assume yes (cross compiling)]),
- flag_finite_math_only=yes)
+ flag_finite_math_only=yes)
elif ./conftest$EXEEXT >&AS_MESSAGE_LOG_FD; then
flag_finite_math_only=no
AC_MSG_RESULT(yes)
diff --git a/dragonflybsd/DragonFlyBSDProcessTable.c b/dragonflybsd/DragonFlyBSDProcessTable.c
index 07c852e5..e36086f2 100644
--- a/dragonflybsd/DragonFlyBSDProcessTable.c
+++ b/dragonflybsd/DragonFlyBSDProcessTable.c
@@ -249,44 +249,56 @@ void ProcessTable_goThroughEntries(ProcessTable* super) {
// would be nice if we could store multiple states in proc->state (as enum) and have writeField render them
/* Taken from: https://github.com/DragonFlyBSD/DragonFlyBSD/blob/c163a4d7ee9c6857ee4e04a3a2cbb50c3de29da1/sys/sys/proc_common.h */
switch (kproc->kp_stat) {
- case SIDL: proc->state = IDLE; isIdleProcess = true; break;
- case SACTIVE:
- switch (kproc->kp_lwp.kl_stat) {
- case LSSLEEP:
- if (kproc->kp_lwp.kl_flags & LWP_SINTR) // interruptible wait short/long
- if (kproc->kp_lwp.kl_slptime >= MAXSLP) {
- proc->state = IDLE;
- isIdleProcess = true;
- } else {
+ case SIDL:
+ proc->state = IDLE;
+ isIdleProcess = true;
+ break;
+ case SACTIVE:
+ switch (kproc->kp_lwp.kl_stat) {
+ case LSSLEEP:
+ if (kproc->kp_lwp.kl_flags & LWP_SINTR) { // interruptible wait short/long
+ if (kproc->kp_lwp.kl_slptime >= MAXSLP) {
+ proc->state = IDLE;
+ isIdleProcess = true;
+ } else {
+ proc->state = SLEEPING;
+ }
+ } else if (kproc->kp_lwp.kl_tdflags & TDF_SINTR) { // interruptible lwkt wait
proc->state = SLEEPING;
+ } else if (kproc->kp_paddr) { // uninterruptible wait
+ proc->state = UNINTERRUPTIBLE_WAIT;
+ } else { // uninterruptible lwkt wait
+ proc->state = UNINTERRUPTIBLE_WAIT;
}
- else if (kproc->kp_lwp.kl_tdflags & TDF_SINTR) // interruptible lwkt wait
- proc->state = SLEEPING;
- else if (kproc->kp_paddr) // uninterruptible wait
- proc->state = UNINTERRUPTIBLE_WAIT;
- else // uninterruptible lwkt wait
- proc->state = UNINTERRUPTIBLE_WAIT;
- break;
- case LSRUN:
- if (kproc->kp_lwp.kl_stat == LSRUN) {
- if (!(kproc->kp_lwp.kl_tdflags & (TDF_RUNNING | TDF_RUNQ)))
- proc->state = QUEUED;
- else
- proc->state = RUNNING;
- }
- break;
- case LSSTOP:
- proc->state = STOPPED;
- break;
- default:
- proc->state = PAGING;
- break;
- }
- break;
- case SSTOP: proc->state = STOPPED; break;
- case SZOMB: proc->state = ZOMBIE; break;
- case SCORE: proc->state = BLOCKED; break;
- default: proc->state = UNKNOWN;
+ break;
+ case LSRUN:
+ if (kproc->kp_lwp.kl_stat == LSRUN) {
+ if (!(kproc->kp_lwp.kl_tdflags & (TDF_RUNNING | TDF_RUNQ))) {
+ proc->state = QUEUED;
+ } else {
+ proc->state = RUNNING;
+ }
+ }
+ break;
+ case LSSTOP:
+ proc->state = STOPPED;
+ break;
+ default:
+ proc->state = PAGING;
+ break;
+ }
+ break;
+ case SSTOP:
+ proc->state = STOPPED;
+ break;
+ case SZOMB:
+ proc->state = ZOMBIE;
+ break;
+ case SCORE:
+ proc->state = BLOCKED;
+ break;
+ default:
+ proc->state = UNKNOWN;
}
if (kproc->kp_flags & P_SWAPPEDOUT)
diff --git a/freebsd/FreeBSDProcessTable.c b/freebsd/FreeBSDProcessTable.c
index 5f3b9682..9e18b8ab 100644
--- a/freebsd/FreeBSDProcessTable.c
+++ b/freebsd/FreeBSDProcessTable.c
@@ -260,14 +260,14 @@ void ProcessTable_goThroughEntries(ProcessTable* super) {
/* Taken from: https://github.com/freebsd/freebsd-src/blob/1ad2d87778970582854082bcedd2df0394fd4933/sys/sys/proc.h#L851 */
switch (kproc->ki_stat) {
- case SIDL: proc->state = IDLE; break;
- case SRUN: proc->state = RUNNING; break;
- case SSLEEP: proc->state = SLEEPING; break;
- case SSTOP: proc->state = STOPPED; break;
- case SZOMB: proc->state = ZOMBIE; break;
- case SWAIT: proc->state = WAITING; break;
- case SLOCK: proc->state = BLOCKED; break;
- default: proc->state = UNKNOWN;
+ case SIDL: proc->state = IDLE; break;
+ case SRUN: proc->state = RUNNING; break;
+ case SSLEEP: proc->state = SLEEPING; break;
+ case SSTOP: proc->state = STOPPED; break;
+ case SZOMB: proc->state = ZOMBIE; break;
+ case SWAIT: proc->state = WAITING; break;
+ case SLOCK: proc->state = BLOCKED; break;
+ default: proc->state = UNKNOWN;
}
if (Process_isKernelThread(proc))
diff --git a/linux/LinuxMachine.c b/linux/LinuxMachine.c
index aa1ff5f8..d8d5fd2b 100644
--- a/linux/LinuxMachine.c
+++ b/linux/LinuxMachine.c
@@ -157,36 +157,36 @@ static void LinuxMachine_scanMemoryInfo(LinuxMachine* this) {
} else (void) 0 /* Require a ";" after the macro use. */
switch (buffer[0]) {
- case 'M':
- tryRead("MemAvailable:", availableMem);
- tryRead("MemFree:", freeMem);
- tryRead("MemTotal:", totalMem);
- break;
- case 'B':
- tryRead("Buffers:", buffersMem);
- break;
- case 'C':
- tryRead("Cached:", cachedMem);
- break;
- case 'S':
- switch (buffer[1]) {
- case 'h':
- tryRead("Shmem:", sharedMem);
+ case 'M':
+ tryRead("MemAvailable:", availableMem);
+ tryRead("MemFree:", freeMem);
+ tryRead("MemTotal:", totalMem);
break;
- case 'w':
- tryRead("SwapTotal:", swapTotalMem);
- tryRead("SwapCached:", swapCacheMem);
- tryRead("SwapFree:", swapFreeMem);
+ case 'B':
+ tryRead("Buffers:", buffersMem);
break;
- case 'R':
- tryRead("SReclaimable:", sreclaimableMem);
+ case 'C':
+ tryRead("Cached:", cachedMem);
+ break;
+ case 'S':
+ switch (buffer[1]) {
+ case 'h':
+ tryRead("Shmem:", sharedMem);
+ break;
+ case 'w':
+ tryRead("SwapTotal:", swapTotalMem);
+ tryRead("SwapCached:", swapCacheMem);
+ tryRead("SwapFree:", swapFreeMem);
+ break;
+ case 'R':
+ tryRead("SReclaimable:", sreclaimableMem);
+ break;
+ }
+ break;
+ case 'Z':
+ tryRead("Zswap:", zswapCompMem);
+ tryRead("Zswapped:", zswapOrigMem);
break;
- }
- break;
- case 'Z':
- tryRead("Zswap:", zswapCompMem);
- tryRead("Zswapped:", zswapOrigMem);
- break;
}
#undef tryRead
@@ -347,35 +347,36 @@ static void LinuxMachine_scanZfsArcstats(LinuxMachine* this) {
} else (void) 0 /* Require a ";" after the macro use. */
switch (buffer[0]) {
- case 'c':
- tryRead("c_min", &this->zfs.min);
- tryRead("c_max", &this->zfs.max);
- tryReadFlag("compressed_size", &this->zfs.compressed, this->zfs.isCompressed);
- break;
- case 'u':
- tryRead("uncompressed_size", &this->zfs.uncompressed);
- break;
- case 's':
- tryRead("size", &this->zfs.size);
- break;
- case 'h':
- tryRead("hdr_size", &this->zfs.header);
- break;
- case 'd':
- tryRead("dbuf_size", &dbufSize);
- tryRead("dnode_size", &dnodeSize);
- break;
- case 'b':
- tryRead("bonus_size", &bonusSize);
- break;
- case 'a':
- tryRead("anon_size", &this->zfs.anon);
- break;
- case 'm':
- tryRead("mfu_size", &this->zfs.MFU);
- tryRead("mru_size", &this->zfs.MRU);
- break;
+ case 'c':
+ tryRead("c_min", &this->zfs.min);
+ tryRead("c_max", &this->zfs.max);
+ tryReadFlag("compressed_size", &this->zfs.compressed, this->zfs.isCompressed);
+ break;
+ case 'u':
+ tryRead("uncompressed_size", &this->zfs.uncompressed);
+ break;
+ case 's':
+ tryRead("size", &this->zfs.size);
+ break;
+ case 'h':
+ tryRead("hdr_size", &this->zfs.header);
+ break;
+ case 'd':
+ tryRead("dbuf_size", &dbufSize);
+ tryRead("dnode_size", &dnodeSize);
+ break;
+ case 'b':
+ tryRead("bonus_size", &bonusSize);
+ break;
+ case 'a':
+ tryRead("anon_size", &this->zfs.anon);
+ break;
+ case 'm':
+ tryRead("mfu_size", &this->zfs.MFU);
+ tryRead("mru_size", &this->zfs.MRU);
+ break;
}
+
#undef tryRead
#undef tryReadFlag
}
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c
index 8b119fd9..84141ec0 100644
--- a/linux/LinuxProcess.c
+++ b/linux/LinuxProcess.c
@@ -319,8 +319,8 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
if (lp->autogroup_id != -1) {
xSnprintf(buffer, n, "%3d ", lp->autogroup_nice);
attr = lp->autogroup_nice < 0 ? CRT_colors[PROCESS_HIGH_PRIORITY]
- : lp->autogroup_nice > 0 ? CRT_colors[PROCESS_LOW_PRIORITY]
- : CRT_colors[PROCESS_SHADOW];
+ : lp->autogroup_nice > 0 ? CRT_colors[PROCESS_LOW_PRIORITY]
+ : CRT_colors[PROCESS_SHADOW];
} else {
attr = CRT_colors[PROCESS_SHADOW];
xSnprintf(buffer, n, "N/A ");
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c
index a4eb0264..aeda509e 100644
--- a/linux/LinuxProcessTable.c
+++ b/linux/LinuxProcessTable.c
@@ -516,33 +516,33 @@ static void LinuxProcessTable_readIoFile(LinuxProcess* lp, openat_arg_t procFd,
const char* line;
while ((line = strsep(&buf, "\n")) != NULL) {
switch (line[0]) {
- case 'r':
- if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
- lp->io_rchar = strtoull(line + 7, NULL, 10);
- } else if (String_startsWith(line + 1, "ead_bytes: ")) {
- lp->io_read_bytes = strtoull(line + 12, NULL, 10);
- lp->io_rate_read_bps = time_delta ? saturatingSub(lp->io_read_bytes, last_read) * /*ms to s*/1000. / time_delta : NAN;
- }
- break;
- case 'w':
- if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
- lp->io_wchar = strtoull(line + 7, NULL, 10);
- } else if (String_startsWith(line + 1, "rite_bytes: ")) {
- lp->io_write_bytes = strtoull(line + 13, NULL, 10);
- lp->io_rate_write_bps = time_delta ? saturatingSub(lp->io_write_bytes, last_write) * /*ms to s*/1000. / time_delta : NAN;
- }
- break;
- case 's':
- if (line[4] == 'r' && String_startsWith(line + 1, "yscr: ")) {
- lp->io_syscr = strtoull(line + 7, NULL, 10);
- } else if (String_startsWith(line + 1, "yscw: ")) {
- lp->io_syscw = strtoull(line + 7, NULL, 10);
- }
- break;
- case 'c':
- if (String_startsWith(line + 1, "ancelled_write_bytes: ")) {
- lp->io_cancelled_write_bytes = strtoull(line + 23, NULL, 10);
- }
+ case 'r':
+ if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
+ lp->io_rchar = strtoull(line + 7, NULL, 10);
+ } else if (String_startsWith(line + 1, "ead_bytes: ")) {
+ lp->io_read_bytes = strtoull(line + 12, NULL, 10);
+ lp->io_rate_read_bps = time_delta ? saturatingSub(lp->io_read_bytes, last_read) * /*ms to s*/1000. / time_delta : NAN;
+ }
+ break;
+ case 'w':
+ if (line[1] == 'c' && String_startsWith(line + 2, "har: ")) {
+ lp->io_wchar = strtoull(line + 7, NULL, 10);
+ } else if (String_startsWith(line + 1, "rite_bytes: ")) {
+ lp->io_write_bytes = strtoull(line + 13, NULL, 10);
+ lp->io_rate_write_bps = time_delta ? saturatingSub(lp->io_write_bytes, last_write) * /*ms to s*/1000. / time_delta : NAN;
+ }
+ break;
+ case 's':
+ if (line[4] == 'r' && String_startsWith(line + 1, "yscr: ")) {
+ lp->io_syscr = strtoull(line + 7, NULL, 10);
+ } else if (String_startsWith(line + 1, "yscw: ")) {
+ lp->io_syscw = strtoull(line + 7, NULL, 10);
+ }
+ break;
+ case 'c':
+ if (String_startsWith(line + 1, "ancelled_write_bytes: ")) {
+ lp->io_cancelled_write_bytes = strtoull(line + 23, NULL, 10);
+ }
}
}
@@ -807,18 +807,18 @@ static void LinuxProcessTable_readOpenVZData(LinuxProcess* process, openat_arg_t
*value_end = '\0';
switch (field) {
- case 1:
- foundEnvID = true;
- if (!String_eq(name_value_sep, process->ctid ? process->ctid : ""))
- free_and_xStrdup(&process->ctid, name_value_sep);
- break;
- case 2:
- foundVPid = true;
- process->vpid = strtoul(name_value_sep, NULL, 0);
- break;
- default:
- //Sanity Check: Should never reach here, or the implementation is missing something!
- assert(false && "OpenVZ handling: Unimplemented case for field handling reached.");
+ case 1:
+ foundEnvID = true;
+ if (!String_eq(name_value_sep, process->ctid ? process->ctid : ""))
+ free_and_xStrdup(&process->ctid, name_value_sep);
+ break;
+ case 2:
+ foundVPid = true;
+ process->vpid = strtoul(name_value_sep, NULL, 0);
+ break;
+ default:
+ //Sanity Check: Should never reach here, or the implementation is missing something!
+ assert(false && "OpenVZ handling: Unimplemented case for field handling reached.");
}
}
@@ -1457,7 +1457,7 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar
bool prev = proc->usesDeletedLib;
if (!proc->isKernelThread && !proc->isUserlandThread &&
- ((ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe && !proc->procExeDeleted && isOlderThan(proc, 10)))) {
+ ((ss->flags & PROCESS_FLAG_LINUX_LRS_FIX) || (settings->highlightDeletedExe && !proc->procExeDeleted && isOlderThan(proc, 10)))) {
// Check if we really should recalculate the M_LRS value for this process
uint64_t passedTimeInMs = host->realtimeMs - lp->last_mlrs_calctime;
@@ -1521,7 +1521,7 @@ static bool LinuxProcessTable_recurseProcTree(LinuxProcessTable* this, openat_ar
proc->percent_mem = proc->m_resident / (double)(host->totalMem) * 100.0;
Process_updateCPUFieldWidths(proc->percent_cpu);
- if (! LinuxProcessTable_updateUser(host, proc, procFd))
+ if (!LinuxProcessTable_updateUser(host, proc, procFd))
goto errorReadingProcess;
if (!LinuxProcessTable_readStatusFile(proc, procFd))
diff --git a/linux/Platform.c b/linux/Platform.c
index fbbedc6e..84eb8b1a 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -303,7 +303,7 @@ pid_t Platform_getMaxPid(void) {
}
double Platform_setCPUValues(Meter* this, unsigned int cpu) {
- const LinuxMachine* lhost = (const LinuxMachine *) this->host;
+ const LinuxMachine* lhost = (const LinuxMachine*) this->host;
const Settings* settings = this->host->settings;
const CPUData* cpuData = &(lhost->cpuData[cpu]);
double total = (double) ( cpuData->totalPeriod == 0 ? 1 : cpuData->totalPeriod);
@@ -928,7 +928,7 @@ CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv) {
case 160: {
const char* mode = optarg;
if (!mode && optind < argc && argv[optind] != NULL &&
- (argv[optind][0] != '\0' && argv[optind][0] != '-')) {
+ (argv[optind][0] != '\0' && argv[optind][0] != '-')) {
mode = argv[optind++];
}
diff --git a/linux/SystemdMeter.c b/linux/SystemdMeter.c
index a154d1b8..e13c6461 100644
--- a/linux/SystemdMeter.c
+++ b/linux/SystemdMeter.c
@@ -307,12 +307,12 @@ static void SystemdMeter_updateValues(Meter* this) {
static int zeroDigitColor(unsigned int value) {
switch (value) {
- case 0:
- return CRT_colors[METER_VALUE];
- case INVALID_VALUE:
- return CRT_colors[METER_VALUE_ERROR];
- default:
- return CRT_colors[METER_VALUE_NOTICE];
+ case 0:
+ return CRT_colors[METER_VALUE];
+ case INVALID_VALUE:
+ return CRT_colors[METER_VALUE_ERROR];
+ default:
+ return CRT_colors[METER_VALUE_NOTICE];
}
}
diff --git a/netbsd/NetBSDProcessTable.c b/netbsd/NetBSDProcessTable.c
index 6fa5bfea..f09a3a4b 100644
--- a/netbsd/NetBSDProcessTable.c
+++ b/netbsd/NetBSDProcessTable.c
@@ -228,30 +228,32 @@ static void NetBSDProcessTable_scanProcs(NetBSDProcessTable* this) {
/* TODO: According to the link below, SDYING should be a regarded state */
/* Taken from: https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/sys/proc.h */
switch (kproc->p_realstat) {
- case SIDL: proc->state = IDLE; break;
- case SACTIVE:
- // We only consider the first LWP with a one of the below states.
- for (int j = 0; j < nlwps; j++) {
- if (klwps) {
- switch (klwps[j].l_stat) {
- case LSONPROC: proc->state = RUNNING; break;
- case LSRUN: proc->state = RUNNABLE; break;
- case LSSLEEP: proc->state = SLEEPING; break;
- case LSSTOP: proc->state = STOPPED; break;
- default: proc->state = UNKNOWN;
- }
- if (proc->state != UNKNOWN)
+ case SIDL: proc->state = IDLE; break;
+ case SACTIVE:
+ // We only consider the first LWP with a one of the below states.
+ for (int j = 0; j < nlwps; j++) {
+ if (klwps) {
+ switch (klwps[j].l_stat) {
+ case LSONPROC: proc->state = RUNNING; break;
+ case LSRUN: proc->state = RUNNABLE; break;
+ case LSSLEEP: proc->state = SLEEPING; break;
+ case LSSTOP: proc->state = STOPPED; break;
+ default: proc->state = UNKNOWN;
+ }
+
+ if (proc->state != UNKNOWN) {
+ break;
+ }
+ } else {
+ proc->state = UNKNOWN;
break;
- } else {
- proc->state = UNKNOWN;
- break;
+ }
}
- }
- break;
- case SSTOP: proc->state = STOPPED; break;
- case SZOMB: proc->state = ZOMBIE; break;
- case SDEAD: proc->state = DEFUNCT; break;
- default: proc->state = UNKNOWN;
+ break;
+ case SSTOP: proc->state = STOPPED; break;
+ case SZOMB: proc->state = ZOMBIE; break;
+ case SDEAD: proc->state = DEFUNCT; break;
+ default: proc->state = UNKNOWN;
}
if (Process_isKernelThread(proc)) {
diff --git a/pcp/Instance.c b/pcp/Instance.c
index f915350d..8ae90512 100644
--- a/pcp/Instance.c
+++ b/pcp/Instance.c
@@ -66,7 +66,7 @@ static void Instance_writeField(const Row* super, RichString* str, RowField fiel
return;
pmAtomValue atom;
- pmAtomValue *ap = &atom;
+ pmAtomValue* ap = &atom;
const pmDesc* descp = Metric_desc(cp->id);
if (!Metric_instance(cp->id, instid, this->offset, ap, descp->type))
ap = NULL;
diff --git a/pcp/Instance.h b/pcp/Instance.h
index c7d688fc..aefd6426 100644
--- a/pcp/Instance.h
+++ b/pcp/Instance.h
@@ -17,16 +17,16 @@ in the source distribution for its full text.
typedef struct Instance_ {
Row super;
- char *name; /* external instance name */
+ char* name; /* external instance name */
const struct InDomTable_* indom; /* instance domain */
/* default result offset to use for searching metrics with instances */
unsigned int offset;
} Instance;
-#define InDom_getId(i_) ((i_)->indom->id)
+#define InDom_getId(i_) ((i_)->indom->id)
#define Instance_getId(i_) ((i_)->super.id)
-#define Instance_setId(i_, id_) ((i_)->super.id = (id_))
+#define Instance_setId(i_, id_) ((i_)->super.id = (id_))
extern const RowClass Instance_class;
diff --git a/pcp/PCPDynamicColumn.c b/pcp/PCPDynamicColumn.c
index 534a9ba6..b0bd03e1 100644
--- a/pcp/PCPDynamicColumn.c
+++ b/pcp/PCPDynamicColumn.c
@@ -273,7 +273,7 @@ static void PCPDynamicColumn_setupWidth(ATTR_UNUSED ht_key_t key, void* value, A
if (column->instances || desc->type == PM_TYPE_STRING) {
column->super.width = column->width;
if (column->super.width == 0)
- column->super.width = -16;
+ column->super.width = -16;
return;
}
@@ -348,6 +348,7 @@ static int PCPDynamicColumn_normalize(const pmDesc* desc, const pmAtomValue* ap,
default:
return PM_ERR_CONV;
}
+
return 0;
}
@@ -460,7 +461,7 @@ void PCPDynamicColumn_writeField(PCPDynamicColumn* this, const Process* proc, Ri
pid_t pid = Process_getPid(proc);
pmAtomValue atom;
- pmAtomValue *ap = &atom;
+ pmAtomValue* ap = &atom;
if (!Metric_instance(this->id, pid, pp->offset, ap, desc->type))
ap = NULL;
@@ -510,5 +511,6 @@ int PCPDynamicColumn_compareByKey(const PCPProcess* p1, const PCPProcess* p2, Pr
default:
break;
}
+
return -1;
}
diff --git a/pcp/PCPDynamicMeter.c b/pcp/PCPDynamicMeter.c
index 1e118351..11df5f0a 100644
--- a/pcp/PCPDynamicMeter.c
+++ b/pcp/PCPDynamicMeter.c
@@ -382,9 +382,11 @@ void PCPDynamicMeter_updateValues(PCPDynamicMeter* this, Meter* meter) {
default:
break;
}
+
if (saved != bytes && metric->suffix)
bytes += xSnprintf(buffer + bytes, size - bytes, "%s", metric->suffix);
}
+
if (!bytes)
xSnprintf(buffer, size, "no data");
}
@@ -458,12 +460,14 @@ void PCPDynamicMeter_display(PCPDynamicMeter* this, ATTR_UNUSED const Meter* met
default:
break;
}
+
if (len) {
RichString_appendnAscii(out, CRT_colors[metric->color], buffer, len);
if (metric->suffix)
RichString_appendAscii(out, CRT_colors[METER_TEXT], metric->suffix);
}
}
+
if (nodata)
RichString_writeAscii(out, CRT_colors[METER_VALUE_ERROR], "no data");
}
diff --git a/pcp/PCPDynamicScreen.c b/pcp/PCPDynamicScreen.c
index a66d9dce..22228225 100644
--- a/pcp/PCPDynamicScreen.c
+++ b/pcp/PCPDynamicScreen.c
@@ -42,7 +42,7 @@ static char* formatFields(PCPDynamicScreen* screen) {
static void PCPDynamicScreens_appendDynamicColumns(PCPDynamicScreens* screens, PCPDynamicColumns* columns) {
for (size_t i = 0; i < screens->count; i++) {
- PCPDynamicScreen *screen = Hashtable_get(screens->table, i);
+ PCPDynamicScreen* screen = Hashtable_get(screens->table, i);
if (!screen)
return;
@@ -60,7 +60,7 @@ static void PCPDynamicScreens_appendDynamicColumns(PCPDynamicScreens* screens, P
if (j == 0) {
const pmDesc* desc = Metric_desc(column->id);
- assert(desc->indom != PM_INDOM_NULL);
+ assert(desc->indom != PM_INDOM_NULL);
screen->indom = desc->indom;
screen->key = column->id;
}
@@ -241,7 +241,7 @@ static void PCPDynamicScreen_parseFile(PCPDynamicScreens* screens, const char* p
if (ok)
screen = PCPDynamicScreen_new(screens, key + 1);
if (pmDebugOptions.appl0)
- fprintf(stderr, "[%s] screen: %s\n", path, key+1);
+ fprintf(stderr, "[%s] screen: %s\n", path, key + 1);
} else if (!ok) {
; /* skip this one, we're looking for a new header */
} else if (!value || !screen) {
diff --git a/pcp/PCPDynamicScreen.h b/pcp/PCPDynamicScreen.h
index 73535925..62483941 100644
--- a/pcp/PCPDynamicScreen.h
+++ b/pcp/PCPDynamicScreen.h
@@ -25,7 +25,7 @@ struct PCPDynamicColumns_;
typedef struct PCPDynamicScreen_ {
DynamicScreen super;
- struct InDomTable_ *table;
+ struct InDomTable_* table;
struct PCPDynamicColumn_** columns;
size_t totalColumns;
diff --git a/pcp/PCPProcessTable.c b/pcp/PCPProcessTable.c
index 07d5805d..4999bdc2 100644
--- a/pcp/PCPProcessTable.c
+++ b/pcp/PCPProcessTable.c
@@ -333,7 +333,7 @@ static void PCPProcessTable_updateCmdline(Process* process, int pid, int offset,
tokenStart = i + 1;
/* special-case arguments for problematic situations like "find /" */
if (command[i] <= ' ')
- argSepSpace = true;
+ argSepSpace = true;
}
tokenEnd = length;
if (argSepSpace)
@@ -403,10 +403,10 @@ static bool PCPProcessTable_updateProcesses(PCPProcessTable* this) {
PCPProcessTable_updateMemory(pp, pid, offset);
- if ((flags & PROCESS_FLAG_LINUX_SMAPS) &&
- (Process_isKernelThread(proc) == false)) {
- if (Metric_enabled(PCP_PROC_SMAPS_PSS))
+ if ((flags & PROCESS_FLAG_LINUX_SMAPS) && !Process_isKernelThread(proc)) {
+ if (Metric_enabled(PCP_PROC_SMAPS_PSS)) {
PCPProcessTable_updateSmaps(pp, pid, offset);
+ }
}
char command[MAX_NAME + 1];
diff --git a/pcp/Platform.c b/pcp/Platform.c
index 6fc2fc51..0b5f3344 100644
--- a/pcp/Platform.c
+++ b/pcp/Platform.c
@@ -802,7 +802,7 @@ CommandLineStatus Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** a
case PLATFORM_LONGOPT_HOST: /* --host=HOSTSPEC */
if (argv[optind][0] == '\0')
return STATUS_ERROR_EXIT;
- __pmAddOptHost(&opts, optarg);
+ __pmAddOptHost(&opts, optarg);
return STATUS_OK;
case PLATFORM_LONGOPT_HOSTZONE: /* --hostzone */
@@ -828,6 +828,7 @@ CommandLineStatus Platform_getLongOption(int opt, ATTR_UNUSED int argc, char** a
default:
break;
}
+
return STATUS_ERROR_EXIT;
}
@@ -918,6 +919,6 @@ void Platform_addDynamicScreenAvailableColumns(Panel* availableColumns, const ch
}
void Platform_updateTables(Machine* host) {
- PCPDynamicScreen_appendTables(&pcp->screens, host);
- PCPDynamicColumns_setupWidths(&pcp->columns);
+ PCPDynamicScreen_appendTables(&pcp->screens, host);
+ PCPDynamicColumns_setupWidths(&pcp->columns);
}
diff --git a/solaris/SolarisMachine.c b/solaris/SolarisMachine.c
index b94fc742..b9da8afd 100644
--- a/solaris/SolarisMachine.c
+++ b/solaris/SolarisMachine.c
@@ -300,7 +300,7 @@ void Machine_scan(Machine* super) {
Machine* Machine_new(UsersTable* usersTable, uid_t userId) {
SolarisMachine* this = xCalloc(1, sizeof(SolarisMachine));
- Machine *super = &this->super;
+ Machine* super = &this->super;
Machine_init(super, usersTable, userId);

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