From 7055a56794dd18f7a29e4064d7f227ac3e04709c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 16 Jan 2024 08:00:00 +0000 Subject: modules: do not invoke getline(3) unnecessarily Replace while (getline(...) != -1 && retval) with while (retval && getline(...) != -1) * modules/pam_listfile/pam_listfile.c (pam_listfile): Do not invoke getline(3) when its result is going to be ignored. * modules/pam_securetty/pam_securetty.c (securetty_perform_check): Likewise. --- modules/pam_securetty/pam_securetty.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules/pam_securetty') diff --git a/modules/pam_securetty/pam_securetty.c b/modules/pam_securetty/pam_securetty.c index 617af679..9264a309 100644 --- a/modules/pam_securetty/pam_securetty.c +++ b/modules/pam_securetty/pam_securetty.c @@ -157,8 +157,7 @@ securetty_perform_check (pam_handle_t *pamh, int ctrl, retval = 1; - while ((getline(&ttyfileline, &ttyfilelinelen, ttyfile) != -1) - && retval) { + while (retval && getline(&ttyfileline, &ttyfilelinelen, ttyfile) != -1) { ttyfileline[strcspn(ttyfileline, "\n")] = '\0'; retval = ( strcmp(ttyfileline, uttyname) -- cgit v1.2.3