summaryrefslogtreecommitdiffstats
path: root/linux/LinuxProcessTable.c
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2024-04-17 16:45:46 +0800
committerBenBE <BenBE@geshi.org>2024-04-17 11:54:00 +0200
commita46b3f0a98c801b94df08598be0127e4d7db2aca (patch)
tree9a0e51e445dbb19685897d225ff847016f9c6761 /linux/LinuxProcessTable.c
parent6f0adfab242f40e0a0e82445abac4e574c7a97e8 (diff)
Use 'fp' name for local 'FILE*' variables.
It is inappropriate to use the 'fd' name for 'FILE*' variables. POSIX file descriptiors are of type 'int' and are distinguished from ISO C stream pointers (type 'FILE*'). Rename these variables to 'fp', which is a preferred naming in POSIX. (Note that ISO C preferred the 'stream' name for the variables.) No code changes.
Diffstat (limited to 'linux/LinuxProcessTable.c')
-rw-r--r--linux/LinuxProcessTable.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c
index f8adf9ad..1e7c041d 100644
--- a/linux/LinuxProcessTable.c
+++ b/linux/LinuxProcessTable.c
@@ -71,11 +71,11 @@ static FILE* fopenat(openat_arg_t openatArg, const char* pathname, const char* m
if (fd < 0)
return NULL;
- FILE* stream = fdopen(fd, mode);
- if (!stream)
+ FILE* fp = fdopen(fd, mode);
+ if (!fp)
close(fd);
- return stream;
+ return fp;
}
static inline uint64_t fast_strtoull_dec(char** str, int maxlen) {
@@ -755,8 +755,8 @@ static bool LinuxProcessTable_readStatmFile(LinuxProcess* process, openat_arg_t
static bool LinuxProcessTable_readSmapsFile(LinuxProcess* process, openat_arg_t procFd, bool haveSmapsRollup) {
//http://elixir.free-electrons.com/linux/v4.10/source/fs/proc/task_mmu.c#L719
//kernel will return data in chunks of size PAGE_SIZE or less.
- FILE* f = fopenat(procFd, haveSmapsRollup ? "smaps_rollup" : "smaps", "r");
- if (!f)
+ FILE* fp = fopenat(procFd, haveSmapsRollup ? "smaps_rollup" : "smaps", "r");
+ if (!fp)
return false;
process->m_pss = 0;
@@ -764,10 +764,10 @@ static bool LinuxProcessTable_readSmapsFile(LinuxProcess* process, openat_arg_t
process->m_psswp = 0;
char buffer[256];
- while (fgets(buffer, sizeof(buffer), f)) {
+ while (fgets(buffer, sizeof(buffer), fp)) {
if (!strchr(buffer, '\n')) {
// Partial line, skip to end of this line
- while (fgets(buffer, sizeof(buffer), f)) {
+ while (fgets(buffer, sizeof(buffer), fp)) {
if (strchr(buffer, '\n')) {
break;
}
@@ -784,7 +784,7 @@ static bool LinuxProcessTable_readSmapsFile(LinuxProcess* process, openat_arg_t
}
}
- fclose(f);
+ fclose(fp);
return true;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy