Do not drop qualifier in cast

ListItem.c:73:33: warning: cast from 'const void *' to 'struct ListItem_ *' drops const qualifier [-Wcast-qual]
   ListItem* obj1 = (ListItem*) cast1;
                                ^
ListItem.c:74:33: warning: cast from 'const void *' to 'struct ListItem_ *' drops const qualifier [-Wcast-qual]
   ListItem* obj2 = (ListItem*) cast2;
                                ^

Process.c:434:28: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
   Process* p1 = (Process*)v1;
                           ^
Process.c:435:28: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
   Process* p2 = (Process*)v2;
                           ^
Process.c:441:36: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
   Settings *settings = ((Process*)v1)->settings;
                                   ^
Process.c:443:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
      p1 = (Process*)v1;
                     ^
Process.c:444:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
      p2 = (Process*)v2;
                     ^
Process.c:446:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
      p2 = (Process*)v1;
                     ^
Process.c:447:22: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
      p1 = (Process*)v2;
                     ^

AffinityPanel.c:37:16: warning: cast from 'const char *' to 'void *' drops const qualifier [-Wcast-qual]
   free((void*)this->text);
               ^
AffinityPanel.c:39:19: warning: cast from 'const char *' to 'void *' drops const qualifier [-Wcast-qual]
      free((void*)this->indent);
                  ^

linux/LinuxProcess.c:294:36: warning: cast from 'const void *' to 'struct Process_ *' drops const qualifier [-Wcast-qual]
   Settings *settings = ((Process*)v1)->settings;
                                   ^
linux/LinuxProcess.c:296:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual]
      p1 = (LinuxProcess*)v1;
                          ^
linux/LinuxProcess.c:297:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual]
      p2 = (LinuxProcess*)v2;
                          ^
linux/LinuxProcess.c:299:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual]
      p2 = (LinuxProcess*)v1;
                          ^
linux/LinuxProcess.c:300:27: warning: cast from 'const void *' to 'struct LinuxProcess_ *' drops const qualifier [-Wcast-qual]
      p1 = (LinuxProcess*)v2;
                          ^

linux/LinuxProcessList.c:62:32: warning: cast from 'const void *' to 'struct TtyDriver_ *' drops const qualifier [-Wcast-qual]
   TtyDriver* a = (TtyDriver*) va;
                               ^
linux/LinuxProcessList.c:63:32: warning: cast from 'const void *' to 'struct TtyDriver_ *' drops const qualifier [-Wcast-qual]
   TtyDriver* b = (TtyDriver*) vb;
                               ^

linux/Battery.c:130:21: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
      free((char *) isOnline);
                    ^
linux/Battery.c:197:26: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
      xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
                         ^
linux/Battery.c:209:29: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
         xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
                            ^
linux/Battery.c:262:29: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
         xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
                            ^
This commit is contained in:
Christian Göttsche 2020-09-23 14:15:51 +02:00 committed by cgzones
parent 6a03cd237a
commit 18b1e9fba9
11 changed files with 37 additions and 38 deletions

View File

@ -73,9 +73,9 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
// ----------------------------------------
static void Action_runSetup(Settings* settings, const Header* header, ProcessList* pl) {
static void Action_runSetup(Settings* settings, Header* header, ProcessList* pl) {
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, true);
CategoriesPanel* panelCategories = CategoriesPanel_new(scr, settings, (Header*) header, pl);
CategoriesPanel* panelCategories = CategoriesPanel_new(scr, settings, header, pl);
ScreenManager_add(scr, (Panel*) panelCategories, 16);
CategoriesPanel_makeMetersPage(panelCategories);
Panel* panelFocus;

View File

@ -19,8 +19,8 @@ in the source distribution for its full text.
typedef struct MaskItem_ {
Object super;
const char* text;
const char* indent; /* used also as an condition whether this is a tree node */
char* text;
char* indent; /* used also as an condition whether this is a tree node */
int value; /* tri-state: 0 - off, 1 - some set, 2 - all set */
int sub_tree; /* tri-state: 0 - no sub-tree, 1 - open sub-tree, 2 - closed sub-tree */
Vector *children;
@ -34,9 +34,8 @@ typedef struct MaskItem_ {
static void MaskItem_delete(Object* cast) {
MaskItem* this = (MaskItem*) cast;
free((void*)this->text);
if (this->indent)
free((void*)this->indent);
free(this->text);
free(this->indent);
Vector_delete(this->children);
#ifdef HAVE_LIBHWLOC
if (this->ownCpuset)

View File

@ -43,9 +43,9 @@ static HandlerResult DisplayOptionsPanel_eventHandler(Panel* super, int ch) {
if (result == HANDLED) {
this->settings->changed = true;
const Header* header = this->scr->header;
Header_calculateHeight((Header*) header);
Header_reinit((Header*) header);
Header* header = this->scr->header;
Header_calculateHeight(header);
Header_reinit(header);
Header_draw(header);
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
}

View File

@ -70,7 +70,7 @@ const char* ListItem_getRef(ListItem* this) {
}
long ListItem_compare(const void* cast1, const void* cast2) {
ListItem* obj1 = (ListItem*) cast1;
ListItem* obj2 = (ListItem*) cast2;
const ListItem* obj1 = (const ListItem*) cast1;
const ListItem* obj2 = (const ListItem*) cast2;
return strcmp(obj1->value, obj2->value);
}

View File

@ -177,7 +177,7 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
}
}
if (result == HANDLED || sideMove) {
Header* header = (Header*) this->scr->header;
Header* header = this->scr->header;
this->settings->changed = true;
Header_calculateHeight(header);
Header_draw(header);

View File

@ -431,20 +431,20 @@ bool Process_sendSignal(Process* this, Arg sgn) {
}
long Process_pidCompare(const void* v1, const void* v2) {
Process* p1 = (Process*)v1;
Process* p2 = (Process*)v2;
const Process* p1 = (const Process*)v1;
const Process* p2 = (const Process*)v2;
return (p1->pid - p2->pid);
}
long Process_compare(const void* v1, const void* v2) {
Process *p1, *p2;
Settings *settings = ((Process*)v1)->settings;
const Process *p1, *p2;
const Settings *settings = ((const Process*)v1)->settings;
if (settings->direction == 1) {
p1 = (Process*)v1;
p2 = (Process*)v2;
p1 = (const Process*)v1;
p2 = (const Process*)v2;
} else {
p2 = (Process*)v1;
p1 = (Process*)v2;
p2 = (const Process*)v1;
p1 = (const Process*)v2;
}
switch (settings->sortKey) {
case PERCENT_CPU:

View File

@ -17,7 +17,7 @@ in the source distribution for its full text.
#include <stdbool.h>
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner) {
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, Header* header, const Settings* settings, bool owner) {
ScreenManager* this;
this = xMalloc(sizeof(ScreenManager));
this->x1 = x1;

View File

@ -25,13 +25,13 @@ typedef struct ScreenManager_ {
Orientation orientation;
Vector* panels;
int panelCount;
const Header* header;
Header* header;
const Settings* settings;
bool owner;
bool allowFocusChange;
} ScreenManager;
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner);
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, Header* header, const Settings* settings, bool owner);
void ScreenManager_delete(ScreenManager* this);

View File

@ -120,7 +120,7 @@ static ACPresence procAcpiCheck(void) {
fclose(file);
if (!line) continue;
const char *isOnline = String_getToken(line, 2);
char *isOnline = String_getToken(line, 2);
free(line);
if (strcmp(isOnline, "on-line") == 0) {
@ -128,7 +128,7 @@ static ACPresence procAcpiCheck(void) {
} else {
isOn = AC_ABSENT;
}
free((char *) isOnline);
free(isOnline);
if (isOn == AC_PRESENT) {
break;
}
@ -193,9 +193,9 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
if (!dirEntry)
break;
char* entryName = (char *) dirEntry->d_name;
const char filePath[256];
char filePath[256];
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
xSnprintf(filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
int fd1 = open(filePath, O_RDONLY);
if (fd1 == -1)
continue;
@ -207,7 +207,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
continue;
if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
xSnprintf(filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
int fd2 = open(filePath, O_RDONLY);
if (fd2 == -1) {
closedir(dir);
@ -260,7 +260,7 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
continue;
}
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
xSnprintf(filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
int fd3 = open(filePath, O_RDONLY);
if (fd3 == -1) {
closedir(dir);

View File

@ -297,14 +297,14 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
}
long LinuxProcess_compare(const void* v1, const void* v2) {
LinuxProcess *p1, *p2;
Settings *settings = ((Process*)v1)->settings;
const LinuxProcess *p1, *p2;
const Settings *settings = ((const Process*)v1)->settings;
if (settings->direction == 1) {
p1 = (LinuxProcess*)v1;
p2 = (LinuxProcess*)v2;
p1 = (const LinuxProcess*)v1;
p2 = (const LinuxProcess*)v2;
} else {
p2 = (LinuxProcess*)v1;
p1 = (LinuxProcess*)v2;
p2 = (const LinuxProcess*)v1;
p1 = (const LinuxProcess*)v2;
}
long long diff;
switch ((int)settings->sortKey) {

View File

@ -59,8 +59,8 @@ static ssize_t xread(int fd, void *buf, size_t count) {
}
static int sortTtyDrivers(const void* va, const void* vb) {
TtyDriver* a = (TtyDriver*) va;
TtyDriver* b = (TtyDriver*) vb;
const TtyDriver* a = (const TtyDriver*) va;
const TtyDriver* b = (const TtyDriver*) vb;
return (a->major == b->major) ? ((int)a->minorFrom - (int)b->minorFrom) : ((int)a->major - (int)b->major);
}