procevent.c: reposition some debug message calls

Move them from the middle of the finalization code to before it.
This commit is contained in:
Kelvin M. Klann 2025-06-30 09:28:39 -03:00
parent 8b8bf79547
commit 0c884029fc

View file

@ -70,10 +70,10 @@ static int pid_is_firejail(pid_t pid) {
if (asprintf(&fname, "/proc/%d/cmdline", pid) == -1) if (asprintf(&fname, "/proc/%d/cmdline", pid) == -1)
errExit("asprintf"); errExit("asprintf");
if ((fd = open(fname, O_RDONLY)) < 0) { if ((fd = open(fname, O_RDONLY)) < 0) {
free(fname);
#ifdef DEBUG_PRCTL #ifdef DEBUG_PRCTL
printf("%s: %d, comm %s, rv %d\n", __FUNCTION__, __LINE__, buf, rv); printf("%s: %d, comm %s, rv %d\n", __FUNCTION__, __LINE__, buf, rv);
#endif #endif
free(fname);
goto doexit; goto doexit;
} }
free(fname); free(fname);
@ -83,10 +83,10 @@ static int pid_is_firejail(pid_t pid) {
unsigned char buffer[BUFLEN]; unsigned char buffer[BUFLEN];
ssize_t len; ssize_t len;
if ((len = read(fd, buffer, sizeof(buffer) - 1)) <= 0) { if ((len = read(fd, buffer, sizeof(buffer) - 1)) <= 0) {
close(fd);
#ifdef DEBUG_PRCTL #ifdef DEBUG_PRCTL
printf("%s: %d, comm %s, rv %d\n", __FUNCTION__, __LINE__, buf, rv); printf("%s: %d, comm %s, rv %d\n", __FUNCTION__, __LINE__, buf, rv);
#endif #endif
close(fd);
goto doexit; goto doexit;
} }
buffer[len] = '\0'; buffer[len] = '\0';
@ -136,10 +136,10 @@ static int pid_is_firejail(pid_t pid) {
int j = 0; int j = 0;
while (exclude_args[j] != NULL) { while (exclude_args[j] != NULL) {
if (strcmp(start, exclude_args[j]) == 0) { if (strcmp(start, exclude_args[j]) == 0) {
rv = 0;
#ifdef DEBUG_PRCTL #ifdef DEBUG_PRCTL
printf("start=#%s#, ptr=#%s#, flip rv %d\n", start, ptr, rv); printf("start=#%s#, ptr=#%s#, flip rv %d\n", start, ptr, rv);
#endif #endif
rv = 0;
break; break;
} }
j++; j++;
@ -150,11 +150,11 @@ printf("start=#%s#, ptr=#%s#, flip rv %d\n", start, ptr, rv);
} }
doexit: doexit:
fclose(fp);
free(file);
#ifdef DEBUG_PRCTL #ifdef DEBUG_PRCTL
printf("%s: %d, return %d\n", __FUNCTION__, __LINE__, rv); printf("%s: %d, return %d\n", __FUNCTION__, __LINE__, rv);
#endif #endif
fclose(fp);
free(file);
return rv; return rv;
} }