summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2017-07-26 11:24:51 -0300
committerGitHub <noreply@github.com>2017-07-26 11:24:51 -0300
commitef7817c17a35dd5f8d9eb9ee65539e52d2fdb410 (patch)
treec932359d63a4d2ec16da0b1b9b221d0e81008eb3
parent33fda932713de9db236d63098d88529f669fc49c (diff)
parentd5faf643742ae047e327d41910232791bc7bca41 (diff)
Merge pull request #656 from rsaxvc/master
more const usage
-rw-r--r--.gitignore1
-rw-r--r--Action.c4
-rw-r--r--AvailableColumnsPanel.c2
-rw-r--r--CategoriesPanel.c2
-rw-r--r--ColorsPanel.c4
-rw-r--r--ColumnsPanel.c2
-rw-r--r--DisplayOptionsPanel.c2
-rw-r--r--FunctionBar.c10
-rw-r--r--FunctionBar.h2
-rw-r--r--IncSet.c8
-rw-r--r--InfoScreen.c4
-rw-r--r--MainPanel.c2
-rw-r--r--Meter.c12
-rw-r--r--MetersPanel.c8
-rw-r--r--TraceScreen.c4
-rw-r--r--linux/IOPriorityPanel.c2
16 files changed, 35 insertions, 34 deletions
diff --git a/.gitignore b/.gitignore
index c1c1df41..56af3797 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ htop
# skip all backups
*.bak
*~
+.*.sw?
# skip coverage files
*.gcda
diff --git a/Action.c b/Action.c
index f5d7de43..391716a5 100644
--- a/Action.c
+++ b/Action.c
@@ -381,7 +381,7 @@ static Htop_Reaction actionRedraw() {
return HTOP_REFRESH | HTOP_REDRAW_BAR;
}
-static struct { const char* key; const char* info; } helpLeft[] = {
+static const struct { const char* key; const char* info; } helpLeft[] = {
{ .key = " Arrows: ", .info = "scroll process list" },
{ .key = " Digits: ", .info = "incremental PID search" },
{ .key = " F3 /: ", .info = "incremental name search" },
@@ -399,7 +399,7 @@ static struct { const char* key; const char* info; } helpLeft[] = {
{ .key = NULL, .info = NULL }
};
-static struct { const char* key; const char* info; } helpRight[] = {
+static const struct { const char* key; const char* info; } helpRight[] = {
{ .key = " Space: ", .info = "tag process" },
{ .key = " c: ", .info = "tag process and its children" },
{ .key = " U: ", .info = "untag all processes" },
diff --git a/AvailableColumnsPanel.c b/AvailableColumnsPanel.c
index 6865b8bc..503efabe 100644
--- a/AvailableColumnsPanel.c
+++ b/AvailableColumnsPanel.c
@@ -26,7 +26,7 @@ typedef struct AvailableColumnsPanel_ {
}*/
-static const char* AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL};
+static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL};
static void AvailableColumnsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
diff --git a/CategoriesPanel.c b/CategoriesPanel.c
index afc32305..437f1a7b 100644
--- a/CategoriesPanel.c
+++ b/CategoriesPanel.c
@@ -34,7 +34,7 @@ typedef struct CategoriesPanel_ {
}*/
-static const char* CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
+static const char* const CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
static void CategoriesPanel_delete(Object* object) {
Panel* super = (Panel*) object;
diff --git a/ColorsPanel.c b/ColorsPanel.c
index 96199c1b..627a516a 100644
--- a/ColorsPanel.c
+++ b/ColorsPanel.c
@@ -34,9 +34,9 @@ typedef struct ColorsPanel_ {
}*/
-static const char* ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
+static const char* const ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
-static const char* ColorSchemeNames[] = {
+static const char* const ColorSchemeNames[] = {
"Default",
"Monochromatic",
"Black on White",
diff --git a/ColumnsPanel.c b/ColumnsPanel.c
index 3ec9ee80..02d8be13 100644
--- a/ColumnsPanel.c
+++ b/ColumnsPanel.c
@@ -29,7 +29,7 @@ typedef struct ColumnsPanel_ {
}*/
-static const char* ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL};
+static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL};
static void ColumnsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c
index 0a32c447..0ff54e33 100644
--- a/DisplayOptionsPanel.c
+++ b/DisplayOptionsPanel.c
@@ -28,7 +28,7 @@ typedef struct DisplayOptionsPanel_ {
}*/
-static const char* DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
+static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
static void DisplayOptionsPanel_delete(Object* object) {
Panel* super = (Panel*) object;
diff --git a/FunctionBar.c b/FunctionBar.c
index 659f4108..4e4baaf3 100644
--- a/FunctionBar.c
+++ b/FunctionBar.c
@@ -28,21 +28,21 @@ typedef struct FunctionBar_ {
}*/
-static const char* FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL};
+static const char* const FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL};
-static const char* FunctionBar_FLabels[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", NULL};
+static const char* const FunctionBar_FLabels[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", NULL};
static int FunctionBar_FEvents[] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)};
-static const char* FunctionBar_EnterEscKeys[] = {"Enter", "Esc", NULL};
-static int FunctionBar_EnterEscEvents[] = {13, 27};
+static const char* const FunctionBar_EnterEscKeys[] = {"Enter", "Esc", NULL};
+static const int FunctionBar_EnterEscEvents[] = {13, 27};
FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc) {
const char* functions[] = {enter, esc, NULL};
return FunctionBar_new(functions, FunctionBar_EnterEscKeys, FunctionBar_EnterEscEvents);
}
-FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events) {
+FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events) {
FunctionBar* this = xCalloc(1, sizeof(FunctionBar));
this->functions = xCalloc(16, sizeof(char*));
if (!functions) {
diff --git a/FunctionBar.h b/FunctionBar.h
index 1975fa38..b60f6582 100644
--- a/FunctionBar.h
+++ b/FunctionBar.h
@@ -24,7 +24,7 @@ typedef struct FunctionBar_ {
FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc);
-FunctionBar* FunctionBar_new(const char** functions, const char** keys, int* events);
+FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events);
void FunctionBar_delete(FunctionBar* this);
diff --git a/IncSet.c b/IncSet.c
index c7f889cc..bb9f9544 100644
--- a/IncSet.c
+++ b/IncSet.c
@@ -52,8 +52,8 @@ static void IncMode_reset(IncMode* mode) {
mode->buffer[0] = 0;
}
-static const char* searchFunctions[] = {"Next ", "Cancel ", " Search: ", NULL};
-static const char* searchKeys[] = {"F3", "Esc", " "};
+static const char* const searchFunctions[] = {"Next ", "Cancel ", " Search: ", NULL};
+static const char* const searchKeys[] = {"F3", "Esc", " "};
static int searchEvents[] = {KEY_F(3), 27, ERR};
static inline void IncMode_initSearch(IncMode* search) {
@@ -62,8 +62,8 @@ static inline void IncMode_initSearch(IncMode* search) {
search->isFilter = false;
}
-static const char* filterFunctions[] = {"Done ", "Clear ", " Filter: ", NULL};
-static const char* filterKeys[] = {"Enter", "Esc", " "};
+static const char* const filterFunctions[] = {"Done ", "Clear ", " Filter: ", NULL};
+static const char* const filterKeys[] = {"Enter", "Esc", " "};
static int filterEvents[] = {13, 27, ERR};
static inline void IncMode_initFilter(IncMode* filter) {
diff --git a/InfoScreen.c b/InfoScreen.c
index e27494c7..dd5095c7 100644
--- a/InfoScreen.c
+++ b/InfoScreen.c
@@ -50,9 +50,9 @@ struct InfoScreen_ {
};
}*/
-static const char* InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL};
+static const char* const InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL};
-static const char* InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"};
+static const char* const InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"};
static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
diff --git a/MainPanel.c b/MainPanel.c
index a62555ee..b5a7e305 100644
--- a/MainPanel.c
+++ b/MainPanel.c
@@ -31,7 +31,7 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t);
}*/
-static const char* MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
+static const char* const MainFunctions[] = {"Help ", "Setup ", "Search", "Filter", "Tree ", "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) {
FunctionBar* bar = MainPanel_getFunctionBar(this);
diff --git a/Meter.c b/Meter.c
index dbfa7d7f..706196dd 100644
--- a/Meter.c
+++ b/Meter.c
@@ -336,7 +336,7 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4
-static const char* GraphMeterMode_dotsUtf8[] = {
+static const char* const GraphMeterMode_dotsUtf8[] = {
/*00*/" ", /*01*/"⢀", /*02*/"⢠", /*03*/"⢰", /*04*/ "⢸",
/*10*/"⡀", /*11*/"⣀", /*12*/"⣠", /*13*/"⣰", /*14*/ "⣸",
/*20*/"⡄", /*21*/"⣄", /*22*/"⣤", /*23*/"⣴", /*24*/ "⣼",
@@ -347,13 +347,13 @@ static const char* GraphMeterMode_dotsUtf8[] = {
#endif
#define PIXPERROW_ASCII 2
-static const char* GraphMeterMode_dotsAscii[] = {
+static const char* const GraphMeterMode_dotsAscii[] = {
/*00*/" ", /*01*/".", /*02*/":",
/*10*/".", /*11*/".", /*12*/":",
/*20*/":", /*21*/":", /*22*/":"
};
-static const char** GraphMeterMode_dots;
+static const char* const* GraphMeterMode_dots;
static int GraphMeterMode_pixPerRow;
static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
@@ -424,7 +424,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
/* ---------- LEDMeterMode ---------- */
-static const char* LEDMeterMode_digitsAscii[] = {
+static const char* const LEDMeterMode_digitsAscii[] = {
" __ "," "," __ "," __ "," "," __ "," __ "," __ "," __ "," __ ",
"| |"," |"," __|"," __|","|__|","|__ ","|__ "," |","|__|","|__|",
"|__|"," |","|__ "," __|"," |"," __|","|__|"," |","|__|"," __|"
@@ -432,7 +432,7 @@ static const char* LEDMeterMode_digitsAscii[] = {
#ifdef HAVE_LIBNCURSESW
-static const char* LEDMeterMode_digitsUtf8[] = {
+static const char* const LEDMeterMode_digitsUtf8[] = {
"┌──┐"," ┐ ","╶──┐","╶──┐","╷ ╷","┌──╴","┌──╴","╶──┐","┌──┐","┌──┐",
"│ │"," │ ","┌──┘"," ──┤","└──┤","└──┐","├──┐"," │","├──┤","└──┤",
"└──┘"," ╵ ","└──╴","╶──┘"," ╵","╶──┘","└──┘"," ╵","└──┘"," ──┘"
@@ -440,7 +440,7 @@ static const char* LEDMeterMode_digitsUtf8[] = {
#endif
-static const char** LEDMeterMode_digits;
+static const char* const* LEDMeterMode_digits;
static void LEDMeterMode_drawDigit(int x, int y, int n) {
for (int i = 0; i < 3; i++)
diff --git a/MetersPanel.c b/MetersPanel.c
index 22449f3d..47833d38 100644
--- a/MetersPanel.c
+++ b/MetersPanel.c
@@ -33,16 +33,16 @@ struct MetersPanel_ {
// Note: In code the meters are known to have bar/text/graph "Modes", but in UI
// we call them "Styles".
-static const char* MetersFunctions[] = {"Style ", "Move ", " ", "Delete", "Done ", NULL};
-static const char* MetersKeys[] = {"Space", "Enter", " ", "Del", "F10"};
+static const char* const MetersFunctions[] = {"Style ", "Move ", " ", "Delete", "Done ", NULL};
+static const char* const MetersKeys[] = {"Space", "Enter", " ", "Del", "F10"};
static int MetersEvents[] = {' ', 13, ERR, KEY_DC, KEY_F(10)};
// We avoid UTF-8 arrows ← → here as they might display full-width on Chinese
// terminals, breaking our aligning.
// In <http://unicode.org/reports/tr11/>, arrows (U+2019..U+2199) are
// considered "Ambiguous characters".
-static const char* MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Down ", "Left ", "Right ", " ", "Delete", "Done ", NULL};
-static const char* MetersMovingKeys[] = {"Space", "Enter", "Up", "Dn", "<-", "->", " ", "Del", "F10"};
+static const char* const MetersMovingFunctions[] = {"Style ", "Lock ", "Up ", "Down ", "Left ", "Right ", " ", "Delete", "Done ", NULL};
+static const char* const MetersMovingKeys[] = {"Space", "Enter", "Up", "Dn", "<-", "->", " ", "Del", "F10"};
static int MetersMovingEvents[] = {' ', 13, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, ERR, KEY_DC, KEY_F(10)};
static FunctionBar* Meters_movingBar = NULL;
diff --git a/TraceScreen.c b/TraceScreen.c
index 6bb2e041..2c9e3684 100644
--- a/TraceScreen.c
+++ b/TraceScreen.c
@@ -43,9 +43,9 @@ typedef struct TraceScreen_ {
}*/
-static const char* TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
+static const char* const TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};
-static const char* TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
+static const char* const TraceScreenKeys[] = {"F3", "F4", "F8", "F9", "Esc"};
static int TraceScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(8), KEY_F(9), 27};
diff --git a/linux/IOPriorityPanel.c b/linux/IOPriorityPanel.c
index 9e12c755..3085fb02 100644
--- a/linux/IOPriorityPanel.c
+++ b/linux/IOPriorityPanel.c
@@ -19,7 +19,7 @@ Panel* IOPriorityPanel_new(IOPriority currPrio) {
Panel_setHeader(this, "IO Priority:");
Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None));
if (currPrio == IOPriority_None) Panel_setSelected(this, 0);
- struct { int klass; const char* name; } classes[] = {
+ static const struct { int klass; const char* name; } classes[] = {
{ .klass = IOPRIO_CLASS_RT, .name = "Realtime" },
{ .klass = IOPRIO_CLASS_BE, .name = "Best-effort" },
{ .klass = 0, .name = NULL }

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