Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3083499pxb; Mon, 18 Oct 2021 07:56:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw71P5UYosKy14W1VcCVEKmv3JwFu2o9J/DCSFCWG7A1DrgxXwc5Jr622A+EJmS356SfO+s X-Received: by 2002:a50:d809:: with SMTP id o9mr44910852edj.149.1634568999996; Mon, 18 Oct 2021 07:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634568999; cv=none; d=google.com; s=arc-20160816; b=T0eMVJYAODnrXzXoshBShzqUMHRY0GUAPrNxQzgFAxA3rEOQFT/E/mvvzKpKWsjpyR JvioRBNNUUwUx5/y2iF/n5Wce239z8xHebq4PyDz7OtunolXG7TBxlOI7EjsTOZ6HFBa 6sljwQfJOsE0XeG8OdC/xEl9k1n7FBHdu69hFVYHnVg2ua6j9ikfvfb8yQ9U/7Jf+ppD 1zPu14m1u1MkQRhlrU4BEhO3/iKtS8i52WSH4RhHYQBPBO0vLD2My+tQBzwThFvS8uk7 8ioZG5L7+Mt7jyN1/fRfVK7dSyEK3u5D3JKjqbpEcrWlxA+Pig4DQiJQZ4NGlPTzAiLY 73Xw== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=fXsphGfG84x/qU401g1UBOIjGC8E9APA4ba1XbVairo=; b=RZCaQerhUNqjI+FjwaNJGErpMxaTIRwARrCxM3b0sVKHXNIUk78vuf/GhdewKnf0aF bhuIIr5yy83rcP9r2GSCjF+lWrIi2v+JwX/16KfXsENDyP6zrrFHhhfGV/O8f8aD22Em TgRA0AtrOT28OHdQs02bSb1hPestwkW3LNYD16IJilmr0L0ECBLLS9QVUJ2pbcl28tDf Y8wylM+0dB+cTg63moSe0p495MuJ05aNSLUKJ4BZnXkk4XMeSe718Qyyb346nZNXBrEI 5jVxVR2Nj+maeHi85wUN6pm36Pwnf/PncusSnMfqtRG97ED39hSTs0auBWB+mDwF0VdI iI+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JNiHB9hV; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si18883131edb.376.2021.10.18.07.56.11; Mon, 18 Oct 2021 07:56:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JNiHB9hV; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232490AbhJRO6U (ORCPT + 99 others); Mon, 18 Oct 2021 10:58:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43340 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232977AbhJRO6N (ORCPT ); Mon, 18 Oct 2021 10:58:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634568961; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fXsphGfG84x/qU401g1UBOIjGC8E9APA4ba1XbVairo=; b=JNiHB9hVH+zW9sJPUSehxcOei+lH8tmB72SW9vyrLvSN+eKxyx3LpnWYXToLt5VRpcJxpG TXz55pOcb3o8XO4vWY/IpATCFzHHjplxweRyswj6pZN9Vt+yESUIAI+GRBFdWDM5aSwyN3 MONevtZR/kFiWjzya6epHpP/K/Pj2aI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-119-TDMc0zyxOESI0WALvBsKvQ-1; Mon, 18 Oct 2021 10:55:58 -0400 X-MC-Unique: TDMc0zyxOESI0WALvBsKvQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1ED1A1006AB3; Mon, 18 Oct 2021 14:55:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A7005DF21; Mon, 18 Oct 2021 14:55:46 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 20/67] cachefiles: Remove some redundant checks on unsigned values From: David Howells To: linux-cachefs@redhat.com Cc: dhowells@redhat.com, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Matthew Wilcox , Alexander Viro , Omar Sandoval , Linus Torvalds , linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 18 Oct 2021 15:55:45 +0100 Message-ID: <163456894569.2614702.11582768897048471845.stgit@warthog.procyon.org.uk> In-Reply-To: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> References: <163456861570.2614702.14754548462706508617.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Remove some redundant checks for unsigned values being >= 0. Signed-off-by: David Howells --- fs/cachefiles/bind.c | 6 ++---- fs/cachefiles/daemon.c | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 6720c07f3d85..0bc748081f59 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c @@ -36,13 +36,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) args); /* start by checking things over */ - ASSERT(cache->fstop_percent >= 0 && - cache->fstop_percent < cache->fcull_percent && + ASSERT(cache->fstop_percent < cache->fcull_percent && cache->fcull_percent < cache->frun_percent && cache->frun_percent < 100); - ASSERT(cache->bstop_percent >= 0 && - cache->bstop_percent < cache->bcull_percent && + ASSERT(cache->bstop_percent < cache->bcull_percent && cache->bcull_percent < cache->brun_percent && cache->brun_percent < 100); diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 8a937d6d5e22..e8ab3ab57147 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -221,7 +221,7 @@ static ssize_t cachefiles_daemon_write(struct file *file, if (test_bit(CACHEFILES_DEAD, &cache->flags)) return -EIO; - if (datalen < 0 || datalen > PAGE_SIZE - 1) + if (datalen > PAGE_SIZE - 1) return -EOPNOTSUPP; /* drag the command string into the kernel so we can parse it */ @@ -378,7 +378,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args) if (args[0] != '%' || args[1] != '\0') return -EINVAL; - if (fstop < 0 || fstop >= cache->fcull_percent) + if (fstop >= cache->fcull_percent) return cachefiles_daemon_range_error(cache, args); cache->fstop_percent = fstop; @@ -450,7 +450,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args) if (args[0] != '%' || args[1] != '\0') return -EINVAL; - if (bstop < 0 || bstop >= cache->bcull_percent) + if (bstop >= cache->bcull_percent) return cachefiles_daemon_range_error(cache, args); cache->bstop_percent = bstop;