Skip to content

Commit cfb561f

Browse files
committed
Display a platform-specific failed state message
Further discussion around earlier PR #1745 (relating to improved handling of PCP pmcd connection loss) centered on more descriptive function names and diagnostics. In this commit the boolean logic in Platform_getValidState has been reversed to *FailedState, and we also overload the diagnostic message pointer such that NULL indicates a successful update (no error to report).
1 parent 79abc57 commit cfb561f

File tree

14 files changed

+24
-24
lines changed

14 files changed

+24
-24
lines changed

Action.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ typedef struct State_ {
3636
Machine* host;
3737
struct MainPanel_* mainPanel;
3838
Header* header;
39+
const char* failedUpdate; /* function bar diagnostic or NULL if no error */
3940
bool pauseUpdate;
40-
bool validUpdate;
4141
bool hideSelection;
4242
bool hideMeters;
4343
} State;

CommandLine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ int CommandLine_run(int argc, char** argv) {
377377
.host = host,
378378
.mainPanel = panel,
379379
.header = header,
380+
.failedUpdate = NULL,
380381
.pauseUpdate = false,
381-
.validUpdate = true,
382382
.hideSelection = false,
383383
.hideMeters = false,
384384
};

MainPanel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ static void MainPanel_drawFunctionBar(Panel* super, bool hideFunctionBar) {
194194
IncSet_drawBar(this->inc, CRT_colors[FUNCTION_BAR]);
195195
if (this->state->pauseUpdate) {
196196
FunctionBar_append("PAUSED", CRT_colors[PAUSED]);
197-
} else if (!this->state->validUpdate) {
198-
FunctionBar_append("FAILED", CRT_colors[FAILED_READ]);
197+
} else if (this->state->failedUpdate) {
198+
FunctionBar_append(this->state->failedUpdate, CRT_colors[FAILED_READ]);
199199
}
200200
}
201201

ScreenManager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
147147
Machine_scan(host);
148148
if (!this->state->pauseUpdate)
149149
Machine_scanTables(host);
150-
this->state->validUpdate = Platform_getValidState();
150+
this->state->failedUpdate = Platform_getFailedState();
151151

152152
// always update header, especially to avoid gaps in graph meters
153153
Header_updateData(this->header);

darwin/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static inline void Platform_getRelease(char** string) {
8888
*string = Generic_uname();
8989
}
9090

91-
static inline bool Platform_getValidState(void) {
92-
return true;
91+
static inline const char* Platform_getFailedState(void) {
92+
return NULL;
9393
}
9494

9595
#define PLATFORM_LONG_OPTIONS

dragonflybsd/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ static inline void Platform_getRelease(char** string) {
7777
*string = Generic_uname();
7878
}
7979

80-
static inline bool Platform_getValidState(void) {
81-
return true;
80+
static inline const char* Platform_getFailedState(void) {
81+
return NULL;
8282
}
8383

8484
#define PLATFORM_LONG_OPTIONS

freebsd/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ static inline void Platform_getRelease(char** string) {
7777
*string = Generic_uname();
7878
}
7979

80-
static inline bool Platform_getValidState(void) {
81-
return true;
80+
static inline const char* Platform_getFailedState(void) {
81+
return NULL;
8282
}
8383

8484
#define PLATFORM_LONG_OPTIONS

linux/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ static inline void Platform_getRelease(char** string) {
9898
*string = Generic_uname();
9999
}
100100

101-
static inline bool Platform_getValidState(void) {
102-
return true;
101+
static inline const char* Platform_getFailedState(void) {
102+
return NULL;
103103
}
104104

105105
#ifdef HAVE_LIBCAP

netbsd/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ static inline void Platform_getRelease(char** string) {
8383
*string = Generic_uname();
8484
}
8585

86-
static inline bool Platform_getValidState(void) {
87-
return true;
86+
static inline const char* Platform_getFailedState(void) {
87+
return NULL;
8888
}
8989

9090
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }

openbsd/Platform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static inline void Platform_getRelease(char** string) {
7575
*string = Generic_uname();
7676
}
7777

78-
static inline bool Platform_getValidState(void) {
79-
return true;
78+
static inline const char* Platform_getFailedState(void) {
79+
return NULL;
8080
}
8181

8282
#define PLATFORM_LONG_OPTIONS

0 commit comments

Comments
 (0)