summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2024-04-17 16:50:34 +0800
committerBenBE <BenBE@geshi.org>2024-04-17 11:54:00 +0200
commit7017b86bbfafe14859d0fa94ec89351ee167db9e (patch)
treed08e55b1b7898fa1613ac8071217ac31836d5e43
parenta46b3f0a98c801b94df08598be0127e4d7db2aca (diff)
Use 'sb' name for local 'struct stat' buffers
Deprecate the use of 'st' and other names. The 'sb' name is often seen in example codes in Linux man pages. (The 'statbuf' name is sometimes also used but I choose 'sb' name because it's shorter.) No code changes.
-rw-r--r--Compat.c6
-rw-r--r--OpenFilesScreen.c6
-rw-r--r--linux/LinuxProcessTable.c26
3 files changed, 19 insertions, 19 deletions
diff --git a/Compat.c b/Compat.c
index d0ad2cc9..6df0b081 100644
--- a/Compat.c
+++ b/Compat.c
@@ -50,11 +50,11 @@ int Compat_faccessat(int dirfd,
}
// Fallback to stat(2)/lstat(2) depending on flags
- struct stat statinfo;
+ struct stat sb;
if (flags) {
- ret = lstat(pathname, &statinfo);
+ ret = lstat(pathname, &sb);
} else {
- ret = stat(pathname, &statinfo);
+ ret = stat(pathname, &sb);
}
return ret;
diff --git a/OpenFilesScreen.c b/OpenFilesScreen.c
index 08b3b3d6..d04cce76 100644
--- a/OpenFilesScreen.c
+++ b/OpenFilesScreen.c
@@ -238,10 +238,10 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
item = &fdata->data;
const char* filename = getDataForType(item, 'n');
- struct stat st;
- if (stat(filename, &st) == 0) {
+ struct stat sb;
+ if (stat(filename, &sb) == 0) {
char fileSizeBuf[21]; /* 20 (long long) + 1 (NULL) */
- xSnprintf(fileSizeBuf, sizeof(fileSizeBuf), "%"PRIu64, (uint64_t)st.st_size); /* st.st_size is long long on macOS, long on linux */
+ xSnprintf(fileSizeBuf, sizeof(fileSizeBuf), "%"PRIu64, (uint64_t)sb.st_size); /* sb.st_size is long long on macOS, long on linux */
free_and_xStrdup(&item->data[fileSizeIndex], fileSizeBuf);
}
}
diff --git a/linux/LinuxProcessTable.c b/linux/LinuxProcessTable.c
index 1e7c041d..f3271022 100644
--- a/linux/LinuxProcessTable.c
+++ b/linux/LinuxProcessTable.c
@@ -490,18 +490,18 @@ static bool LinuxProcessTable_updateUser(const Machine* host, Process* process,
return true;
}
- struct stat sstat;
+ struct stat sb;
#ifdef HAVE_OPENAT
- int statok = fstat(procFd, &sstat);
+ int statok = fstat(procFd, &sb);
#else
- int statok = stat(procFd, &sstat);
+ int statok = stat(procFd, &sb);
#endif
if (statok == -1)
return false;
- if (process->st_uid != sstat.st_uid) {
- process->st_uid = sstat.st_uid;
- process->user = UsersTable_getRef(host->usersTable, sstat.st_uid);
+ if (process->st_uid != sb.st_uid) {
+ process->st_uid = sb.st_uid;
+ process->user = UsersTable_getRef(host->usersTable, sb.st_uid);
}
return true;
@@ -1349,19 +1349,19 @@ static char* LinuxProcessTable_updateTtyDevice(TtyDriver* ttyDrivers, unsigned l
continue;
}
unsigned int idx = min - ttyDrivers[i].minorFrom;
- struct stat sstat;
+ struct stat sb;
char* fullPath;
for (;;) {
xAsprintf(&fullPath, "%s/%d", ttyDrivers[i].path, idx);
- int err = stat(fullPath, &sstat);
- if (err == 0 && major(sstat.st_rdev) == maj && minor(sstat.st_rdev) == min) {
+ int err = stat(fullPath, &sb);
+ if (err == 0 && major(sb.st_rdev) == maj && minor(sb.st_rdev) == min) {
return fullPath;
}
free(fullPath);
xAsprintf(&fullPath, "%s%d", ttyDrivers[i].path, idx);
- err = stat(fullPath, &sstat);
- if (err == 0 && major(sstat.st_rdev) == maj && minor(sstat.st_rdev) == min) {
+ err = stat(fullPath, &sb);
+ if (err == 0 && major(sb.st_rdev) == maj && minor(sb.st_rdev) == min) {
return fullPath;
}
free(fullPath);
@@ -1372,8 +1372,8 @@ static char* LinuxProcessTable_updateTtyDevice(TtyDriver* ttyDrivers, unsigned l
idx = min;
}
- int err = stat(ttyDrivers[i].path, &sstat);
- if (err == 0 && tty_nr == sstat.st_rdev) {
+ int err = stat(ttyDrivers[i].path, &sb);
+ if (err == 0 && tty_nr == sb.st_rdev) {
return xStrdup(ttyDrivers[i].path);
}
}

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