Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3773179rdb; Thu, 14 Sep 2023 02:02:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4ULcznJAB6lkqw8Idtu9ccSQgJ2mzgntb6uKQAB202Aoxn58lQbUnNiHmPrcL25c1VGMa X-Received: by 2002:a17:903:22cc:b0:1c3:b1d8:41b8 with SMTP id y12-20020a17090322cc00b001c3b1d841b8mr6702413plg.0.1694682159008; Thu, 14 Sep 2023 02:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694682158; cv=none; d=google.com; s=arc-20160816; b=KlRFg21bDwyrbChXSA+6wN3dxLjJWOEHLgHMqesGXPjyC5CtpjiHPn+kfCdRt5MWIh JUXzD2uY8wbMy/iY6UBt17fgvDqF0Utb3jAaUbDJTc5qpbLauJigWCOdXrqjDO/IIjU0 GBksWcYChV9dfkUpxCjAfk6mbvBobCB2YcIQ0LPwv3DPy4Xta5mzygGfuxY6v1zFlIGK 3GBTnwp4TT7kgJMvYuoifyLiv+LwBPyU2nEZj6wW3Jlvq53XpEo/ja8RP3tIsRGGepVr mfmnEKSqCSiM2KxvagcclVhWvQBK4VKnra8ho+eT5tH6rSBNkeyoetpG5sISZvF3LIPA Iy/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Yy7C3eh8AGJ5bOR1d/ShKLFT+panz2pLVtrtSqm2ZHg=; fh=RRDU2ConwD1Ch8Hb+3YXX73LOu3fTA1Hpcj4W1pDUus=; b=VkbfR0bfUeZW9y7nwuHbtn3N9xxsifHVBh6CPFmbBP2H2FwJ2Mb2gt2Bsll9ZXnbLc NGCEP+mQgto98VY1g0QcwBIpJKig1kLlt9b001D5ebmTgufuqwFIiUBHKeCGTZ0gcj4s /qIEJstWESfhsVyP9uwO/1zH4u6ds1ltxA22J/GnkCIVo1Dhs+XGHF3qQWPpEvsWRPGR WaDpWfZtApbP72WNCeCYl0HjbaqPOuDfNy/N3uNV+JewEqc60zGv4GXluFbWHfGUbVSX oF5hv98i1Ar1ErkSubNbgVHyjukq25fCXrplXYGpQ0eZ1oQByouXOdhcN9zgepPlbwME 0JRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=XD76436I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id b3-20020a170903228300b001b6c462acbdsi1373595plh.15.2023.09.14.02.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 02:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=XD76436I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DF01480B19AA; Thu, 14 Sep 2023 01:02:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235969AbjINICg (ORCPT + 99 others); Thu, 14 Sep 2023 04:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231274AbjINICg (ORCPT ); Thu, 14 Sep 2023 04:02:36 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C41061BFB for ; Thu, 14 Sep 2023 01:02:31 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40434d284f7so4142005e9.3 for ; Thu, 14 Sep 2023 01:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1694678550; x=1695283350; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Yy7C3eh8AGJ5bOR1d/ShKLFT+panz2pLVtrtSqm2ZHg=; b=XD76436IqKjCqyjfCqfMZRTQBNlgBe65EWcim9kOBLUT48ZwCcklXXHkGTmAMPbpqc jksJbKz3t+2dZZjifjWIBcM4bwjhOi5Btdf3uCyLW9L0fYQXlvLAUBTm7rYHs6iEYOoW 71nJ7E1Go4X5VWgwy0b3Ni7h1WIkiVyhDubUnH8NCGOJD4UiqJp2JF2PXdKoesLlVEAU 0UWyFagIjEj/7idmggSoqlQUYHcy4fnajX709YcLmwEty0uYA9eDUTa2ExxcfDiwnofO S5nmV1xcepEP77Imkro17DjGG9tClb4L9gxQh8gQusxEPsLy1cZ6DfG8YaUNdwjEmEOZ SiAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694678550; x=1695283350; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Yy7C3eh8AGJ5bOR1d/ShKLFT+panz2pLVtrtSqm2ZHg=; b=IUAl8R2A4AI0pMigY6ymuygzHZl8bKFLD1Xvqg3e2ds0B832p/+vjNnsjbCAkSeZUt 2ho1XfehgA/WYD5adh6RmSKxG2Ws3DlvtF5/TSj6yE6ee/PflnuBztMswrazWcB9YAQ7 QF4Lw0Jz3LAGv2H10Sxxk1ZU7yZdcKhGuKs0tG6hP9qi6JIlfClQ27eQxrM/Iw1UtKzq N6QUzuT38CF1bmryHcLmu7KTUkdd8tz2Nn7aPRFqet2ud8IQ97bGHU8IqJSL3xCXgViu Tv94g9WF18KiNLoBj1yzyet+Bx+tp5uaw/3Ca+ttU6z5Tb2WVvEw/C/gL4lv6kzg5kWj RM4Q== X-Gm-Message-State: AOJu0YygLdHLyaXAN34BQQsGnXMZnAN2lY1g3eKhs2bejEuPcBEuF8JF NXc0iZKndhI32LYR0BelUNXZKw== X-Received: by 2002:a7b:c414:0:b0:402:fe6d:6296 with SMTP id k20-20020a7bc414000000b00402fe6d6296mr4102677wmi.9.1694678550109; Thu, 14 Sep 2023 01:02:30 -0700 (PDT) Received: from localhost (cst2-173-16.cust.vodafone.cz. [31.30.173.16]) by smtp.gmail.com with ESMTPSA id t7-20020a1c7707000000b003fedcd02e2asm1233317wmi.35.2023.09.14.01.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 01:02:29 -0700 (PDT) Date: Thu, 14 Sep 2023 10:02:28 +0200 From: Andrew Jones To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Haibo Xu , Anup Patel Subject: Re: [PATCH] KVM: selftests: Assert that vasprintf() is successful Message-ID: <20230914-d8d1bb0c3d71454c0a55f721@orel> References: <20230914010636.1391735-1-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230914010636.1391735-1-seanjc@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 01:02:52 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email On Wed, Sep 13, 2023 at 06:06:36PM -0700, Sean Christopherson wrote: > Assert that vasprintf() succeeds as the "returned" string is undefined > on failure. Checking the result also eliminates the only warning with > default options in KVM selftests, i.e. is the only thing getting in the > way of compile with -Werror. > > lib/test_util.c: In function ‘strdup_printf’: > lib/test_util.c:390:9: error: ignoring return value of ‘vasprintf’ > declared with attribute ‘warn_unused_result’ [-Werror=unused-result] > 390 | vasprintf(&str, fmt, ap); > | ^~~~~~~~~~~~~~~~~~~~~~~~ > Oh, darn. My compilers didn't report that or I would have fixed it. > Don't bother capturing the return value, allegedly vasprintf() can only > fail due to a memory allocation failure. > > Fixes: dfaf20af7649 ("KVM: arm64: selftests: Replace str_with_index with strdup_printf") > Cc: Andrew Jones > Cc: Haibo Xu > Cc: Anup Patel > Signed-off-by: Sean Christopherson > --- > > I haven't actually run the relevant tests, someone should probably do so on > ARM and/or RISC-V to make sure I didn't do something stupid. Done for both. Reviewed-by: Andrew Jones Tested-by: Andrew Jones Thanks, drew > > tools/testing/selftests/kvm/lib/test_util.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/lib/test_util.c b/tools/testing/selftests/kvm/lib/test_util.c > index 3e36019eeb4a..5d7f28b02d73 100644 > --- a/tools/testing/selftests/kvm/lib/test_util.c > +++ b/tools/testing/selftests/kvm/lib/test_util.c > @@ -387,7 +387,7 @@ char *strdup_printf(const char *fmt, ...) > char *str; > > va_start(ap, fmt); > - vasprintf(&str, fmt, ap); > + TEST_ASSERT(vasprintf(&str, fmt, ap) >= 0, "vasprintf() failed"); > va_end(ap); > > return str; > > base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d > -- > 2.42.0.283.g2d96d420d3-goog >