git: 1cdb98e72558 - stable/13 - sort: simplify file_reader_clean

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Wed, 19 Oct 2022 08:01:38 UTC
The branch stable/13 has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=1cdb98e725586384105f73d13d58a8706b6e01f8

commit 1cdb98e725586384105f73d13d58a8706b6e01f8
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2022-10-13 08:40:21 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2022-10-19 07:59:31 +0000

    sort: simplify file_reader_clean
    
    Deindent the function, remove useless tests:
     - free already test if argument is NULL
     - closefile already test if the input is stdin or null
    
    (cherry picked from commit ffd41d39c660ca1c80b77707238e8e5ef26d7d7a)
---
 usr.bin/sort/file.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index 8f9d8ac89b5b..0f1a9e6bad4d 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -574,7 +574,7 @@ openfile(const char *fn, const char *mode)
 void
 closefile(FILE *f, const char *fn)
 {
-	if (f == NULL || f = stdin)
+	if (f == NULL || f == stdin)
 		return;
 	if (f == stdout) {
 		fflush(f);
@@ -699,25 +699,18 @@ static void
 file_reader_clean(struct file_reader *fr)
 {
 
-	if (fr) {
-		if (fr->mmapaddr)
-			munmap(fr->mmapaddr, fr->mmapsize);
-
-		if (fr->fd)
-			close(fr->fd);
-
-		if (fr->buffer)
-			sort_free(fr->buffer);
-
-		if (fr->file)
-			if (fr->file != stdin)
-				closefile(fr->file, fr->fname);
+	if (fr == NULL)
+		return;
 
-		if(fr->fname)
-			sort_free(fr->fname);
+	if (fr->mmapaddr)
+		munmap(fr->mmapaddr, fr->mmapsize);
+	if (fr->fd)
+		close(fr->fd);
 
-		memset(fr, 0, sizeof(struct file_reader));
-	}
+	free(fr->buffer);
+	closefile(fr->file, fr->fname);
+	free(fr->fname);
+	memset(fr, 0, sizeof(struct file_reader));
 }
 
 void