mirror of https://github.com/xzeldon/htop.git
Enable -Wcast-qual compiler warning
This commit is contained in:
parent
ad3acfc847
commit
db472075a4
|
@ -40,18 +40,18 @@ FunctionBar* FunctionBar_new(const char* const* functions, const char* const* ke
|
|||
}
|
||||
if (keys && events) {
|
||||
this->staticData = false;
|
||||
this->keys = xCalloc(15, sizeof(char*));
|
||||
this->keys.keys = xCalloc(15, sizeof(char*));
|
||||
this->events = xCalloc(15, sizeof(int));
|
||||
int i = 0;
|
||||
while (i < 15 && functions[i]) {
|
||||
this->keys[i] = xStrdup(keys[i]);
|
||||
this->keys.keys[i] = xStrdup(keys[i]);
|
||||
this->events[i] = events[i];
|
||||
i++;
|
||||
}
|
||||
this->size = i;
|
||||
} else {
|
||||
this->staticData = true;
|
||||
this->keys = (char**) FunctionBar_FKeys;
|
||||
this->keys.constKeys = FunctionBar_FKeys;
|
||||
this->events = FunctionBar_FEvents;
|
||||
this->size = 10;
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ void FunctionBar_delete(FunctionBar* this) {
|
|||
free(this->functions);
|
||||
if (!this->staticData) {
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
free(this->keys[i]);
|
||||
free(this->keys.keys[i]);
|
||||
}
|
||||
free(this->keys);
|
||||
free(this->keys.keys);
|
||||
free(this->events);
|
||||
}
|
||||
free(this);
|
||||
|
@ -93,8 +93,8 @@ void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr) {
|
|||
int x = 0;
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
attrset(CRT_colors[FUNCTION_KEY]);
|
||||
mvaddstr(LINES-1, x, this->keys[i]);
|
||||
x += strlen(this->keys[i]);
|
||||
mvaddstr(LINES-1, x, this->keys.constKeys[i]);
|
||||
x += strlen(this->keys.constKeys[i]);
|
||||
attrset(CRT_colors[FUNCTION_BAR]);
|
||||
mvaddstr(LINES-1, x, this->functions[i]);
|
||||
x += strlen(this->functions[i]);
|
||||
|
@ -113,7 +113,7 @@ void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr) {
|
|||
int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos) {
|
||||
int x = 0;
|
||||
for (int i = 0; i < this->size; i++) {
|
||||
x += strlen(this->keys[i]);
|
||||
x += strlen(this->keys.constKeys[i]);
|
||||
x += strlen(this->functions[i]);
|
||||
if (pos < x) {
|
||||
return this->events[i];
|
||||
|
|
|
@ -12,7 +12,10 @@ in the source distribution for its full text.
|
|||
typedef struct FunctionBar_ {
|
||||
int size;
|
||||
char** functions;
|
||||
union {
|
||||
char** keys;
|
||||
const char* const* constKeys;
|
||||
} keys;
|
||||
int* events;
|
||||
bool staticData;
|
||||
} FunctionBar;
|
||||
|
|
16
Macros.h
16
Macros.h
|
@ -33,4 +33,20 @@
|
|||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
// ignore casts discarding const specifier, e.g.
|
||||
// const char [] -> char * / void *
|
||||
// const char *[2]' -> char *const *
|
||||
#ifdef __clang__
|
||||
#define IGNORE_WCASTQUAL_BEGIN _Pragma("clang diagnostic push") \
|
||||
_Pragma("clang diagnostic ignored \"-Wcast-qual\"")
|
||||
#define IGNORE_WCASTQUAL_END _Pragma("clang diagnostic pop")
|
||||
#elif defined(__GNUC__)
|
||||
#define IGNORE_WCASTQUAL_BEGIN _Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
|
||||
#define IGNORE_WCASTQUAL_END _Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
#define IGNORE_WCASTQUAL_BEGIN
|
||||
#define IGNORE_WCASTQUAL_END
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -296,6 +296,7 @@ fi
|
|||
AM_CFLAGS="\
|
||||
-Wall\
|
||||
-Wcast-align\
|
||||
-Wcast-qual\
|
||||
-Wextra\
|
||||
-Wfloat-equal\
|
||||
-Wmissing-format-attribute\
|
||||
|
|
|
@ -108,14 +108,14 @@ void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField
|
|||
}
|
||||
|
||||
long DragonFlyBSDProcess_compare(const void* v1, const void* v2) {
|
||||
DragonFlyBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
const DragonFlyBSDProcess *p1, *p2;
|
||||
const Settings *settings = ((const Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
p1 = (DragonFlyBSDProcess*)v1;
|
||||
p2 = (DragonFlyBSDProcess*)v2;
|
||||
p1 = (const DragonFlyBSDProcess*)v1;
|
||||
p2 = (const DragonFlyBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (DragonFlyBSDProcess*)v1;
|
||||
p1 = (DragonFlyBSDProcess*)v2;
|
||||
p2 = (const DragonFlyBSDProcess*)v1;
|
||||
p1 = (const DragonFlyBSDProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
// add Platform-specific fields here
|
||||
|
|
|
@ -107,14 +107,14 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
|||
}
|
||||
|
||||
long FreeBSDProcess_compare(const void* v1, const void* v2) {
|
||||
FreeBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
const FreeBSDProcess *p1, *p2;
|
||||
const Settings *settings = ((const Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
p1 = (FreeBSDProcess*)v1;
|
||||
p2 = (FreeBSDProcess*)v2;
|
||||
p1 = (const FreeBSDProcess*)v1;
|
||||
p2 = (const FreeBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (FreeBSDProcess*)v1;
|
||||
p1 = (FreeBSDProcess*)v2;
|
||||
p2 = (const FreeBSDProcess*)v1;
|
||||
p1 = (const FreeBSDProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
// add FreeBSD-specific fields here
|
||||
|
|
|
@ -5,6 +5,7 @@ Released under the GNU GPLv2, see the COPYING file
|
|||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "Macros.h"
|
||||
#include "ProcessList.h"
|
||||
#include "FreeBSDProcessList.h"
|
||||
#include "FreeBSDProcess.h"
|
||||
|
@ -338,6 +339,7 @@ char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc) {
|
|||
|
||||
if (kproc->ki_jid != 0 ){
|
||||
memset(jnamebuf, 0, sizeof(jnamebuf));
|
||||
IGNORE_WCASTQUAL_BEGIN
|
||||
*(const void **)&jiov[0].iov_base = "jid";
|
||||
jiov[0].iov_len = sizeof("jid");
|
||||
jiov[1].iov_base = &kproc->ki_jid;
|
||||
|
@ -350,6 +352,7 @@ char* FreeBSDProcessList_readJailName(struct kinfo_proc* kproc) {
|
|||
jiov[4].iov_len = sizeof("errmsg");
|
||||
jiov[5].iov_base = jail_errmsg;
|
||||
jiov[5].iov_len = JAIL_ERRMSGLEN;
|
||||
IGNORE_WCASTQUAL_END
|
||||
jail_errmsg[0] = 0;
|
||||
jid = jail_get(jiov, 6, 0);
|
||||
if (jid < 0) {
|
||||
|
|
|
@ -193,14 +193,14 @@ void OpenBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
|||
}
|
||||
|
||||
long OpenBSDProcess_compare(const void* v1, const void* v2) {
|
||||
OpenBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
const OpenBSDProcess *p1, *p2;
|
||||
const Settings *settings = ((const Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
p1 = (OpenBSDProcess*)v1;
|
||||
p2 = (OpenBSDProcess*)v2;
|
||||
p1 = (const OpenBSDProcess*)v1;
|
||||
p2 = (const OpenBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (OpenBSDProcess*)v1;
|
||||
p1 = (OpenBSDProcess*)v2;
|
||||
p2 = (const OpenBSDProcess*)v1;
|
||||
p1 = (const OpenBSDProcess*)v2;
|
||||
}
|
||||
switch (settings->sortKey) {
|
||||
// add OpenBSD-specific fields here
|
||||
|
|
|
@ -117,14 +117,14 @@ void SolarisProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
|||
}
|
||||
|
||||
long SolarisProcess_compare(const void* v1, const void* v2) {
|
||||
SolarisProcess *p1, *p2;
|
||||
Settings* settings = ((Process*)v1)->settings;
|
||||
const SolarisProcess *p1, *p2;
|
||||
const Settings* settings = ((const Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
p1 = (SolarisProcess*)v1;
|
||||
p2 = (SolarisProcess*)v2;
|
||||
p1 = (const SolarisProcess*)v1;
|
||||
p2 = (const SolarisProcess*)v2;
|
||||
} else {
|
||||
p2 = (SolarisProcess*)v1;
|
||||
p1 = (SolarisProcess*)v2;
|
||||
p2 = (const SolarisProcess*)v1;
|
||||
p1 = (const SolarisProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
case ZONEID:
|
||||
|
|
Loading…
Reference in New Issue