lkml.org 
[lkml]   [2020]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[RFC PATCH 36/76] cachefiles: Remove some redundant checks on unsigned values
    From
    Date
    Remove some redundant checks for unsigned values being >= 0.

    Signed-off-by: David Howells <dhowells@redhat.com>
    ---

    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 a39e65d5103b..c89a422fd1d1 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;

    \
     
     \ /
      Last update: 2020-11-20 16:12    [W:4.167 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site