Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1871997rwb; Sun, 14 Aug 2022 14:53:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6bd8W7RF3ol7Kx9cENYw0q04WtwGcmQQNu0hIb+XdBMC8r3bAE/TJHVhDlKr47zg3nZ0Om X-Received: by 2002:a17:902:b28a:b0:171:3543:6b40 with SMTP id u10-20020a170902b28a00b0017135436b40mr14086604plr.109.1660514001762; Sun, 14 Aug 2022 14:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660514001; cv=none; d=google.com; s=arc-20160816; b=Y7goqdT2LT1/Co4ulV/RWBc494JJKtlNieQoIZkdky5mz/1NKEDia8vZGyySPST/1t isiSzL0lLLXJ0OouiNgyhgQJZuEV1Ij2z4QBTwSGBSHlzpIUF2B+SFg+Opw8/vjQUxxA HU5zUxJeVANSdJep+QRC4gb4mFRhc2PMrcftdGQvODmkAlAhoz24NbApGz81QVSLaEet c7ws7aHrBV9kR9ymNDCM3N4JZT8rPryrMAGzVXhi8JpjD5FvlZZjpJ5XiHWLay73C3Bf nReHgcxxMqBPA3sMUzuXdyyjwsC1fB9cU0FiLAfXhyluhrnyWbv52ikC1IBZx8JmCq/U sGjg== 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=lYid45vDrsfGp3/xPEZDgzeMTFMxEVq5nDuDoli1D2U=; b=alNCdwi1mXsQsfY1IAgdeL6AHwEOcX0KtfLnHS/CBbNUUO5r3r1Kl2lPERbjAr2/u5 kCrh4iXh96eHJPqUvozCx1gfz2o4wiimuzf0nXFI/NKP9db66QlHKKsjMZBgz8d9nknL mWbINN6hXCxSzRIBO9wBjf5o9Zt9QyYnA8UpwjBhQowVsES58TdB62ielZDIDxjHezbm rn4W3dK/Uy5q0mjnkyjtqdAkk72epCYyWKbSZh6zK8BQuEgIHBGucS3EPyXcEQkWzDPD 8YkqNfc9HVfs7sglYqNVRKYkDfQFLXhK2UbVMuRMOdXJmPBfRaFv0wt5iezuClcIwR/q sMQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YFv+rmH1; 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=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a056a00158d00b0052e6fe35393si9584988pfk.10.2022.08.14.14.53.11; Sun, 14 Aug 2022 14:53:21 -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=@linux.dev header.s=key1 header.b=YFv+rmH1; 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=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240355AbiHNVWB (ORCPT + 99 others); Sun, 14 Aug 2022 17:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240465AbiHNVU5 (ORCPT ); Sun, 14 Aug 2022 17:20:57 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C814B1C8 for ; Sun, 14 Aug 2022 14:20:50 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1660512048; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lYid45vDrsfGp3/xPEZDgzeMTFMxEVq5nDuDoli1D2U=; b=YFv+rmH1oFhY4ybgP1LhjEX8xQEBPX+Rb8QJenVULTRnrO8GiokbD4yKEAOm3LNifn8M8y dGDA8oniqHZBKrhfxZZQpGg0DxOnjpKeeDhVdU1Q/YvelvTuaDzv38qj3S3qWJdRs+CV2+ X3WzNCjkG293rRYrAO74gMHAdEdmh2E= From: Kent Overstreet To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Kent Overstreet , Rasmus Villemoes Subject: [PATCH 11/32] test_printf: Drop requirement that sprintf not write past nul Date: Sun, 14 Aug 2022 17:19:50 -0400 Message-Id: <20220814212011.1727798-12-kent.overstreet@linux.dev> In-Reply-To: <20220814212011.1727798-1-kent.overstreet@linux.dev> References: <20220814212011.1727798-1-kent.overstreet@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, 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 From: Kent Overstreet 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 Cc: Rasmus Villemoes --- lib/test_printf.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 4bd15a593f..da91301eae 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -84,12 +84,6 @@ do_test(int bufsize, const char *expect, int elen, return 1; } - if (memchr_inv(test_buffer + written + 1, FILL_CHAR, bufsize - (written + 1))) { - pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond the nul-terminator\n", - bufsize, fmt); - return 1; - } - if (memchr_inv(test_buffer + bufsize, FILL_CHAR, BUF_SIZE + PAD_SIZE - bufsize)) { pr_warn("vsnprintf(buf, %d, \"%s\", ...) wrote beyond buffer\n", bufsize, fmt); return 1; -- 2.36.1