Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2445928iog; Sun, 19 Jun 2022 18:18:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tjUSqxYE6UYRwlf5eQVO8te3KnKhcIS+ddaU5nGlXwR/iQ6y20FeAfpuMrIuyAkuEhwg0M X-Received: by 2002:a17:906:72c5:b0:711:d2cb:28b0 with SMTP id m5-20020a17090672c500b00711d2cb28b0mr18953170ejl.229.1655687903191; Sun, 19 Jun 2022 18:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655687903; cv=none; d=google.com; s=arc-20160816; b=YkQ/HQ3tWDdATHrc5Vi4RmPqSyvx1/MZ3IMvC2jpRDsHyqI4ufkupl6C0qSacxEVh/ 7mBqa/UKCpTgSK8iUN/lo0kTPnY40LFl74UcTNqEYA4y6TfcspVUneKWjZ7jM3gPaKsI YRZPaaxBOoROI975Vf1xI3SFp4+k26r7yb1BH44tj87wWPqapzGeTKeHkNu8n6OeJ9AO Mk769Jqkuad7ZRApqeRu4qgZsKDFh8FJUOw2JqNmenGE+bCxkUf6uffVLaV2pCjE0g/X 2+Lv3Wqh7ijVdqFByNHDqb59JJma49eY6DLuGAKcpJvSuZXc8AjnmxCSsxP8xTimE+ZV DwGw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jzrJaN7GJ4zvwlB0O2GIJnZ1v/nEIhK2TK9aO5Rtgmc=; b=04BF+hipasxakmry5Ei5Oj/zFpn0MT4/wPtdVKjTx4uqORNpqSQtDBzrnP/24142fR pxw4szQAMsBuMpFBbXeNxceiSuQlX74sPyJ7pGDTIGW/lDOy8SYMsZSoPUqhucAsk6hM 6VbGwL/dFXjvREPgpmmpr/aNGgCCDL4VwxuT1mpCJG3homVPPMns1bEnxms7ik5AkWYg yWgfGD1O9w21iYrPt8GEPiTrh3mg29QIs2pzdEeuEfBhrEVvomCznD+LhHcxrZcCYw50 WtRsgiB/MFYQx1YbN1e30cUH1zAZck10bUzSNiRwtJVKsEF6G7a0tB3atberxrmf43Fe r5Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Lx1lmnEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e20-20020a056402191400b0043120d5f3adsi10819815edz.135.2022.06.19.18.17.58; Sun, 19 Jun 2022 18:18:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Lx1lmnEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238568AbiFTApe (ORCPT + 99 others); Sun, 19 Jun 2022 20:45:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237887AbiFTAnM (ORCPT ); Sun, 19 Jun 2022 20:43:12 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A72E8B85E for ; Sun, 19 Jun 2022 17:43:03 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id g18so6506831qvn.2 for ; Sun, 19 Jun 2022 17:43:03 -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=r8kdixNkOjs59Imbledaw3FOrWGPzvT6xQmayshKJwD/N1zq057SQW/C5EKuj11kaW ATE9+F3KtTqVf9/60FYZagzso9ZynING9Za4yQuGrT356cdBVDVzjiMKa+/yK1qsN5Nb iKuM0GqmFFi9su34S9IMQS7W2vHqXYU+3jf4ASKJSDhBIzAD64PJfQhOK+wHrRfbeCEj zCWgbACSMhO7h9nZZx8qNuuCk/u7rZcR/7c0+SLU+70jNRGFK19LJyhwdhPogMil+Pfz Jq/ds9WcENSNt5EB+Bdo7O24kuok2TI9p4uaT6IVjuioJgpEhLseWShCEKROoxxyPjT7 LvOA== X-Gm-Message-State: AJIora/tDIjIcNd/qc1oXV78HzTIV37qp+Ha+rsOdWz2jOin8BT/wW2i 5t0EUSUSbx5MSsRGoqz0KSHb2pAcsBQiDpA= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.36.1