diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-05 23:47:20 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-01-06 16:43:18 +0100 |
commit | e103ec0317a88965b74107a1f2d780573c464ac8 (patch) | |
tree | 24a244f07569849948a24038a1fbfd4726598b4e | |
parent | 7ff654f2df3a49c6b46e19b95533da531f71be5b (diff) |
Declare for loop variables inside the loop
-rw-r--r-- | Process.c | 4 | ||||
-rw-r--r-- | linux/LinuxProcess.c | 3 |
2 files changed, 3 insertions, 4 deletions
@@ -187,8 +187,8 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea const char* comm = this->comm; if (this->settings->highlightBaseName || !this->settings->showProgramPath) { - int i, basename = 0; - for (i = 0; i < this->basenameOffset; i++) { + int basename = 0; + for (int i = 0; i < this->basenameOffset; i++) { if (comm[i] == '/') { basename = i + 1; } else if (comm[i] == ':') { diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index a45505e2..10017bd1 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -198,12 +198,11 @@ static bool findCommInCmdline(const char *comm, const char *cmdline, int cmdline /* Try to find procComm in tokenized cmdline - this might in rare cases * mis-identify a string or fail, if comm or cmdline had been unsuitably * modified by the process */ - const char *token; const char *tokenBase; size_t tokenLen; const size_t commLen = strlen(comm); - for (token = cmdline + cmdlineBasenameOffset; *token; ) { + for (const char *token = cmdline + cmdlineBasenameOffset; *token; ) { for (tokenBase = token; *token && *token != '\n'; ++token) { if (*token == '/') { tokenBase = token + 1; |