From 843949131aa75312086bea6a50408e09d82f5209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 28 Sep 2020 12:17:52 +0200 Subject: [PATCH] Drop redundant casts to the same type --- Action.c | 2 +- AvailableMetersPanel.c | 2 +- InfoScreen.c | 2 +- Meter.c | 2 +- StringUtils.c | 2 +- Vector.c | 2 +- linux/Battery.c | 8 ++++---- linux/LinuxProcess.c | 2 +- linux/LinuxProcessList.c | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Action.c b/Action.c index 62266084..233f1324 100644 --- a/Action.c +++ b/Action.c @@ -305,7 +305,7 @@ static Htop_Reaction actionSetAffinity(State* st) { } static Htop_Reaction actionKill(State* st) { - Panel* signalsPanel = (Panel*) SignalsPanel_new(); + Panel* signalsPanel = SignalsPanel_new(); ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15, true); if (sgn) { if (sgn->key != 0) { diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index 0533cfbf..3538cd13 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -25,7 +25,7 @@ static void AvailableMetersPanel_delete(Object* object) { } static inline void AvailableMetersPanel_addMeter(Header* header, Panel* panel, MeterClass* type, int param, int column) { - Meter* meter = (Meter*) Header_addMeterByClass(header, type, param, column); + Meter* meter = Header_addMeterByClass(header, type, param, column); Panel_add(panel, (Object*) Meter_toListItem(meter, false)); Panel_setSelected(panel, Panel_size(panel) - 1); MetersPanel_setMoving((MetersPanel*)panel, true); diff --git a/InfoScreen.c b/InfoScreen.c index 8a6a3bee..b8859af0 100644 --- a/InfoScreen.c +++ b/InfoScreen.c @@ -57,7 +57,7 @@ void InfoScreen_addLine(InfoScreen* this, const char* line) { Vector_add(this->lines, (Object*) ListItem_new(line, 0)); const char* incFilter = IncSet_filter(this->inc); if (!incFilter || String_contains_i(line, incFilter)) - Panel_add(this->display, (Object*)Vector_get(this->lines, Vector_size(this->lines)-1)); + Panel_add(this->display, Vector_get(this->lines, Vector_size(this->lines)-1)); } void InfoScreen_appendLine(InfoScreen* this, const char* line) { diff --git a/Meter.c b/Meter.c index 5b4ae006..d144b5b8 100644 --- a/Meter.c +++ b/Meter.c @@ -282,7 +282,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { struct timeval now; gettimeofday(&now, NULL); if (!timercmp(&now, &(data->time), <)) { - struct timeval delay = { .tv_sec = (int)(CRT_delay/10), .tv_usec = (CRT_delay-((int)(CRT_delay/10)*10)) * 100000 }; + struct timeval delay = { .tv_sec = CRT_delay/10, .tv_usec = (CRT_delay-((CRT_delay/10)*10)) * 100000 }; timeradd(&now, &delay, &(data->time)); for (int i = 0; i < nValues - 1; i++) diff --git a/StringUtils.c b/StringUtils.c index e2386e3c..1e4c03b3 100644 --- a/StringUtils.c +++ b/StringUtils.c @@ -112,7 +112,7 @@ char* String_getToken(const char* line, const unsigned short int numMatch) { } match[foundCount] = '\0'; - return((char*)xStrdup(match)); + return xStrdup(match); } char* String_readLine(FILE* fd) { diff --git a/Vector.c b/Vector.c index e51fd7b1..20578851 100644 --- a/Vector.c +++ b/Vector.c @@ -309,7 +309,7 @@ inline int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) { assert(compare); assert(Vector_isConsistent(this)); for (int i = 0; i < this->items; i++) { - Object* o = (Object*)this->array[i]; + Object* o = this->array[i]; assert(o); if (compare(search, o) == 0) return i; diff --git a/linux/Battery.c b/linux/Battery.c index a0a0e58e..614126e8 100644 --- a/linux/Battery.c +++ b/linux/Battery.c @@ -100,11 +100,11 @@ static ACPresence procAcpiCheck(void) { } for (;;) { - struct dirent* dirEntry = readdir((DIR *) dir); + struct dirent* dirEntry = readdir(dir); if (!dirEntry) break; - char* entryName = (char *) dirEntry->d_name; + const char* entryName = dirEntry->d_name; if (entryName[0] != 'A') continue; @@ -189,10 +189,10 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { unsigned long int totalRemain = 0; for (;;) { - struct dirent* dirEntry = readdir((DIR *) dir); + struct dirent* dirEntry = readdir(dir); if (!dirEntry) break; - char* entryName = (char *) dirEntry->d_name; + const char* entryName = dirEntry->d_name; char filePath[256]; xSnprintf(filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName); diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 41404de1..890c8a0f 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -290,7 +290,7 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field) xSnprintf(buffer, n, "%5lu ", lp->ctxt_diff); break; default: - Process_writeField((Process*)this, str, field); + Process_writeField(this, str, field); return; } RichString_append(str, attr, buffer); diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 76f2a423..e984735b 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -232,7 +232,7 @@ static inline unsigned long long LinuxProcess_adjustTime(unsigned long long t) { jiffy = sc_jiffy; } double jiffytime = 1.0 / jiffy; - return (unsigned long long) t * jiffytime * 100; + return t * jiffytime * 100; } static bool LinuxProcessList_readStatFile(Process *process, const char* dirname, const char* name, char* command, int* commLen) {