[PATCH 1/2] script: move output limit check to dedicated function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn@xxxxxxxxxx>
---
 term-utils/script.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 6d5ddd84a..dfea87463 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -414,6 +414,19 @@ static void write_eof_to_shell(struct script_control *ctl)
 	write_to_shell(ctl, &c, sizeof(char));
 }
 
+static void check_output_limit(struct script_control *ctl)
+{
+	if (ctl->maxsz != 0 && ctl->outsz >= ctl->maxsz) {
+		if (!ctl->quiet)
+			printf(_("Script terminated, max output file size "
+				"%"PRIu64" exceeded.\n"), ctl->maxsz);
+
+		DBG(IO, ul_debug("output size %"PRIu64", exceeded limit %"PRIu64,
+			ctl->outsz, ctl->maxsz));
+		done_log(ctl, _("max output size exceeded"));
+	}
+}
+
 static void handle_io(struct script_control *ctl, int fd, int *eof)
 {
 	char buf[BUFSIZ];
@@ -451,13 +464,7 @@ static void handle_io(struct script_control *ctl, int fd, int *eof)
 		DBG(IO, ul_debug(" master --> stdout %zd bytes", bytes));
 		write_output(ctl, buf, bytes);
 
-		/* check output limit */
-		if (ctl->maxsz != 0 && ctl->outsz >= ctl->maxsz) {
-			if (!ctl->quiet)
-				printf(_("Script terminated, max output file size %"PRIu64" exceeded.\n"), ctl->maxsz);
-			DBG(IO, ul_debug("output size %"PRIu64", exceeded limit %"PRIu64, ctl->outsz, ctl->maxsz));
-			done_log(ctl, _("max output size exceeded"));
-		}
+		check_output_limit(ctl);
 	}
 }
 
-- 
2.16.1




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux