From 724aae60d14c1721518c768a48e1e46e3391bb4e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 6 Apr 2018 21:52:50 -0500 Subject: Add tree view flag to man page --- htop.1.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htop.1.in b/htop.1.in index 98164520..774bc099 100644 --- a/htop.1.in +++ b/htop.1.in @@ -3,7 +3,7 @@ htop \- interactive process viewer .SH "SYNOPSIS" .LP -.B htop [\fI\-dChusv\fR] +.B htop [\fI\-dChustv\fR] .SH "DESCRIPTION" .LP Htop is a free (GPL) ncurses-based process viewer for Linux. @@ -41,6 +41,9 @@ Show only the processes of a given user .TP \fB\-v \-\-version Output version information and exit +.TP +\fB\-t \-\-tree +Show processes in tree view .PP .br .SH "INTERACTIVE COMMANDS" -- cgit v1.2.3 From dd33444f7eace81115308eadb568020470c48b2b Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 11:39:12 -0500 Subject: Clean up existing whitespace --- Action.c | 4 ++-- AvailableMetersPanel.c | 4 ++-- BatteryMeter.c | 2 +- CPUMeter.c | 14 ++++++------- CRT.c | 4 ++-- CheckItem.c | 4 ++-- ColorsPanel.c | 2 +- ColumnsPanel.c | 4 ++-- DisplayOptionsPanel.c | 2 +- FunctionBar.c | 2 +- Hashtable.c | 8 +++---- Header.c | 10 ++++----- InfoScreen.c | 4 ++-- MainPanel.c | 6 +++--- MemoryMeter.c | 2 +- Meter.c | 16 +++++++------- Meter.h | 2 +- MetersPanel.c | 2 +- Object.c | 2 +- Object.h | 2 +- Panel.c | 4 ++-- Process.c | 10 ++++----- ProcessList.c | 10 ++++----- RichString.c | 2 +- RichString.h | 2 +- ScreenManager.c | 6 +++--- Settings.c | 16 +++++++------- Settings.h | 2 +- StringUtils.c | 2 +- TasksMeter.c | 6 +++--- Vector.c | 4 ++-- darwin/DarwinProcess.c | 12 +++++------ dragonflybsd/DragonFlyBSDProcessList.c | 2 +- htop.c | 26 +++++++++++------------ linux/Battery.c | 8 +++---- linux/IOPriority.c | 2 +- linux/IOPriority.h | 2 +- linux/LinuxProcess.c | 4 ++-- linux/LinuxProcess.h | 2 +- linux/LinuxProcessList.c | 38 +++++++++++++++++----------------- linux/LinuxProcessList.h | 6 +++--- openbsd/Battery.c | 6 +++--- solaris/Platform.c | 14 ++++++------- solaris/Platform.h | 2 +- solaris/SolarisProcessList.c | 22 ++++++++++---------- solaris/SolarisProcessList.h | 2 +- unsupported/UnsupportedProcessList.c | 2 +- 47 files changed, 155 insertions(+), 155 deletions(-) diff --git a/Action.c b/Action.c index 9a7c3c56..dba77563 100644 --- a/Action.c +++ b/Action.c @@ -66,7 +66,7 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) { Panel* panel = st->panel; Header* header = st->header; Settings* settings = st->settings; - + int y = panel->y; ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false); scr->allowFocusChange = false; @@ -297,7 +297,7 @@ static Htop_Reaction actionSetAffinity(State* st) { return HTOP_OK; #if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY) Panel* panel = st->panel; - + Process* p = (Process*) Panel_getSelected(panel); if (!p) return HTOP_OK; Affinity* affinity = Affinity_get(p, st->pl); diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index ddb55367..f670f6b7 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -52,7 +52,7 @@ static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, M static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) { AvailableMetersPanel* this = (AvailableMetersPanel*) super; Header* header = this->header; - + ListItem* selected = (ListItem*) Panel_getSelected(super); int param = selected->key & 0xff; int type = selected->key >> 16; @@ -104,7 +104,7 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* heade Panel* super = (Panel*) this; FunctionBar* fuBar = FunctionBar_newEnterEsc("Add ", "Done "); Panel_init(super, 1, 1, 1, 1, Class(ListItem), true, fuBar); - + this->settings = settings; this->header = header; this->leftPanel = leftMeters; diff --git a/BatteryMeter.c b/BatteryMeter.c index 214248e2..716b7750 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -35,7 +35,7 @@ int BatteryMeter_attributes[] = { static void BatteryMeter_updateValues(Meter * this, char *buffer, int len) { ACPresence isOnAC; double percent; - + Battery_getData(&percent, &isOnAC); if (percent == -1) { diff --git a/CPUMeter.c b/CPUMeter.c index de5490df..8fbd1d45 100644 --- a/CPUMeter.c +++ b/CPUMeter.c @@ -219,7 +219,7 @@ MeterClass CPUMeter_class = { .defaultMode = BAR_METERMODE, .maxItems = CPU_METER_ITEMCOUNT, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "CPU", .uiName = "CPU", .caption = "CPU", @@ -234,7 +234,7 @@ MeterClass AllCPUsMeter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "AllCPUs", .uiName = "CPUs (1/1)", .description = "CPUs (1/1): all CPUs", @@ -253,7 +253,7 @@ MeterClass AllCPUs2Meter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "AllCPUs2", .uiName = "CPUs (1&2/2)", .description = "CPUs (1&2/2): all CPUs in 2 shorter columns", @@ -272,7 +272,7 @@ MeterClass LeftCPUsMeter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "LeftCPUs", .uiName = "CPUs (1/2)", .description = "CPUs (1/2): first half of list", @@ -291,7 +291,7 @@ MeterClass RightCPUsMeter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "RightCPUs", .uiName = "CPUs (2/2)", .description = "CPUs (2/2): second half of list", @@ -310,7 +310,7 @@ MeterClass LeftCPUs2Meter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "LeftCPUs2", .uiName = "CPUs (1&2/4)", .description = "CPUs (1&2/4): first half in 2 shorter columns", @@ -329,7 +329,7 @@ MeterClass RightCPUs2Meter_class = { }, .defaultMode = CUSTOM_METERMODE, .total = 100.0, - .attributes = CPUMeter_attributes, + .attributes = CPUMeter_attributes, .name = "RightCPUs2", .uiName = "CPUs (3&4/4)", .description = "CPUs (3&4/4): second half in 2 shorter columns", diff --git a/CRT.c b/CRT.c index ca9a10dd..b35a176d 100644 --- a/CRT.c +++ b/CRT.c @@ -604,12 +604,12 @@ void CRT_init(int delay, int colorScheme) { } CRT_colors = CRT_colorSchemes[colorScheme]; CRT_colorScheme = colorScheme; - + for (int i = 0; i < LAST_COLORELEMENT; i++) { unsigned int color = CRT_colorSchemes[COLORSCHEME_DEFAULT][i]; CRT_colorSchemes[COLORSCHEME_BROKENGRAY][i] = color == (A_BOLD | ColorPairGrayBlack) ? ColorPair(White,Black) : color; } - + halfdelay(CRT_delay); nonl(); intrflush(stdscr, false); diff --git a/CheckItem.c b/CheckItem.c index b7ba6fec..910981e8 100644 --- a/CheckItem.c +++ b/CheckItem.c @@ -66,14 +66,14 @@ CheckItem* CheckItem_newByVal(char* text, bool value) { } void CheckItem_set(CheckItem* this, bool value) { - if (this->ref) + if (this->ref) *(this->ref) = value; else this->value = value; } bool CheckItem_get(CheckItem* this) { - if (this->ref) + if (this->ref) return *(this->ref); else return this->value; diff --git a/ColorsPanel.c b/ColorsPanel.c index 2028335f..b2d3500c 100644 --- a/ColorsPanel.c +++ b/ColorsPanel.c @@ -56,7 +56,7 @@ static void ColorsPanel_delete(Object* object) { static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) { ColorsPanel* this = (ColorsPanel*) super; - + HandlerResult result = IGNORED; int mark = Panel_getSelectedIndex(super); diff --git a/ColumnsPanel.c b/ColumnsPanel.c index 8974ffdc..f982292e 100644 --- a/ColumnsPanel.c +++ b/ColumnsPanel.c @@ -40,7 +40,7 @@ static void ColumnsPanel_delete(Object* object) { static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { ColumnsPanel* const this = (ColumnsPanel*) super; - + int selected = Panel_getSelectedIndex(super); HandlerResult result = IGNORED; int size = Panel_size(super); @@ -87,7 +87,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { case ']': case '+': { - if (selected < size - 2) + if (selected < size - 2) Panel_moveSelectedDown(super); result = HANDLED; break; diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 0ff54e33..40b8d987 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -39,7 +39,7 @@ static void DisplayOptionsPanel_delete(Object* object) { static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) { DisplayOptionsPanel* this = (DisplayOptionsPanel*) super; - + HandlerResult result = IGNORED; CheckItem* selected = (CheckItem*) Panel_getSelected(super); diff --git a/FunctionBar.c b/FunctionBar.c index 4e4baaf3..8661bf0c 100644 --- a/FunctionBar.c +++ b/FunctionBar.c @@ -52,7 +52,7 @@ FunctionBar* FunctionBar_new(const char* const* functions, const char* const* ke this->functions[i] = xStrdup(functions[i]); } if (keys && events) { - this->staticData = false; + this->staticData = false; this->keys = xCalloc(15, sizeof(char*)); this->events = xCalloc(15, sizeof(int)); int i = 0; diff --git a/Hashtable.c b/Hashtable.c index b3eac8da..3436dad6 100644 --- a/Hashtable.c +++ b/Hashtable.c @@ -63,7 +63,7 @@ int Hashtable_count(Hashtable* this) { static HashtableItem* HashtableItem_new(unsigned int key, void* value) { HashtableItem* this; - + this = xMalloc(sizeof(HashtableItem)); this->key = key; this->value = value; @@ -73,7 +73,7 @@ static HashtableItem* HashtableItem_new(unsigned int key, void* value) { Hashtable* Hashtable_new(int size, bool owner) { Hashtable* this; - + this = xMalloc(sizeof(Hashtable)); this->items = 0; this->size = size; @@ -119,10 +119,10 @@ void Hashtable_put(Hashtable* this, unsigned int key, void* value) { void* Hashtable_remove(Hashtable* this, unsigned int key) { unsigned int index = key % this->size; - + assert(Hashtable_isConsistent(this)); - HashtableItem** bucket; + HashtableItem** bucket; for (bucket = &(this->buckets[index]); *bucket; bucket = &((*bucket)->next) ) { if ((*bucket)->key == key) { void* value = (*bucket)->value; diff --git a/Header.c b/Header.c index e048ee55..7742289f 100644 --- a/Header.c +++ b/Header.c @@ -76,17 +76,17 @@ void Header_populateFromSettings(Header* this) { void Header_writeBackToSettings(const Header* this) { Header_forEachColumn(this, col) { MeterColumnSettings* colSettings = &this->settings->columns[col]; - + String_freeArray(colSettings->names); free(colSettings->modes); - + Vector* vec = this->columns[col]; int len = Vector_size(vec); - + colSettings->names = xCalloc(len+1, sizeof(char*)); colSettings->modes = xCalloc(len, sizeof(int)); colSettings->len = len; - + for (int i = 0; i < len; i++) { Meter* meter = (Meter*) Vector_get(vec, i); char* name = xCalloc(64, sizeof(char)); @@ -186,7 +186,7 @@ void Header_draw(const Header* this) { } int width = COLS / this->nrColumns - (pad * this->nrColumns - 1) - 1; int x = pad; - + Header_forEachColumn(this, col) { Vector* meters = this->columns[col]; for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) { diff --git a/InfoScreen.c b/InfoScreen.c index fab8daea..0e7543a3 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -120,7 +120,7 @@ void InfoScreen_run(InfoScreen* this) { } set_escdelay(25); int ch = getch(); - + if (ch == ERR) { if (As_InfoScreen(this)->onErr) { InfoScreen_onErr(this); @@ -143,7 +143,7 @@ void InfoScreen_run(InfoScreen* this) { IncSet_handleKey(this->inc, ch, panel, IncSet_getListItemValue, this->lines); continue; } - + switch(ch) { case ERR: continue; diff --git a/MainPanel.c b/MainPanel.c index 25023367..b271162a 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -69,7 +69,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { MainPanel* this = (MainPanel*) super; HandlerResult result = IGNORED; - + Htop_Reaction reaction = HTOP_OK; if (EVENT_IS_HEADER_CLICK(ch)) { @@ -84,7 +84,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { } else { reaction |= Action_setSortKey(settings, field); } - reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS; + reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS; result = HANDLED; } else if (ch != ERR && this->inc->active) { bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL); @@ -121,7 +121,7 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) { } if (reaction & HTOP_REFRESH) { result |= REDRAW; - } + } if (reaction & HTOP_RECALCULATE) { result |= RESCAN; } diff --git a/MemoryMeter.c b/MemoryMeter.c index fbf5330c..8d5d809e 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -60,7 +60,7 @@ MeterClass MemoryMeter_class = { .delete = Meter_delete, .display = MemoryMeter_display, }, - .updateValues = MemoryMeter_updateValues, + .updateValues = MemoryMeter_updateValues, .defaultMode = BAR_METERMODE, .maxItems = 3, .total = 100.0, diff --git a/Meter.c b/Meter.c index 05a4eb23..e2a29a69 100644 --- a/Meter.c +++ b/Meter.c @@ -78,7 +78,7 @@ typedef struct MeterClass_ { struct Meter_ { Object super; Meter_Draw draw; - + char* caption; int mode; int param; @@ -275,7 +275,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { attrset(CRT_colors[BAR_BORDER]); mvaddch(y, x, '['); mvaddch(y, x + w, ']'); - + w--; x++; @@ -284,7 +284,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) { return; } char bar[w + 1]; - + int blockSizes[10]; xSnprintf(bar, w + 1, "%*.*s", w, w, buffer); @@ -378,7 +378,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { mvaddnstr(y, x, this->caption, captionLen); x += captionLen; w -= captionLen; - + struct timeval now; gettimeofday(&now, NULL); if (!timercmp(&now, &(data->time), <)) { @@ -387,10 +387,10 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { for (int i = 0; i < nValues - 1; i++) data->values[i] = data->values[i+1]; - + char buffer[nValues]; Meter_updateValues(this, buffer, nValues - 1); - + double value = 0.0; int items = Meter_getItems(this); for (int i = 0; i < items; i++) @@ -398,7 +398,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { value /= this->total; data->values[nValues - 1] = value; } - + int i = nValues - (w*2) + 2, k = 0; if (i < 0) { k = -i/2; @@ -459,7 +459,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) { char buffer[METER_BUFFER_LEN]; Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1); - + RichString_begin(out); Meter_displayBuffer(this, buffer, &out); diff --git a/Meter.h b/Meter.h index d98c910e..4a7ce448 100644 --- a/Meter.h +++ b/Meter.h @@ -65,7 +65,7 @@ typedef struct MeterClass_ { struct Meter_ { Object super; Meter_Draw draw; - + char* caption; int mode; int param; diff --git a/MetersPanel.c b/MetersPanel.c index 3cf3e075..397a6c7d 100644 --- a/MetersPanel.c +++ b/MetersPanel.c @@ -93,7 +93,7 @@ static inline bool moveToNeighbor(MetersPanel* this, MetersPanel* neighbor, int static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) { MetersPanel* this = (MetersPanel*) super; - + int selected = Panel_getSelectedIndex(super); HandlerResult result = IGNORED; bool sideMove = false; diff --git a/Object.c b/Object.c index 120d28c1..cf13b648 100644 --- a/Object.c +++ b/Object.c @@ -28,7 +28,7 @@ typedef void(*Object_Delete)(Object*); #define Class(class_) ((ObjectClass*)(&(class_ ## _class))) #define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_)); - + typedef struct ObjectClass_ { const void* extends; const Object_Display display; diff --git a/Object.h b/Object.h index 19a667c8..fdb9b37c 100644 --- a/Object.h +++ b/Object.h @@ -29,7 +29,7 @@ typedef void(*Object_Delete)(Object*); #define Class(class_) ((ObjectClass*)(&(class_ ## _class))) #define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_)); - + typedef struct ObjectClass_ { const void* extends; const Object_Display display; diff --git a/Panel.c b/Panel.c index 1e53b4a4..fc4fa3c2 100644 --- a/Panel.c +++ b/Panel.c @@ -372,7 +372,7 @@ void Panel_draw(Panel* this, bool focus) { bool Panel_onKey(Panel* this, int key) { assert (this != NULL); - + int size = Vector_size(this->items); switch (key) { case KEY_DOWN: @@ -455,7 +455,7 @@ bool Panel_onKey(Panel* this, int key) { if (this->selected < 0 || size == 0) { this->selected = 0; this->needsRedraw = true; - } else if (this->selected >= size) { + } else if (this->selected >= size) { this->selected = size - 1; this->needsRedraw = true; } diff --git a/Process.c b/Process.c index 54c41af4..1738d3b7 100644 --- a/Process.c +++ b/Process.c @@ -216,7 +216,7 @@ void Process_setupColumnWidths() { void Process_humanNumber(RichString* str, unsigned long number, bool coloring) { char buffer[11]; int len; - + int largeNumberColor = CRT_colors[LARGE_NUMBER]; int processMegabytesColor = CRT_colors[PROCESS_MEGABYTES]; int processColor = CRT_colors[PROCESS]; @@ -224,7 +224,7 @@ void Process_humanNumber(RichString* str, unsigned long number, bool coloring) { largeNumberColor = CRT_colors[PROCESS]; processMegabytesColor = CRT_colors[PROCESS]; } - + if(number >= (10 * ONE_DECIMAL_M)) { #ifdef __LP64__ if(number >= (100 * ONE_DECIMAL_G)) { @@ -380,9 +380,9 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) { switch (field) { case PERCENT_CPU: { if (this->percent_cpu > 999.9) { - xSnprintf(buffer, n, "%4u ", (unsigned int)this->percent_cpu); + xSnprintf(buffer, n, "%4u ", (unsigned int)this->percent_cpu); } else if (this->percent_cpu > 99.9) { - xSnprintf(buffer, n, "%3u. ", (unsigned int)this->percent_cpu); + xSnprintf(buffer, n, "%3u. ", (unsigned int)this->percent_cpu); } else { xSnprintf(buffer, n, "%4.1f ", this->percent_cpu); } @@ -390,7 +390,7 @@ void Process_writeField(Process* this, RichString* str, ProcessField field) { } case PERCENT_MEM: { if (this->percent_mem > 99.9) { - xSnprintf(buffer, n, "100. "); + xSnprintf(buffer, n, "100. "); } else { xSnprintf(buffer, n, "%4.1f ", this->percent_mem); } diff --git a/ProcessList.c b/ProcessList.c index 7482b037..edbc114c 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -84,10 +84,10 @@ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* this->usersTable = usersTable; this->pidWhiteList = pidWhiteList; this->userId = userId; - + // tree-view auxiliary buffer this->processes2 = Vector_new(klass, true, DEFAULT_SIZE); - + // set later by platform-specific code this->cpuCount = 0; @@ -138,10 +138,10 @@ void ProcessList_printHeader(ProcessList* this, RichString* header) { void ProcessList_add(ProcessList* this, Process* p) { assert(Vector_indexOf(this->processes, p, Process_pidCompare) == -1); assert(Hashtable_get(this->processTable, p->pid) == NULL); - + Vector_add(this->processes, p); Hashtable_put(this->processTable, p->pid, p); - + assert(Vector_indexOf(this->processes, p, Process_pidCompare) != -1); assert(Hashtable_get(this->processTable, p->pid) != NULL); assert(Hashtable_count(this->processTable) == Vector_count(this->processes)); @@ -353,7 +353,7 @@ void ProcessList_scan(ProcessList* this) { this->runningTasks = 0; ProcessList_goThroughEntries(this); - + for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { Process* p = (Process*) Vector_get(this->processes, i); if (p->updated == false) diff --git a/RichString.c b/RichString.c index 370566a8..d246f1e1 100644 --- a/RichString.c +++ b/RichString.c @@ -67,7 +67,7 @@ typedef struct RichString_ { #define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) #endif -#define charBytes(n) (sizeof(CharType) * (n)) +#define charBytes(n) (sizeof(CharType) * (n)) static void RichString_extendLen(RichString* this, int len) { if (this->chlen <= RICHSTRING_MAXLEN) { diff --git a/RichString.h b/RichString.h index f5b5cba1..17649d0f 100644 --- a/RichString.h +++ b/RichString.h @@ -63,7 +63,7 @@ typedef struct RichString_ { #define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x))) #endif -#define charBytes(n) (sizeof(CharType) * (n)) +#define charBytes(n) (sizeof(CharType) * (n)) #define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0) diff --git a/ScreenManager.c b/ScreenManager.c index 06e90193..54d4ea45 100644 --- a/ScreenManager.c +++ b/ScreenManager.c @@ -163,7 +163,7 @@ static Panel* setCurrentPanel(Panel* panel) { void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { bool quit = false; int focus = 0; - + Panel* panelFocus = setCurrentPanel((Panel*) Vector_get(this->panels, focus)); double oldTime = 0.0; @@ -181,7 +181,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { if (this->header) { checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut); } - + if (redraw) { ScreenManager_drawPanels(this, focus); } @@ -269,7 +269,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { quit = true; continue; } - + switch (ch) { case KEY_RESIZE: { diff --git a/Settings.c b/Settings.c index db2fa066..fea6c3b7 100644 --- a/Settings.c +++ b/Settings.c @@ -31,7 +31,7 @@ typedef struct { typedef struct Settings_ { char* filename; - + MeterColumnSettings columns[2]; ProcessField* fields; @@ -114,7 +114,7 @@ static void Settings_defaultMeters(Settings* this) { this->columns[i].modes = xCalloc(sizes[i], sizeof(int)); this->columns[i].len = sizes[i]; } - + int r = 0; if (this->cpuCount > 8) { this->columns[0].names[0] = xStrdup("LeftCPUs2"); @@ -134,7 +134,7 @@ static void Settings_defaultMeters(Settings* this) { this->columns[0].modes[1] = BAR_METERMODE; this->columns[0].names[2] = xStrdup("Swap"); this->columns[0].modes[2] = BAR_METERMODE; - + this->columns[1].names[r] = xStrdup("Tasks"); this->columns[1].modes[r++] = TEXT_METERMODE; this->columns[1].names[r] = xStrdup("LoadAverage"); @@ -165,13 +165,13 @@ static void readFields(ProcessField* fields, int* flags, const char* line) { static bool Settings_read(Settings* this, const char* fileName) { FILE* fd; - + CRT_dropPrivileges(); fd = fopen(fileName, "r"); CRT_restorePrivileges(); if (!fd) return false; - + bool didReadMeters = false; bool didReadFields = false; for (;;) { @@ -325,7 +325,7 @@ bool Settings_write(Settings* this) { } Settings* Settings_new(int cpuCount) { - + Settings* this = xCalloc(1, sizeof(Settings)); this->sortKey = PERCENT_CPU; @@ -344,7 +344,7 @@ Settings* Settings_new(int cpuCount) { this->cpuCount = cpuCount; this->showProgramPath = true; this->highlightThreads = true; - + this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField)); // TODO: turn 'fields' into a Vector, // (and ProcessFields into proper objects). @@ -375,7 +375,7 @@ Settings* Settings_new(int cpuCount) { htopDir = String_cat(home, "/.config/htop"); } legacyDotfile = String_cat(home, "/.htoprc"); - + CRT_dropPrivileges(); (void) mkdir(configDir, 0700); (void) mkdir(htopDir, 0700); diff --git a/Settings.h b/Settings.h index d9dc0683..d662c319 100644 --- a/Settings.h +++ b/Settings.h @@ -22,7 +22,7 @@ typedef struct { typedef struct Settings_ { char* filename; - + MeterColumnSettings columns[2]; ProcessField* fields; diff --git a/StringUtils.c b/StringUtils.c index 0578cdea..2f5889f6 100644 --- a/StringUtils.c +++ b/StringUtils.c @@ -116,7 +116,7 @@ char* String_getToken(const char* line, const unsigned short int numMatch) { if (lastState == 0 && inWord == 1) count++; - + if(inWord == 1){ if (count == numMatch && line[i] != ' ' && line[i] != '\0' && line[i] != '\n' && line[i] != (char)EOF) { match[foundCount] = line[i]; diff --git a/TasksMeter.c b/TasksMeter.c index f56c8613..996109cf 100644 --- a/TasksMeter.c +++ b/TasksMeter.c @@ -37,9 +37,9 @@ static void TasksMeter_display(Object* cast, RichString* out) { Meter* this = (Meter*)cast; Settings* settings = this->pl->settings; char buffer[20]; - + int processes = (int) this->values[2]; - + xSnprintf(buffer, sizeof(buffer), "%d", processes); RichString_write(out, CRT_colors[METER_VALUE], buffer); int threadValueColor = CRT_colors[METER_VALUE]; @@ -76,7 +76,7 @@ MeterClass TasksMeter_class = { .defaultMode = TEXT_METERMODE, .maxItems = 4, .total = 100.0, - .attributes = TasksMeter_attributes, + .attributes = TasksMeter_attributes, .name = "Tasks", .uiName = "Task counter", .caption = "Tasks: " diff --git a/Vector.c b/Vector.c index 6eb91ae6..819d9863 100644 --- a/Vector.c +++ b/Vector.c @@ -195,7 +195,7 @@ void Vector_insert(Vector* this, int idx, void* data_) { if (idx > this->items) { idx = this->items; } - + Vector_checkArraySize(this); //assert(this->array[this->items] == NULL); for (int i = this->items; i > idx; i--) { @@ -302,7 +302,7 @@ inline int Vector_size(Vector* this) { static void Vector_merge(Vector* this, Vector* v2) { int i; assert(Vector_isConsistent(this)); - + for (i = 0; i < v2->items; i++) Vector_add(this, v2->array[i]); v2->items = 0; diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index e1a16f9c..bf5fd577 100644 --- a/darwin/DarwinProcess.c +++ b/darwin/DarwinProcess.c @@ -212,7 +212,7 @@ ERROR_B: ERROR_A: retval = xStrdup(k->kp_proc.p_comm); *basenameOffset = strlen(retval); - + return retval; } @@ -302,11 +302,11 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList void DarwinProcess_scanThreads(DarwinProcess *dp) { Process* proc = (Process*) dp; kern_return_t ret; - + if (!dp->taskAccess) { return; } - + if (proc->state == 'Z') { return; } @@ -317,7 +317,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) { dp->taskAccess = false; return; } - + task_info_data_t tinfo; mach_msg_type_number_t task_info_count = TASK_INFO_MAX; ret = task_info(port, TASK_BASIC_INFO, (task_info_t) tinfo, &task_info_count); @@ -325,7 +325,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) { dp->taskAccess = false; return; } - + thread_array_t thread_list; mach_msg_type_number_t thread_count; ret = task_threads(port, &thread_list, &thread_count); @@ -334,7 +334,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) { mach_port_deallocate(mach_task_self(), port); return; } - + integer_t run_state = 999; for (unsigned int i = 0; i < thread_count; i++) { thread_info_data_t thinfo; diff --git a/dragonflybsd/DragonFlyBSDProcessList.c b/dragonflybsd/DragonFlyBSDProcessList.c index a41af854..5bc4b384 100644 --- a/dragonflybsd/DragonFlyBSDProcessList.c +++ b/dragonflybsd/DragonFlyBSDProcessList.c @@ -565,7 +565,7 @@ void ProcessList_goThroughEntries(ProcessList* this) { if (kproc->kp_flags & P_JAILED) { proc->state = 'J'; } - + if (Process_isKernelThread(dfp)) { this->kernelThreads++; } diff --git a/htop.c b/htop.c index 8c88c782..07a4fdf9 100644 --- a/htop.c +++ b/htop.c @@ -34,7 +34,7 @@ static void printVersionFlag() { stdout); exit(0); } - + static void printHelpFlag() { fputs("htop " VERSION " - " COPYRIGHT "\n" "Released under the GNU GPL.\n\n" @@ -186,12 +186,12 @@ int main(int argc, char** argv) { exit(1); } #endif - + Process_setupColumnWidths(); - + UsersTable* ut = UsersTable_new(); ProcessList* pl = ProcessList_new(ut, flags.pidWhiteList, flags.userId); - + Settings* settings = Settings_new(pl->cpuCount); pl->settings = settings; @@ -201,18 +201,18 @@ int main(int argc, char** argv) { if (flags.delay != -1) settings->delay = flags.delay; - if (!flags.useColors) + if (!flags.useColors) settings->colorScheme = COLORSCHEME_MONOCHROME; if (flags.treeView) settings->treeView = true; CRT_init(settings->delay, settings->colorScheme); - + MainPanel* panel = MainPanel_new(); ProcessList_setPanel(pl, (Panel*) panel); MainPanel_updateTreeFunctions(panel, settings->treeView); - + if (flags.sortKey > 0) { settings->sortKey = flags.sortKey; settings->treeView = false; @@ -228,7 +228,7 @@ int main(int argc, char** argv) { .header = header, }; MainPanel_setState(panel, &state); - + ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true); ScreenManager_add(scr, (Panel*) panel, -1); @@ -236,13 +236,13 @@ int main(int argc, char** argv) { millisleep(75); ProcessList_scan(pl); - ScreenManager_run(scr, NULL, NULL); - + ScreenManager_run(scr, NULL, NULL); + attron(CRT_colors[RESET_COLOR]); mvhline(LINES-1, 0, ' ', COLS); attroff(CRT_colors[RESET_COLOR]); refresh(); - + CRT_done(); if (settings->changed) Settings_write(settings); @@ -250,10 +250,10 @@ int main(int argc, char** argv) { ProcessList_delete(pl); ScreenManager_delete(scr); - + UsersTable_delete(ut); Settings_delete(settings); - + if(flags.pidWhiteList) { Hashtable_delete(flags.pidWhiteList); } diff --git a/linux/Battery.c b/linux/Battery.c index aedacabc..7b9e79a1 100644 --- a/linux/Battery.c +++ b/linux/Battery.c @@ -78,7 +78,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short const unsigned long int foundNum = atoi(foundNumStr); free(foundNumStr); free(line); - + total += foundNum; } @@ -175,7 +175,7 @@ static inline ssize_t xread(int fd, void *buf, size_t count) { } static void Battery_getSysData(double* level, ACPresence* isOnAC) { - + *level = 0; *isOnAC = AC_ERROR; @@ -194,7 +194,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { const char filePath[50]; if (entryName[0] == 'B' && entryName[1] == 'A' && entryName[2] == 'T') { - + xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName); int fd = open(filePath, O_RDONLY); if (fd == -1) { @@ -247,7 +247,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { if (*isOnAC != AC_ERROR) { continue; } - + xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName); int fd = open(filePath, O_RDONLY); if (fd == -1) { diff --git a/linux/IOPriority.c b/linux/IOPriority.c index dd7c84a1..80007df0 100644 --- a/linux/IOPriority.c +++ b/linux/IOPriority.c @@ -4,7 +4,7 @@ htop - IOPriority.c Released under the GNU GPL, see the COPYING file in the source distribution for its full text. -Based on ionice, +Based on ionice, Copyright (C) 2005 Jens Axboe Released under the terms of the GNU General Public License version 2 */ diff --git a/linux/IOPriority.h b/linux/IOPriority.h index 148e344c..1c9ca95b 100644 --- a/linux/IOPriority.h +++ b/linux/IOPriority.h @@ -8,7 +8,7 @@ htop - IOPriority.h Released under the GNU GPL, see the COPYING file in the source distribution for its full text. -Based on ionice, +Based on ionice, Copyright (C) 2005 Jens Axboe Released under the terms of the GNU General Public License version 2 */ diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 5f697078..3bedbf66 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -117,7 +117,7 @@ typedef struct LinuxProcess_ { unsigned long long io_write_bytes; unsigned long long io_cancelled_write_bytes; unsigned long long io_rate_read_time; - unsigned long long io_rate_write_time; + unsigned long long io_rate_write_time; double io_rate_read_bps; double io_rate_write_bps; #endif @@ -394,7 +394,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) attr = CRT_colors[PROCESS_HIGH_PRIORITY]; xSnprintf(buffer, n, "R%1d ", IOPriority_data(lp->ioPriority)); } else if (klass == IOPRIO_CLASS_IDLE) { - attr = CRT_colors[PROCESS_LOW_PRIORITY]; + attr = CRT_colors[PROCESS_LOW_PRIORITY]; xSnprintf(buffer, n, "id "); } else { xSnprintf(buffer, n, "?? "); diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 6ce3037d..4b81539f 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -108,7 +108,7 @@ typedef struct LinuxProcess_ { unsigned long long io_write_bytes; unsigned long long io_cancelled_write_bytes; unsigned long long io_rate_read_time; - unsigned long long io_rate_write_time; + unsigned long long io_rate_write_time; double io_rate_read_bps; double io_rate_write_bps; #endif diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 5f38540c..ec543be6 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -62,7 +62,7 @@ typedef struct CPUData_ { unsigned long long int softIrqTime; unsigned long long int stealTime; unsigned long long int guestTime; - + unsigned long long int totalPeriod; unsigned long long int userPeriod; unsigned long long int systemPeriod; @@ -86,10 +86,10 @@ typedef struct TtyDriver_ { typedef struct LinuxProcessList_ { ProcessList super; - + CPUData* cpus; TtyDriver* ttyDrivers; - + #ifdef HAVE_DELAYACCT struct nl_sock *netlink_socket; int netlink_family; @@ -319,7 +319,7 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, location += 2; char *end = strrchr(location, ')'); if (!end) return false; - + int commsize = end - location; memcpy(command, location, commsize); command[commsize] = '\0'; @@ -370,9 +370,9 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, location += 1; assert(location != NULL); process->processor = strtol(location, &location, 10); - + process->time = lp->utime + lp->stime; - + return true; } @@ -412,7 +412,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_rate_write_time = -1LL; return; } - + char buffer[1024]; ssize_t buflen = xread(fd, buffer, 1023); close(fd); @@ -429,7 +429,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_rchar = strtoull(line+7, NULL, 10); else if (strncmp(line+1, "ead_bytes: ", 11) == 0) { process->io_read_bytes = strtoull(line+12, NULL, 10); - process->io_rate_read_bps = + process->io_rate_read_bps = ((double)(process->io_read_bytes - last_read))/(((double)(now - process->io_rate_read_time))/1000); process->io_rate_read_time = now; } @@ -439,7 +439,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna process->io_wchar = strtoull(line+7, NULL, 10); else if (strncmp(line+1, "rite_bytes: ", 12) == 0) { process->io_write_bytes = strtoull(line+13, NULL, 10); - process->io_rate_write_bps = + process->io_rate_write_bps = ((double)(process->io_write_bytes - last_write))/(((double)(now - process->io_rate_write_time))/1000); process->io_rate_write_time = now; } @@ -661,7 +661,7 @@ static void LinuxProcessList_readDelayAcctData(LinuxProcessList* this, LinuxProc process->cpu_delay_percent = -1LL; return; } - + if (nl_recvmsgs_default(this->netlink_socket) < 0) { return; } @@ -685,11 +685,11 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna int fd = open(filename, O_RDONLY); if (fd == -1) return false; - + char command[4096+1]; // max cmdline length on Linux int amtRead = xread(fd, command, sizeof(command) - 1); close(fd); - int tokenEnd = 0; + int tokenEnd = 0; int lastChar = 0; if (amtRead == 0) { ((LinuxProcess*)process)->isKernelThread = true; @@ -726,13 +726,13 @@ static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned in i++; if ((!ttyDrivers[i].path) || maj < ttyDrivers[i].major) { break; - } + } if (maj > ttyDrivers[i].major) { continue; } if (min < ttyDrivers[i].minorFrom) { break; - } + } if (min > ttyDrivers[i].minorTo) { continue; } @@ -790,17 +790,17 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* // filename is a number: process directory int pid = atoi(name); - + if (parent && pid == parent->pid) continue; - if (pid <= 0) + if (pid <= 0) continue; bool preExisting = false; Process* proc = ProcessList_getProcess(pl, pid, &preExisting, (Process_New) LinuxProcess_new); proc->tgid = parent ? parent->pid : pid; - + LinuxProcess* lp = (LinuxProcess*) proc; char subdirname[MAX_NAME+1]; @@ -846,7 +846,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* LinuxProcessList_readOpenVZData(lp, dirname, name); } #endif - + #ifdef HAVE_VSERVER if (settings->flags & PROCESS_FLAG_LINUX_VSERVER) { LinuxProcessList_readVServerData(lp, dirname, name); @@ -874,7 +874,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char* if (settings->flags & PROCESS_FLAG_LINUX_CGROUP) LinuxProcessList_readCGroupFile(lp, dirname, name); #endif - + if (settings->flags & PROCESS_FLAG_LINUX_OOM) LinuxProcessList_readOomData(lp, dirname, name); diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index f30b487d..81f87a59 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -35,7 +35,7 @@ typedef struct CPUData_ { unsigned long long int softIrqTime; unsigned long long int stealTime; unsigned long long int guestTime; - + unsigned long long int totalPeriod; unsigned long long int userPeriod; unsigned long long int systemPeriod; @@ -59,10 +59,10 @@ typedef struct TtyDriver_ { typedef struct LinuxProcessList_ { ProcessList super; - + CPUData* cpus; TtyDriver* ttyDrivers; - + #ifdef HAVE_DELAYACCT struct nl_sock *netlink_socket; int netlink_family; diff --git a/openbsd/Battery.c b/openbsd/Battery.c index 3a0bae14..70fb6298 100644 --- a/openbsd/Battery.c +++ b/openbsd/Battery.c @@ -34,7 +34,7 @@ void Battery_getData(double* level, ACPresence* isOnAC) { size_t sdlen = sizeof(struct sensordev); bool found = findDevice("acpibat0", mib, &snsrdev, &sdlen); - + *level = -1; if (found) { /* last full capacity */ @@ -57,9 +57,9 @@ void Battery_getData(double* level, ACPresence* isOnAC) { } } } - + found = findDevice("acpiac0", mib, &snsrdev, &sdlen); - + *isOnAC = AC_ERROR; if (found) { mib[3] = 9; diff --git a/solaris/Platform.c b/solaris/Platform.c index a29fcb47..396b502c 100644 --- a/solaris/Platform.c +++ b/solaris/Platform.c @@ -48,7 +48,7 @@ typedef struct var kvar_t; typedef struct envAccum_ { size_t capacity; size_t size; - size_t bytes; + size_t bytes; char *env; } envAccum; @@ -136,7 +136,7 @@ extern char Process_pidFormat[20]; int Platform_getUptime() { int boot_time = 0; - int curr_time = time(NULL); + int curr_time = time(NULL); struct utmpx * ent; while (( ent = getutxent() )) { @@ -170,7 +170,7 @@ int Platform_getMaxPid() { vproc = ksvar->v_proc; } if (kc != NULL) { kstat_close(kc); } - return vproc; + return vproc; } double Platform_setCPUValues(Meter* this, int cpu) { @@ -223,7 +223,7 @@ void Platform_setSwapValues(Meter* this) { static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr_t addr, const char *str) { envAccum *accump = accum; (void) Phandle; - (void) addr; + (void) addr; size_t thissz = strlen(str); if ((thissz + 2) > (accump->capacity - accump->size)) accump->env = xRealloc(accump->env, accump->capacity *= 2); @@ -232,7 +232,7 @@ static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size)); strncpy( accump->env + accump->size + thissz + 1, "\n", 1); accump->size = accump->size + thissz + 1; - return 0; + return 0; } char* Platform_getProcessEnv(pid_t pid) { @@ -240,7 +240,7 @@ char* Platform_getProcessEnv(pid_t pid) { pid_t realpid = pid / 1024; int graberr; struct ps_prochandle *Phandle; - + if ((Phandle = Pgrab(realpid,PGRAB_RDONLY,&graberr)) == NULL) return "Unable to read process environment."; @@ -248,7 +248,7 @@ char* Platform_getProcessEnv(pid_t pid) { envBuilder.size = 0; envBuilder.env = xMalloc(envBuilder.capacity); - (void) Penv_iter(Phandle,Platform_buildenv,&envBuilder); + (void) Penv_iter(Phandle,Platform_buildenv,&envBuilder); Prelease(Phandle, 0); diff --git a/solaris/Platform.h b/solaris/Platform.h index f961b913..ffec60c9 100644 --- a/solaris/Platform.h +++ b/solaris/Platform.h @@ -27,7 +27,7 @@ typedef struct var kvar_t; typedef struct envAccum_ { size_t capacity; size_t size; - size_t bytes; + size_t bytes; char *env; } envAccum; diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c index 2c681852..f452fe79 100644 --- a/solaris/SolarisProcessList.c +++ b/solaris/SolarisProcessList.c @@ -153,7 +153,7 @@ static inline void SolarisProcessList_scanCPUTime(ProcessList* pl) { idlebuf += cpuData->idlePercent; } } - + if (cpus > 1) { CPUData* cpuData = &(spl->cpus[0]); cpuData->userPercent = userbuf / cpus; @@ -177,7 +177,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { uint64_t totalswap = 0; uint64_t totalfree = 0; int nswap = 0; - char *spath = NULL; + char *spath = NULL; char *spathbase = NULL; // Part 1 - physical memory @@ -191,7 +191,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { pl->totalMem = totalmem_pgs->value.ui64 * PAGE_SIZE_KB; pl->usedMem = lockedmem_pgs->value.ui64 * PAGE_SIZE_KB; // Not sure how to implement this on Solaris - suggestions welcome! - pl->cachedMem = 0; + pl->cachedMem = 0; // Not really "buffers" but the best Solaris analogue that I can find to // "memory in use but not by programs or the kernel itself" pl->buffersMem = (totalmem_pgs->value.ui64 - pages->value.ui64) * PAGE_SIZE_KB; @@ -202,12 +202,12 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { pl->cachedMem = 0; pl->usedMem = pl->totalMem - (sysconf(_SC_AVPHYS_PAGES) * PAGE_SIZE); } - + // Part 2 - swap nswap = swapctl(SC_GETNSWP, NULL); if (nswap > 0) { sl = xMalloc((nswap * sizeof(swapent_t)) + sizeof(int)); } if (sl != NULL) { spathbase = xMalloc( nswap * MAXPATHLEN ); } - if (spathbase != NULL) { + if (spathbase != NULL) { spath = spathbase; swapdev = sl->swt_ent; for (int i = 0; i < nswap; i++, swapdev++) { @@ -217,7 +217,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { sl->swt_n = nswap; } nswap = swapctl(SC_LIST, sl); - if (nswap > 0) { + if (nswap > 0) { swapdev = sl->swt_ent; for (int i = 0; i < nswap; i++, swapdev++) { totalswap += swapdev->ste_pages; @@ -227,7 +227,7 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) { free(spathbase); free(sl); pl->totalSwap = totalswap * PAGE_SIZE_KB; - pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB); + pl->usedSwap = pl->totalSwap - (totalfree * PAGE_SIZE_KB); } void ProcessList_delete(ProcessList* pl) { @@ -242,7 +242,7 @@ void ProcessList_delete(ProcessList* pl) { * and MUST conform to the appropriate definition in order * to work. See libproc(3LIB) on a Solaris or Illumos * system for more info. - */ + */ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr) { struct timeval tv; @@ -262,7 +262,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * getpid = _psinfo->pr_pid * 1024; } else { getpid = lwpid; - } + } Process *proc = ProcessList_getProcess(pl, getpid, &preExisting, (Process_New) SolarisProcess_new); SolarisProcess *sproc = (SolarisProcess*) proc; @@ -293,7 +293,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * sproc->realpid = _psinfo->pr_pid; sproc->lwpid = lwpid_real; sproc->zoneid = _psinfo->pr_zoneid; - sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc); + sproc->zname = SolarisProcessList_readZoneName(spl->kd,sproc); proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid); proc->comm = xStrdup(_psinfo->pr_fname); proc->commLen = strnlen(_psinfo->pr_fname,PRFNSZ); @@ -332,7 +332,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void * proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu/(double)32768)*(double)100.0; proc->time = _lwpsinfo->pr_time.tv_sec; if (!preExisting) { // Tasks done only for NEW LWPs - sproc->is_lwp = true; + sproc->is_lwp = true; proc->basenameOffset = -1; proc->ppid = _psinfo->pr_pid * 1024; proc->tgid = _psinfo->pr_pid * 1024; diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h index a5f2fbc2..9d2309cc 100644 --- a/solaris/SolarisProcessList.h +++ b/solaris/SolarisProcessList.h @@ -54,7 +54,7 @@ void ProcessList_delete(ProcessList* pl); * and MUST conform to the appropriate definition in order * to work. See libproc(3LIB) on a Solaris or Illumos * system for more info. - */ + */ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *listptr); diff --git a/unsupported/UnsupportedProcessList.c b/unsupported/UnsupportedProcessList.c index 9be4eee4..65749b18 100644 --- a/unsupported/UnsupportedProcessList.c +++ b/unsupported/UnsupportedProcessList.c @@ -18,7 +18,7 @@ in the source distribution for its full text. ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { ProcessList* this = xCalloc(1, sizeof(ProcessList)); ProcessList_init(this, Class(Process), usersTable, pidWhiteList, userId); - + return this; } -- cgit v1.2.3 From 63fbc3b51704b4b122d2cab57de7e7f9dfcc03b1 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 31 Oct 2019 11:39:57 -0500 Subject: Add `trim_trailing_whitespace` to editorconfig --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 18807892..dd881dd0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,4 @@ charset = utf-8 [*.{c,h}] indent_style = space indent_size = 3 +trim_trailing_whitespace = true -- cgit v1.2.3