mirror of https://github.com/xzeldon/htop.git
Avoid shadowing warnings
This commit is contained in:
parent
b4ceb83d76
commit
4e2b9f0965
14
Action.c
14
Action.c
|
@ -316,17 +316,17 @@ static Htop_Reaction actionSetAffinity(State* st) {
|
||||||
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
if (!p) return HTOP_OK;
|
if (!p) return HTOP_OK;
|
||||||
Affinity* affinity = Affinity_get(p, st->pl);
|
Affinity* affinity1 = Affinity_get(p, st->pl);
|
||||||
if (!affinity) return HTOP_OK;
|
if (!affinity1) return HTOP_OK;
|
||||||
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity);
|
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity1);
|
||||||
Affinity_delete(affinity);
|
Affinity_delete(affinity1);
|
||||||
|
|
||||||
void* set = Action_pickFromVector(st, affinityPanel, 15, true);
|
void* set = Action_pickFromVector(st, affinityPanel, 15, true);
|
||||||
if (set) {
|
if (set) {
|
||||||
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity2 }, NULL);
|
||||||
if (!ok) beep();
|
if (!ok) beep();
|
||||||
Affinity_delete(affinity);
|
Affinity_delete(affinity2);
|
||||||
}
|
}
|
||||||
Panel_delete((Object*)affinityPanel);
|
Panel_delete((Object*)affinityPanel);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -64,7 +64,7 @@ static unsigned long int parseBatInfo(const char *fileName, const unsigned short
|
||||||
}
|
}
|
||||||
|
|
||||||
char* line = NULL;
|
char* line = NULL;
|
||||||
for (unsigned short int i = 0; i < lineNum; i++) {
|
for (unsigned short int j = 0; j < lineNum; j++) {
|
||||||
free(line);
|
free(line);
|
||||||
line = String_readLine(file);
|
line = String_readLine(file);
|
||||||
if (!line) break;
|
if (!line) break;
|
||||||
|
@ -194,26 +194,26 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
||||||
const char filePath[50];
|
const char filePath[50];
|
||||||
|
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/type", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd1 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd1 == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char type[8];
|
char type[8];
|
||||||
ssize_t typelen = xread(fd, type, 7);
|
ssize_t typelen = xread(fd1, type, 7);
|
||||||
close(fd);
|
close(fd1);
|
||||||
if (typelen < 1)
|
if (typelen < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
|
if (type[0] == 'B' && type[1] == 'a' && type[2] == 't') {
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/uevent", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd2 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd2 == -1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
ssize_t buflen = xread(fd, buffer, 1023);
|
ssize_t buflen = xread(fd2, buffer, 1023);
|
||||||
close(fd);
|
close(fd2);
|
||||||
if (buflen < 1) {
|
if (buflen < 1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
|
@ -259,18 +259,18 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) {
|
||||||
}
|
}
|
||||||
|
|
||||||
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
|
xSnprintf((char *) filePath, sizeof filePath, SYS_POWERSUPPLY_DIR "/%s/online", entryName);
|
||||||
int fd = open(filePath, O_RDONLY);
|
int fd3 = open(filePath, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd3 == -1) {
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char buffer[2] = "";
|
char buffer[2] = "";
|
||||||
for(;;) {
|
for(;;) {
|
||||||
ssize_t res = read(fd, buffer, 1);
|
ssize_t res = read(fd3, buffer, 1);
|
||||||
if (res == -1 && errno == EINTR) continue;
|
if (res == -1 && errno == EINTR) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd3);
|
||||||
if (buffer[0] == '0') {
|
if (buffer[0] == '0') {
|
||||||
*isOnAC = AC_ABSENT;
|
*isOnAC = AC_ABSENT;
|
||||||
} else if (buffer[0] == '1') {
|
} else if (buffer[0] == '1') {
|
||||||
|
|
|
@ -1227,9 +1227,9 @@ static inline double LinuxProcessList_scanCPUFrequency(LinuxProcessList* this) {
|
||||||
(sscanf(buffer, "processor: %d", &cpuid) == 1)
|
(sscanf(buffer, "processor: %d", &cpuid) == 1)
|
||||||
) {
|
) {
|
||||||
if (cpuid < 0 || cpuid > (cpus - 1)) {
|
if (cpuid < 0 || cpuid > (cpus - 1)) {
|
||||||
char buffer[64];
|
char tmpbuffer[64];
|
||||||
xSnprintf(buffer, sizeof(buffer), PROCCPUINFOFILE " contains out-of-range CPU number %d", cpuid);
|
xSnprintf(tmpbuffer, sizeof(tmpbuffer), PROCCPUINFOFILE " contains out-of-range CPU number %d", cpuid);
|
||||||
CRT_fatalError(buffer);
|
CRT_fatalError(tmpbuffer);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
(sscanf(buffer, "cpu MHz : %lf", &frequency) == 1) ||
|
(sscanf(buffer, "cpu MHz : %lf", &frequency) == 1) ||
|
||||||
|
|
|
@ -94,12 +94,12 @@ static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
||||||
|
|
||||||
LinuxProcess* p = (LinuxProcess*) Panel_getSelected(panel);
|
LinuxProcess* p = (LinuxProcess*) Panel_getSelected(panel);
|
||||||
if (!p) return HTOP_OK;
|
if (!p) return HTOP_OK;
|
||||||
IOPriority ioprio = p->ioPriority;
|
IOPriority ioprio1 = p->ioPriority;
|
||||||
Panel* ioprioPanel = IOPriorityPanel_new(ioprio);
|
Panel* ioprioPanel = IOPriorityPanel_new(ioprio1);
|
||||||
void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
||||||
if (set) {
|
if (set) {
|
||||||
IOPriority ioprio = IOPriorityPanel_getIOPriority(ioprioPanel);
|
IOPriority ioprio2 = IOPriorityPanel_getIOPriority(ioprioPanel);
|
||||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (Arg){ .i = ioprio }, NULL);
|
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) LinuxProcess_setIOPriority, (Arg){ .i = ioprio2 }, NULL);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue