Skip to contentSkip to conversation

cachefiles: remove always false 'datalen < 0' expression

PATCH In review Austin Kim 1 participant 2 messages Aug 24, 2021 – Nov 3, 2021 Cachefiles: fs-cache backend for caching on mounted filesystems

lore
Share & tools
lore

Austin Kim

author
#0 lore raw

PATCH 1/1 cachefiles: remove always false 'datalen < 0' expression

From: Austin Kim <[email protected]>

Since 'datalen' is declared as size_t, the 'datalen < 0' expression is always false. Where size_t is defined as below;

typedef unsigned long __kernel_ulong_t;
typedef __kernel_ulong_t __kernel_size_t;
typedef __kernel_size_t size_t;

So it had better remove unnecessary 'always false' expression.

---
 fs/cachefiles/daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cachefiles/daemon.c +1 -1
index 752c1e43416f..1cfed9e0812a 100644
@@ -225,7 +225,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 */
Signature · 1 line
2.20.1
author
#1 lore raw

2021년 8월 24일 (화) 오후 12:18, Austin Kim <[email protected]>님이 작성:

Quoted 31 lines

From: Austin Kim <[email protected]>

Since 'datalen' is declared as size_t, the 'datalen < 0' expression is always false. Where size_t is defined as below;

   typedef unsigned long __kernel_ulong_t;
   typedef __kernel_ulong_t __kernel_size_t;
   typedef __kernel_size_t size_t;

So it had better remove unnecessary 'always false' expression.

---
 fs/cachefiles/daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cachefiles/daemon.c +1 -2
index 752c1e43416f..1cfed9e0812a 100644
@@ -225,7 +225,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 */
--
Quoted 2 lines

2.20.1

If you are available, would you please review this patch? It will not take long.

BR,
Austin Kim