Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2872996pxu; Sat, 19 Dec 2020 04:58:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyt/rUvK1EFACRhMts9r/ooGpRYOVo6DvT92HLyaoi/fs6UxoLZc3p/TsZVWqdDUUC4l6Mn X-Received: by 2002:a17:906:4e50:: with SMTP id g16mr8492948ejw.191.1608382728561; Sat, 19 Dec 2020 04:58:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608382728; cv=none; d=google.com; s=arc-20160816; b=Yc+5x9Zgm/bPX4VvrY5fnlqXRFqY4VIrtYt6/kfpOWp/cJbNYhupDCYgU/5oj1IgdH QolqkQBsDSREC0VrEo9kG5kk1pu+zUkTcg00Z96Xzez0vxtBNltMiZf0zN5STmqHsowW uJKOrMnSMxnyZzd/pguhJPsOP/xSLre94mbHDHjvBWJyouXljBVwZFTAY58fozkqLUe+ 7AIOQDrMPheQSOvCNRvZ3o2rjEYhJodol/1bhuaXbZ6sc/E6HYfhBpR9m9emEKUaJ2m+ 5wG9YToBA7PSKM2PrsjL0SOb6BfOzrIG5mD3Jc2cAotZYKJoYEUBs7tfZP6oiBkDCqzf wyJA== 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=fxS0WwZBIN931S3sZZ+9MOB9QDf/ML8oVpqgyTkzw9kee/S09leMJWoJL8uB/zceWh gmOIjBS71bZEb87e4nO12bVW1WSZ9P9YPtLAT2qD6of4s0hsRp4o8Ocz9kkH4HrvW0s9 XYSuobm8M2n34wu5lkRmjYIYleMAjH16TAP23cfOncOsWZUAzcwkQDzuleduAIAdHln3 O82NvCM6WDyeHsnwlS0HEY3bA0ZM6VZB3IGqah1uHcU6gziVhxYS8ccUE7oGaTpCc8AK sBHhZlCBNc+RQqqrX6Om0srHD8mIxtB8sHassRuWuN3sqJqXjRqaUU6cOdOM7ZIywcJD +0Hg== 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 bf21si8056959edb.369.2020.12.19.04.58.26; Sat, 19 Dec 2020 04:58:48 -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 S1726820AbgLSM4y (ORCPT + 99 others); Sat, 19 Dec 2020 07:56:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:43550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726479AbgLSM4x (ORCPT ); Sat, 19 Dec 2020 07:56:53 -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.10 03/16] ktest.pl: Fix the logic for truncating the size of the log file for email Date: Sat, 19 Dec 2020 13:57:10 +0100 Message-Id: <20201219125339.238687837@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125339.066340030@linuxfoundation.org> References: <20201219125339.066340030@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";