Skip to content

Commit

Permalink
Minor code style adjustment in matchCmdlinePrefixWithExeSuffix()
Browse files Browse the repository at this point in the history
Improve readability of local variables.

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Feb 2, 2025
1 parent 648e859 commit 4f112fc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ static bool findCommInCmdline(const char* comm, const char* cmdline, int cmdline

static int matchCmdlinePrefixWithExeSuffix(const char* cmdline, int cmdlineBaseOffset, const char* exe, int exeBaseOffset, int exeBaseLen) {
int matchLen; /* matching length to be returned */
char delim; /* delimiter following basename */

/* cmdline prefix is an absolute path: it must match whole exe. */
if (cmdline[0] == '/') {
matchLen = exeBaseLen + exeBaseOffset;
if (strncmp(cmdline, exe, matchLen) == 0) {
delim = cmdline[matchLen];
char delim = cmdline[matchLen];
if (delim == 0 || delim == '\n' || delim == ' ') {
return matchLen;
}
Expand All @@ -127,13 +126,13 @@ static int matchCmdlinePrefixWithExeSuffix(const char* cmdline, int cmdlineBaseO
*
* So if needed, we adjust cmdlineBaseOffset to the previous (if any)
* component of the cmdline relative path, and retry the procedure. */
bool delimFound; /* if valid basename delimiter found */
bool delimFound = true; /* if valid basename delimiter found */
do {
/* match basename */
matchLen = exeBaseLen + cmdlineBaseOffset;
if (cmdlineBaseOffset < exeBaseOffset &&
strncmp(cmdline + cmdlineBaseOffset, exe + exeBaseOffset, exeBaseLen) == 0) {
delim = cmdline[matchLen];
char delim = cmdline[matchLen];
if (delim == 0 || delim == '\n' || delim == ' ') {
int i, j;
/* reverse match the cmdline prefix and exe suffix */
Expand All @@ -149,7 +148,8 @@ static int matchCmdlinePrefixWithExeSuffix(const char* cmdline, int cmdlineBaseO

/* Try to find the previous potential cmdlineBaseOffset - it would be
* preceded by '/' or nothing, and delimited by ' ' or '\n' */
for (delimFound = false, cmdlineBaseOffset -= 2; cmdlineBaseOffset > 0; --cmdlineBaseOffset) {
delimFound = false;
for (cmdlineBaseOffset -= 2; cmdlineBaseOffset > 0; --cmdlineBaseOffset) {
if (delimFound) {
if (cmdline[cmdlineBaseOffset - 1] == '/') {
break;
Expand Down

0 comments on commit 4f112fc

Please sign in to comment.