Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2721738rwb; Mon, 7 Nov 2022 17:23:59 -0800 (PST) X-Google-Smtp-Source: AMsMyM5CAu4Yu3cWyz5bMSCqUXY+c1FKxoo/dG+6p78d9WVeV/y2fibxcWF+njdseRPi++8rSGez X-Received: by 2002:a17:906:6b90:b0:7ad:b6d3:3394 with SMTP id l16-20020a1709066b9000b007adb6d33394mr46922289ejr.497.1667870639428; Mon, 07 Nov 2022 17:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667870639; cv=none; d=google.com; s=arc-20160816; b=wcFrRRWVfLDccj8Zq3c+/SuKJt2kaY+8J3rJvtFabhK9DYqNjRnTBwVum+xH9sMBMq xGi95wMHLTzuJqsG5Jcko6/NrZ1W7fkWePWluvq2xi0J6+l5B+XyC5ABTDvIv+4d+PBF kXki9J8n7if596uVFDi71axFlInXmzGPMV0BPEou8Ln+HeHRdyykpo7GNN5ncIMEXqcz oGABbDMHQnGKuNs5iHJbzr1+GFyVrapCbj1c3Xy6AzsPqPmpk9mXqE7QBNHgXOG6I6IH wu5ADGFV7/x7EolvCdCzk7gwPOji8ENjUmMHd0Uxt5Z/vv7PU5MBpMi1Fc0h2kpnBIx5 Ue5A== 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-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=GwrfcPLWegZuEEj6CKXHwu1qKx5JNoa40Mx3JbzZqAQ=; b=LIROLolN1QI+X/IsMOZJQmSx+4Q3LBvlFs7Yib6B51gSkbAqcN6PN+Q/s+SyCMTL+h FnDcQJN3aUsX3X8/Ks3CC3A7tvPd2ABCmEpwZLWhlcuBkjFzCTHzD8ouHFFiK48nFMYI NBjolq1hIBsWSzlG0d4BN3JEXUIYiYXB+I2MlACLw2KZL3472aE/N8p1eyiiTO/ebt4v NZLugA/O/p/jI3p7PVy6q/MpskbexOi+YbMw0yTa8e5HhPlgMRCn01i5W9ZLO3t1XNEO I+gmgg+KxB/fm9KzsPBgFwZ8i8EQhlsXjVFuHcLGKl1+JzfEsuKPBCJ2K/4Wol1MD7tM Wo4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=B7ri3UCt; 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 z17-20020a05640240d100b004631c0f4612si12836942edb.555.2022.11.07.17.23.37; Mon, 07 Nov 2022 17:23:59 -0800 (PST) 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=B7ri3UCt; 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 S233230AbiKHBA7 (ORCPT + 91 others); Mon, 7 Nov 2022 20:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233299AbiKHBAq (ORCPT ); Mon, 7 Nov 2022 20:00:46 -0500 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC6020BF6; Mon, 7 Nov 2022 17:00:45 -0800 (PST) Date: Mon, 7 Nov 2022 17:00:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1667869243; 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=GwrfcPLWegZuEEj6CKXHwu1qKx5JNoa40Mx3JbzZqAQ=; b=B7ri3UCtv3d9fm2jpYiLnPJPeUql2n6CDoGeYOaKmhurHDVulZvaXfdl9zcXOySTiQXpdl 3NBMoukjfCAUQPIHFGwBdG4Y6Z1OICOr5yjOAtskNfzQJixSbkIep7zDd6HOK5TlhDDwYo 7Edd6tBQzP3ulK36p3Y6KEKHG2aK06o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: YueHaibing Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, shuah@kernel.org, yosryahmed@google.com, shakeelb@google.com, rientjes@google.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests: cgroup: Fix unsigned comparison with less than zero Message-ID: References: <20221105110611.28920-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221105110611.28920-1-yuehaibing@huawei.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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 On Sat, Nov 05, 2022 at 07:06:11PM +0800, YueHaibing wrote: > 'size' is unsigned, it never less than zero. > > Fixes: 6c26df84e1f2 ("selftests: cgroup: return -errno from cg_read()/cg_write() on failure") > Signed-off-by: YueHaibing > --- > tools/testing/selftests/cgroup/cgroup_util.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c > index 4c52cc6f2f9c..e8bbbdb77e0d 100644 > --- a/tools/testing/selftests/cgroup/cgroup_util.c > +++ b/tools/testing/selftests/cgroup/cgroup_util.c > @@ -555,6 +555,7 @@ int proc_mount_contains(const char *option) > ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t size) > { > char path[PATH_MAX]; > + ssize_t ret; > > if (!pid) > snprintf(path, sizeof(path), "/proc/%s/%s", > @@ -562,8 +563,8 @@ ssize_t proc_read_text(int pid, bool thread, const char *item, char *buf, size_t > else > snprintf(path, sizeof(path), "/proc/%d/%s", pid, item); > > - size = read_text(path, buf, size); > - return size < 0 ? -1 : size; > + ret = read_text(path, buf, size); > + return ret < 0 ? -1 : ret; > } Indeed, good catch! Acked-by: Roman Gushchin Thanks!