Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp3008489rwl; Sat, 5 Nov 2022 15:42:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GfB/iFQq3QzY0b1tHqyiDK1hGABvrh1szWIO6twE/cBxUUMfcwwibOXhLRG6/17qcGa84 X-Received: by 2002:a05:6402:d62:b0:460:42c8:fc6d with SMTP id ec34-20020a0564020d6200b0046042c8fc6dmr43093901edb.182.1667688155460; Sat, 05 Nov 2022 15:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667688155; cv=none; d=google.com; s=arc-20160816; b=UEawDCmEiJKwyOih+JaNHd3SOkvkLqE4U0NnGoTKsjZyZscHhWahGQsfAv/hcF8rLt 3zWCZtGxfdmrIqjFVMPkN6ZpFu0aq1gxbNFesiDg/HzmUhLEkb7OGoeFQ0QZvnA5h8X/ WdsxdNWIF9rIWm8uwa1KJJKwtjYRcrzlIk1C1eG6xcGS1bG8Id4liVu3YghcUtiX59Ss J/BW8T66Wjp2/QnRJWEuVHd2FGP2iKo9hhAdHTYSI0spRQo6wTYir/4/oiRHKI1a5t61 Zv6AOd2nmHZkKIi/pzTka5cSjEwLdafc/4JZU0QZ+BXU8OHrIW3nUj6PSPcvJnGR1K5N cEtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CbBRCqYlzL5aIOV/FIaD3IiZ/MIQgFytQcTe8Ul9rWk=; b=hgC6SIGQejXQ2rkbZ88POuzFKOl3TFXiCXHBvYC0PAynO/PwtsMezqW60Ohp1b9OzH opYdnofsD2OpFupewoAetXxppfRT80uLtDAbBkvEch7khUfgoeoURsYkRzgrq7hG+ZuJ d6BKHbmHrdgPCKEdmXJu3piVgW2tX9eI/m8OmU3m8jHYopVT+SUUHx1U5JtaimhzdFH9 fHgOZRyPWn8rN0nFODFQeHmXrQou+BCsZUbEXrUI+p7ozqVVFLay9dsG+6deiQn8Mgh3 oVs4vruU4lUN09MqGk3MclwN4qyKTdqNMbmPYBwTvlP3xm7m+Td7BrRBnBKdBSLqI+Mn Stjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PXiWAzVm; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s3-20020a170906a18300b0073d71124609si2643177ejy.182.2022.11.05.15.42.11; Sat, 05 Nov 2022 15:42:35 -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=@google.com header.s=20210112 header.b=PXiWAzVm; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbiKEWag (ORCPT + 97 others); Sat, 5 Nov 2022 18:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbiKEWae (ORCPT ); Sat, 5 Nov 2022 18:30:34 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49F8F11A00 for ; Sat, 5 Nov 2022 15:30:31 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id o13so4238908ilq.6 for ; Sat, 05 Nov 2022 15:30:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=CbBRCqYlzL5aIOV/FIaD3IiZ/MIQgFytQcTe8Ul9rWk=; b=PXiWAzVmOTq6MGJT16VHLmmAgF9HAeDaUY3bKDIRjX1G2Y65KvekkmTwB3jXjs7l8j 3pwPXGGFlmVDhSaP9TQBDvvS6p+fAWGePMqqaRzzzDXHP3KJe6vIEtBlUYLCnWIeVYWH Ur3sBQPhqJ9Oxf9cpbNiQGJDIzJIItYtzHmtxg3clYTMzc4hOrUKhdgu8eInd8uXzmfA k95eZ9IVCthx6Phbt4Yks+3rpYJa3InS68hKNKmTwEALPL0g5Nml8gTVHzucq3y6Jb8G 14nj2uu2GiE7DWFSSY89/Px2IvRk5FMIk9gai01Ied2ap6Bp2Jba4/6u5484C+uU7lis IzFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CbBRCqYlzL5aIOV/FIaD3IiZ/MIQgFytQcTe8Ul9rWk=; b=rCM5GUViv1j2aitdgmBK5p36HwrDT0HA8HAUyMba1m6kUOjs7caob5EdT8HBbwQaFz u/m7IweBgG61vSL6vQ0L1o4T+eYXCDVnkOYIKhAq/mt4ZdUu/Jbyl65UVxuKAPMo3N98 oBX/aNFHd/wYtKG0o2beXad5ObH+NPhOvKwS7snIBRWmEWx/teDGqWrExp3MHJb7t41f fj6sIL1rzBvKNqk4AGYUr19T4idqWfzYQvQzB7egsPkm0qewUhCoiOf40UXTnYIRhPUQ hXhn0DG9/1fKQzppnVOna6YWpm5IYQiLTEhpie77WiO8UN2Lv42c5J+uYqUcoAcMkdG2 Hz3g== X-Gm-Message-State: ACrzQf3gNTF6rv2SHloXDLjWMDHADctqd2IXbSphkomf5rh/pa5Lb3r9 QFW1FH6zhR4iyWXu1CgG/w6HXGIXxo2peltmWzciVg== X-Received: by 2002:a05:6e02:d49:b0:300:d893:a3f8 with SMTP id h9-20020a056e020d4900b00300d893a3f8mr8609481ilj.53.1667687430424; Sat, 05 Nov 2022 15:30:30 -0700 (PDT) MIME-Version: 1.0 References: <20221105110611.28920-1-yuehaibing@huawei.com> In-Reply-To: <20221105110611.28920-1-yuehaibing@huawei.com> From: Yosry Ahmed Date: Sat, 5 Nov 2022 15:29:54 -0700 Message-ID: Subject: Re: [PATCH] selftests: cgroup: Fix unsigned comparison with less than zero To: YueHaibing Cc: tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org, shuah@kernel.org, roman.gushchin@linux.dev, shakeelb@google.com, rientjes@google.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 5, 2022 at 4:06 AM 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 Thanks for fixing this! FWIW, Reviewed-by: Yosry Ahmed > --- > 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; > } > > int proc_read_strstr(int pid, bool thread, const char *item, const char *needle) > -- > 2.17.1 >