git: 1961b4605913 - stable/13 - savecore: fold maxdumps check into getbounds()

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Mon, 16 May 2022 13:51:17 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=1961b4605913e6fc98b6cce08e8078e034ea255f

commit 1961b4605913e6fc98b6cce08e8078e034ea255f
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-04-18 15:18:13 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-05-16 13:34:03 +0000

    savecore: fold maxdumps check into getbounds()
    
    So that new callers of getbounds() don't need to duplicate it.
    
    Reviewed by:    markj
    MFC after:      3 days
    Sponsored by:   Juniper Networks, Inc.
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D34783
    
    (cherry picked from commit 4243d307d397dedb2161499742288450fd311e1b)
---
 sbin/savecore/savecore.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index fddeaf6e284f..755fef6bf31d 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -257,6 +257,8 @@ getbounds(int savedirfd)
 	ret = (int)strtol(buf, NULL, 10);
 	if (ret == 0 && (errno == EINVAL || errno == ERANGE))
 		logmsg(LOG_WARNING, "invalid value found in bounds, using 0");
+	if (maxdumps > 0 && ret == maxdumps)
+		ret = 0;
 	fclose(fp);
 	return (ret);
 }
@@ -721,9 +723,6 @@ DoFile(const char *savedir, int savedirfd, const char *device)
 		return;
 	}
 
-	if (maxdumps > 0 && bounds == maxdumps)
-		bounds = 0;
-
 	if (buf == NULL) {
 		buf = malloc(BUFFERSIZE);
 		if (buf == NULL) {