Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2874701pxu; Sat, 19 Dec 2020 05:01:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC5UGxgQ3QNrvmXmGfCRs+XqDUnVFyL35HvGRbiRQvYZn4isoVwFcQVMl8Lo9ZBKRG9eo8 X-Received: by 2002:a17:906:229a:: with SMTP id p26mr8206030eja.291.1608382901611; Sat, 19 Dec 2020 05:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608382901; cv=none; d=google.com; s=arc-20160816; b=fG0q9yHzHTee3Z2bL2iutjjBi2hP+wg3k6SJvbhN2qeQS+8BYbP7aN6YutHlwUbgr7 STWeTgYgTec14/w4BKsGPlUAMV3FAJqDljAdIcMtb8wyMSQOOHHuphgFOHLHZAsusdfr cGDBqLKi/MfU0c8yfX0pJW7TVLtOCHuWmV+AE5gcepCbBWPa6HNTSWe49GqBsv1lUBvZ bQJyokLhUnz/dmz0hqsRWwnWzXZcA34tigOqEAZtnKYV2naNNHrZKyKISODo4/SbHA1k LLu8DCN5ira4+ELdEqnUo/30X+BPIrJduxEWYh6Pm0v82cAUWHR5YxQFGX7YMuEKzzzC 55zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=ONkX9fVhVhjnYdEE37RBGpKLZVTPAcaCLu7Bup7fLKs=; b=P2cq7Ec8jnaQ7AutVi5zxtdPodBN80W/pB6JI65ylI4Wa75aNvuB1Xyid/dSLA+MDg n6ZiGhvjgiiDwPpDOghCfsXRlBWATHYaVZxZpRSVV32H2mEip2yFULLl9KVpf1GNaM/W 4g2jDeNEgnh14atd7kb0pDIW0BhdPR3IBSYoAsxoY7Zvq3zGh0tbYjuI6hsTPrTDWy2i XDpTJYvvmGeNih7RWX+AP2zC54BJ0mByM4bh2EvC9SqRktsovHVI/DnzyCik7FK9ylTN W7x67o43cUp/zdGaNULcxgdTtWifgxXp6WD0YDDrTHCxfqs/If+PGFQXV1qVPF33Ix+A WzBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si6182301ejj.305.2020.12.19.05.01.19; Sat, 19 Dec 2020 05:01:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728378AbgLSNAC (ORCPT + 99 others); Sat, 19 Dec 2020 08:00:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:46332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbgLSM7h (ORCPT ); Sat, 19 Dec 2020 07:59:37 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Steven Rostedt (VMware)" Subject: [PATCH 5.9 34/49] ktest.pl: Fix the logic for truncating the size of the log file for email Date: Sat, 19 Dec 2020 13:58:38 +0100 Message-Id: <20201219125346.341459473@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125344.671832095@linuxfoundation.org> References: <20201219125344.671832095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) commit 170f4869e66275f498ae4736106fb54c0fdcd036 upstream. The logic for truncating the log file for emailing based on the MAIL_MAX_SIZE option is confusing and incorrect. Simplify it and have the tail of the log file truncated to the max size specified in the config. Cc: stable@vger.kernel.org Fixes: 855d8abd2e8ff ("ktest.pl: Change the logic to control the size of the log file emailed") Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- tools/testing/ktest/ktest.pl | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -1499,17 +1499,16 @@ sub dodie { my $log_file; if (defined($opt{"LOG_FILE"})) { - my $whence = 0; # beginning of file - my $pos = $test_log_start; + my $whence = 2; # End of file + my $log_size = tell LOG; + my $size = $log_size - $test_log_start; if (defined($mail_max_size)) { - my $log_size = tell LOG; - $log_size -= $test_log_start; - if ($log_size > $mail_max_size) { - $whence = 2; # end of file - $pos = - $mail_max_size; + if ($size > $mail_max_size) { + $size = $mail_max_size; } } + my $pos = - $size; $log_file = "$tmpdir/log"; open (L, "$opt{LOG_FILE}") or die "Can't open $opt{LOG_FILE} to read)"; open (O, "> $tmpdir/log") or die "Can't open $tmpdir/log\n";