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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F234EC636D4 for ; Thu, 2 Feb 2023 08:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232065AbjBBITo (ORCPT ); Thu, 2 Feb 2023 03:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbjBBITg (ORCPT ); Thu, 2 Feb 2023 03:19:36 -0500 X-Greylist: delayed 514 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 02 Feb 2023 00:19:34 PST Received: from out-22.mta1.migadu.com (out-22.mta1.migadu.com [95.215.58.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECAE2834BB for ; Thu, 2 Feb 2023 00:19:34 -0800 (PST) Date: Thu, 2 Feb 2023 09:10:57 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1675325458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3ie5uGvKIrofRgo6t7ShvhGoGSYw5hlV+UY54sbIh3c=; b=MIMPAxDX5vZ3dkfPsO5DiRiiDEsk2io0Wb+spRESH22N1RK+B0qcCw5ySRYA0QYYrt5Wri bXpfIvuVDvV7/qfqpo09eYrX55QilXOgEb8KPX+NUqADcozuYKIG89w6RHCe83648Y/LfS XdJR7sQKJ9vwOovXTocnlEnILFFPTtE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Andrew Jones To: shahuang@redhat.com Cc: kvm@vger.kernel.org, Paolo Bonzini , Shuah Khan , Sean Christopherson , "open list:KERNEL SELFTEST FRAMEWORK" , open list Subject: Re: [PATCH v2] selftests: KVM: Replace optarg with arg in guest_modes_cmdline Message-ID: <20230202081057.nanfjavyy2l4pswc@orel> References: <20230202025716.216323-1-shahuang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230202025716.216323-1-shahuang@redhat.com> X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 02, 2023 at 10:57:15AM +0800, shahuang@redhat.com wrote: > From: Shaoqin Huang > > The parameter arg in guest_modes_cmdline not being used now, and the > optarg should be replaced with arg in guest_modes_cmdline. > > And this is the chance to change strtoul() to atoi_non_negative(), since > guest mode ID will never be negative. Fixes: e42ac777d661 ("KVM: selftests: Factor out guest mode code") > > Signed-off-by: Shaoqin Huang > > --- > Changes from v1: > - Change strtoul() to atoi_non_negative(). [Vipin] > > --- > tools/testing/selftests/kvm/lib/guest_modes.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kvm/lib/guest_modes.c b/tools/testing/selftests/kvm/lib/guest_modes.c > index 99a575bbbc52..1df3ce4b16fd 100644 > --- a/tools/testing/selftests/kvm/lib/guest_modes.c > +++ b/tools/testing/selftests/kvm/lib/guest_modes.c > @@ -127,7 +127,7 @@ void guest_modes_cmdline(const char *arg) > mode_selected = true; > } > > - mode = strtoul(optarg, NULL, 10); > + mode = atoi_non_negative("Guest mode ID", arg); > TEST_ASSERT(mode < NUM_VM_MODES, "Guest mode ID %d too big", mode); > guest_modes[mode].enabled = true; > } > -- > 2.39.0 > Reviewed-by: Andrew Jones