From patchwork Mon Jun 20 00:42:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 12886904 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AED1DC433EF for ; Mon, 20 Jun 2022 00:43:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C5206B0083; Sun, 19 Jun 2022 20:43:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 44EEB6B0085; Sun, 19 Jun 2022 20:43:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2790E6B0087; Sun, 19 Jun 2022 20:43:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 183736B0083 for ; Sun, 19 Jun 2022 20:43:03 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ECF6B34565 for ; Mon, 20 Jun 2022 00:43:02 +0000 (UTC) X-FDA: 79596764604.02.B380CE2 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by imf25.hostedemail.com (Postfix) with ESMTP id 5580BA0009 for ; Mon, 20 Jun 2022 00:43:02 +0000 (UTC) Received: by mail-qv1-f43.google.com with SMTP id p31so13998719qvp.5 for ; Sun, 19 Jun 2022 17:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jzrJaN7GJ4zvwlB0O2GIJnZ1v/nEIhK2TK9aO5Rtgmc=; b=Lx1lmnEKLmHMo8GHFAGvtwT3kPHmLRskpKD6CEVJIlEOc7OOqPkS+AyPuQjC6rkL/R RVK8+PQf6sJtv6K7a1/JuyP1Tc8zux4etc1R1OE3bbgEZ3C8RrskO7A6KayUFnodw0Pi /nvSWAOB9bk2S6Md2QizVlUhMvW8PKZGGu8BijiTIUeuUUB/OGAuTBxCrEE/ciQCaAUX Rml/JegJzNmIz1eCPDhc3Qw9qhEClxDG6UowIKZUFCXu6kOW63ydkkszQeUimcN+3KHr RuJ/x1XnWgd11/FREucrvMRD+5RQLlaQC0XKRsSPIHg0Gshd7s5dqqdASW/2g/yvTaQo gWfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jzrJaN7GJ4zvwlB0O2GIJnZ1v/nEIhK2TK9aO5Rtgmc=; b=d02SwwxKnX7hTJFFLRpNcOU74+PTh43jc4AJm2Lre4mocNsvnIDThFoWiDipqsSJeY /0hF4J0/X+TedU1206h509szM2GcVrpXpRRwKrIrkj0SnaFeJ3zFnOtODOmkfvjDA6wo e7DYcnETP9F/ItU886N3NRAg0Yccq5WZP82Z/R8MO4VyAjuminxmZTIaY84j2+0TIqFQ M4yV9vWRBgazZbpBSndqJgqoeAvUMQT8YFwFg66darRwEv3+9AE1T2YZWBbt4UrMt+kp zFRahOg56li/oqA+XD8sGBLAC4ii1gIdijiVW+NuF6JZenqq8LoTd6kPds52FsmFQPiJ EGpg== X-Gm-Message-State: AJIora9++XiF2Vyvrzve8LGs6B4M7HApQGQ3o1i8hkC72UyHJc7G+3bL Clb3/AFcxIJUdMaPYTYwEg== X-Google-Smtp-Source: AGRyM1sksTfZsVTyUyCjlAQdG4wXyI6RZnc1sCTZrHrYV9IC64sOB5+yfZ27xlwBXuwuV9wyMa93IA== X-Received: by 2002:ac8:5750:0:b0:304:fcfa:67db with SMTP id 16-20020ac85750000000b00304fcfa67dbmr17632697qtx.249.1655685781656; Sun, 19 Jun 2022 17:43:01 -0700 (PDT) Received: from localhost (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id c10-20020a05620a0cea00b006a6ab259261sm9905480qkj.29.2022.06.19.17.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jun 2022 17:43:01 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, pmladek@suse.com Cc: Kent Overstreet , rostedt@goodmis.org, enozhatsky@chromium.org, linux@rasmusvillemoes.dk, willy@infradead.org Subject: [PATCH v4 13/34] test_printf: Drop requirement that sprintf not write past nul Date: Sun, 19 Jun 2022 20:42:12 -0400 Message-Id: <20220620004233.3805-14-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620004233.3805-1-kent.overstreet@gmail.com> References: <20220620004233.3805-1-kent.overstreet@gmail.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655685782; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jzrJaN7GJ4zvwlB0O2GIJnZ1v/nEIhK2TK9aO5Rtgmc=; b=XjGqpJaUpbwp78DeVCYRcSMySJ2GmxYS3uX/bxURhD23mrF6TMMPndFGx5EP7kKXIXVQW2 2dCXx4UEBao9L+5cl9HeY111oImnwYWQzb8MjYbmyGKfaCwOXy79Mgx7nalaVt3u45zbeV GcZKQJ8kyLcxe0eSi6tULcb9oYRw6/4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655685782; a=rsa-sha256; cv=none; b=0bzNXh6ZlxYefgoSZykP4rvI1Dj+XyYecWbBuc+rralSp6y6vX8PHiL5XrP5nXPNaif/9R Dwr4ZegDVWT6IGzOReJjnl2sgVkN2gUSkPNM8ioHs1D3CR1Gv+popOmdb/Iu44X+BmUsx3 jkP7HGR6kwiA/oDdRtcOv/ygEHP3EN8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Lx1lmnEK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Lx1lmnEK; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of kent.overstreet@gmail.com designates 209.85.219.43 as permitted sender) smtp.mailfrom=kent.overstreet@gmail.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: o76xc9d7sga8gwycd9o3y6a85nkd5dyb X-Rspamd-Queue-Id: 5580BA0009 X-HE-Tag: 1655685782-391606 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The current test code checks that sprintf never writes past the terminating nul. This is a rather strange requirement, completely separate from writing past the end of the buffer, which of course we can't do: writing anywhere to the buffer passed to snprintf, within size of course, should be perfectly fine. Since this check has no documentation as to where it comes from or what depends on it, and it's getting in the way of further refactoring (printf_spec handling is right now scattered massively throughout the code, and we'd like to consolidate it) - delete it. Also, many current pretty-printers building up their output on the stack, and then copy it to the actual output buffer - by eliminating this requirement we can kill those extra buffers. Signed-off-by: Kent Overstreet --- lib/test_printf.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index e3de52da91..853e89e2f8 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -79,12 +79,6 @@ do_test(int bufsize, const char *expect, int elen, return 1; } - if (memchr_inv(test_buffer + written + 1, FILL_CHAR, BUF_SIZE + PAD_SIZE - (written + 1))) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond the nul-terminator\n", - bufsize, fmt); - return 1; - } - if (memcmp(test_buffer, expect, written)) { pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote '%s', expected '%.*s'\n", bufsize, fmt, test_buffer, written, expect);