Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp105128iof; Sun, 5 Jun 2022 22:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpehEsBBIMrDpAk6mkj0XWwcV+wOJ0J4u36v1IItkk4NrZayfJWjLZ67k/vezg9RZ6kOCP X-Received: by 2002:a17:90b:4c0f:b0:1e6:9e44:edcb with SMTP id na15-20020a17090b4c0f00b001e69e44edcbmr20847211pjb.2.1654493522393; Sun, 05 Jun 2022 22:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493522; cv=none; d=google.com; s=arc-20160816; b=Wd7jVla7LSBRRJM1i3cwASJ9SIE1q9Ek+qszN0Pxth5o15nwu+byA7qy5PhXIq8CXW ufJMJMKsgbYmBSJ+PA59DnZqpu8VQAwfAQdirudQ9B78ImVOCiw6F+otWBV4L7CDY3oH JMOMFxgeJ313W9cFwjQYaruSoYxNTk+P3uBUtWbqw3AetkjnpDSC2C2degrumw75A/w5 tFhPdaGHGB6OYQHjIwGWe78hOOaEU+V1nYjyCo8aBUHOUDzEFhfs/ZgwHMSgmvfRuzdh XcTi5h7CXetWPaWHPKiMXX1u2EXluOAfHVhbSQpa92c773F04c5EL54ZMwu1A/wW3DmW mOqg== 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=Shg77HnyMQRXbMxMOH7fDju/B6P367xm3FEJBtf2/5I=; b=XyZQUjj+QrVYxYiz/Rt0bxnp/J9hHK0m1L0wNVnXSTaJvSFbum9adD0FPBwASRBO29 TewwZIImrvnEloIdzldUjuiBNqa0kh5WwcUokJc4SF4qvCzHFL/ps93p9eEUM/5YDWCI YWjWham8dtGR8dpZ82DyjHLhUG5I1qpsN0R8XX8OIjB2m5dGoxbk592rifZLrggSKtOg ulSZ6S50FoVnLwlXVlCMgyBPy+veiXO7ULZz5rpYKKu8/cVITCgVRhOBCO2E1MKSEVIt U1YltvtWZ9HiV6Babipv6my5WT6pH5ds2IegnqfwDk82W1N/EtYxeol3N5XWpKRDrljV K+cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZHiSfBqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 189-20020a6300c6000000b003fd085317e3si12456731pga.176.2022.06.05.22.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZHiSfBqP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4F9FF1FA4CA; Sun, 5 Jun 2022 21:30:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240198AbiFDTbz (ORCPT + 99 others); Sat, 4 Jun 2022 15:31:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240140AbiFDTbi (ORCPT ); Sat, 4 Jun 2022 15:31:38 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E79034F9D2 for ; Sat, 4 Jun 2022 12:31:10 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id t21so935157qtw.11 for ; Sat, 04 Jun 2022 12:31:10 -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=Shg77HnyMQRXbMxMOH7fDju/B6P367xm3FEJBtf2/5I=; b=ZHiSfBqPf0mmbm6Cwm8a5Stmx8hor2CW8L2no7YFJT+21lVu1KlVat/aaUe3DDYjH/ y4u/TFZndKUExogSMANFNdRkkv5S1EAcSEHdbgHQVDsQUT/Ei7aDabv4lcnV/1CUHJIl CbSGFxkKVgXnqltp5pM4Ld1WfhRNwHyDq0FVChR4oMeLklKEqtCf9rFv4ko3NNv+vF9E Pz5Ggg0J0GrzUmaZhWcITVVjxszp2JyiHvsNw5NXivNPNOAYYRu6FSxvytF3c/1enH02 akpVa+IoaPLG3KOtR63Vr9o0+hXnsRUh1/os5CusE6GXQrYUbv6SlnJIOEPh62PINNho yuhQ== 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=Shg77HnyMQRXbMxMOH7fDju/B6P367xm3FEJBtf2/5I=; b=bleMMShbgtvPHrqnChmxlnJ+zG3yDrybCqvMOStmHq+gmyLdxDf3dbHz8VHXgWoFUZ hDtdicrW6qdppkgnfw17u/OXEhyygtjbb7Ywkr/LmpEUqb3aNrzjrUV2yS5bbYI3XiSc zd+Z2ZyPIvGmWnRNPtpV4DUste8djri9v4J8wxbLlpoRegd2wMynSuhPjmK8v9DW4lE6 djk6vQEfNgmVo7gtKMyvvoEEdw8R7bB0dKReilPUPRXuQZp4aYbYS+VwyHFEUnzv/hOj ibHUzisQXwkF/64iSftZLFnslffQCq61dAV7trtFr6/TobbskynEnDd+Q/ki7u//dBHr jTsA== X-Gm-Message-State: AOAM530/voVDP3LfGwJGrkoQ2e1FdTeoYECKBSBpQHkMyXGPKeMBu7sg W6Zz8F1tk4qiy6WpuBG+0FKX5+uM6dLA X-Received: by 2002:ac8:578f:0:b0:2f9:317a:bd25 with SMTP id v15-20020ac8578f000000b002f9317abd25mr12802150qta.456.1654371069357; Sat, 04 Jun 2022 12:31:09 -0700 (PDT) Received: from moria.home.lan (c-73-219-103-14.hsd1.vt.comcast.net. [73.219.103.14]) by smtp.gmail.com with ESMTPSA id o17-20020ac84291000000b00304defdb1b3sm3537426qtl.85.2022.06.04.12.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jun 2022 12:31:08 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org Cc: Kent Overstreet , pmladek@suse.com, rostedt@goodmis.org Subject: [PATCH v3 13/33] test_printf: Drop requirement that sprintf not write past nul Date: Sat, 4 Jun 2022 15:30:22 -0400 Message-Id: <20220604193042.1674951-14-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220604193042.1674951-1-kent.overstreet@gmail.com> References: <20220604193042.1674951-1-kent.overstreet@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 ff833870f5..a702dd5dc0 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -78,12 +78,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.0