mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-14 04:54:37 +03:00
Mark several non-modified pointer variables const
This commit is contained in:

committed by
BenBE

parent
1b2d48bc9a
commit
d72b0a682e
@ -107,7 +107,7 @@ static void LinuxProcessList_initTtyDrivers(LinuxProcessList* this) {
|
||||
while (*at != '\0') {
|
||||
at = strchr(at, ' '); // skip first token
|
||||
while (*at == ' ') at++; // skip spaces
|
||||
char* token = at; // mark beginning of path
|
||||
const char* token = at; // mark beginning of path
|
||||
at = strchr(at, ' '); // find end of path
|
||||
*at = '\0'; at++; // clear and skip
|
||||
ttyDrivers[numDrivers].path = xStrdup(token); // save
|
||||
@ -394,7 +394,7 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, openat_arg_t proc
|
||||
unsigned long long last_read = process->io_read_bytes;
|
||||
unsigned long long last_write = process->io_write_bytes;
|
||||
char* buf = buffer;
|
||||
char* line = NULL;
|
||||
const char* line;
|
||||
while ((line = strsep(&buf, "\n")) != NULL) {
|
||||
switch (line[0]) {
|
||||
case 'r':
|
||||
@ -486,7 +486,7 @@ static void LinuxProcessList_calcLibSize_helper(ATTR_UNUSED ht_key_t key, void*
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
LibraryData* v = (LibraryData *)value;
|
||||
const LibraryData* v = (const LibraryData *)value;
|
||||
uint64_t* d = (uint64_t *)data;
|
||||
if (!v->exec)
|
||||
return;
|
||||
@ -755,7 +755,7 @@ static void LinuxProcessList_readCGroupFile(LinuxProcess* process, openat_arg_t
|
||||
int left = PROC_LINE_LENGTH;
|
||||
while (!feof(file) && left > 0) {
|
||||
char buffer[PROC_LINE_LENGTH + 1];
|
||||
char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||
const char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||
if (!ok)
|
||||
break;
|
||||
|
||||
@ -859,7 +859,7 @@ static void LinuxProcessList_readSecattrData(LinuxProcess* process, openat_arg_t
|
||||
}
|
||||
|
||||
char buffer[PROC_LINE_LENGTH + 1];
|
||||
char* res = fgets(buffer, sizeof(buffer), file);
|
||||
const char* res = fgets(buffer, sizeof(buffer), file);
|
||||
fclose(file);
|
||||
if (!res) {
|
||||
free(process->secattr);
|
||||
@ -906,7 +906,7 @@ static void LinuxProcessList_readCwd(LinuxProcess* process, openat_arg_t procFd)
|
||||
static int handleNetlinkMsg(struct nl_msg* nlmsg, void* linuxProcess) {
|
||||
struct nlmsghdr* nlhdr;
|
||||
struct nlattr* nlattrs[TASKSTATS_TYPE_MAX + 1];
|
||||
struct nlattr* nlattr;
|
||||
const struct nlattr* nlattr;
|
||||
struct taskstats stats;
|
||||
int rem;
|
||||
LinuxProcess* lp = (LinuxProcess*) linuxProcess;
|
||||
@ -1663,7 +1663,7 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
||||
// Depending on your kernel version,
|
||||
// 5, 7, 8 or 9 of these fields will be set.
|
||||
// The rest will remain at zero.
|
||||
char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||
const char* ok = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||
if (!ok) {
|
||||
buffer[0] = '\0';
|
||||
}
|
||||
|
@ -131,13 +131,13 @@ void Platform_done(void) {
|
||||
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
||||
Panel* panel = st->panel;
|
||||
|
||||
LinuxProcess* p = (LinuxProcess*) Panel_getSelected(panel);
|
||||
const LinuxProcess* p = (const LinuxProcess*) Panel_getSelected(panel);
|
||||
if (!p)
|
||||
return HTOP_OK;
|
||||
|
||||
IOPriority ioprio1 = p->ioPriority;
|
||||
Panel* ioprioPanel = IOPriorityPanel_new(ioprio1);
|
||||
void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
||||
const void* set = Action_pickFromVector(st, ioprioPanel, 21, true);
|
||||
if (set) {
|
||||
IOPriority ioprio2 = IOPriorityPanel_getIOPriority(ioprioPanel);
|
||||
bool ok = MainPanel_foreachProcess((MainPanel*)panel, LinuxProcess_setIOPriority, (Arg) { .i = ioprio2 }, NULL);
|
||||
@ -366,7 +366,7 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||
*/
|
||||
char* Platform_getInodeFilename(pid_t pid, ino_t inode) {
|
||||
struct stat sb;
|
||||
struct dirent *de;
|
||||
const struct dirent *de;
|
||||
DIR *dirp;
|
||||
ssize_t len;
|
||||
int fd;
|
||||
@ -596,11 +596,11 @@ static unsigned long int parseBatInfo(const char* fileName, const unsigned short
|
||||
memset(batteries, 0, MAX_BATTERIES * sizeof(char*));
|
||||
|
||||
while (nBatteries < MAX_BATTERIES) {
|
||||
struct dirent* dirEntry = readdir(batteryDir);
|
||||
const struct dirent* dirEntry = readdir(batteryDir);
|
||||
if (!dirEntry)
|
||||
break;
|
||||
|
||||
char* entryName = dirEntry->d_name;
|
||||
const char* entryName = dirEntry->d_name;
|
||||
if (!String_startsWith(entryName, "BAT"))
|
||||
continue;
|
||||
|
||||
@ -653,7 +653,7 @@ static ACPresence procAcpiCheck(void) {
|
||||
return AC_ERROR;
|
||||
|
||||
for (;;) {
|
||||
struct dirent* dirEntry = readdir(dir);
|
||||
const struct dirent* dirEntry = readdir(dir);
|
||||
if (!dirEntry)
|
||||
break;
|
||||
|
||||
@ -728,7 +728,7 @@ static void Platform_Battery_getSysData(double* percent, ACPresence* isOnAC) {
|
||||
unsigned long int totalRemain = 0;
|
||||
|
||||
for (;;) {
|
||||
struct dirent* dirEntry = readdir(dir);
|
||||
const struct dirent* dirEntry = readdir(dir);
|
||||
if (!dirEntry)
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user