Whamcloud - gitweb
LU-18141 libcfs: don't emit a warning for LIBCFS_FREE(NULL) 50/56050/3
authorTimothy Day <timday@amazon.com>
Wed, 14 Aug 2024 14:02:55 +0000 (10:02 -0400)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 22:07:32 +0000 (22:07 +0000)
There is no need to emit a console message when doing
a LIBCFS_FREE() of NULL. We ought to silently accept
NULL and do nothing.

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: If7217f4791998b15e92485a80b6f2ed051f7eecc
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56050
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
libcfs/include/libcfs/libcfs_private.h

index e1110d7..927e4ae 100644 (file)
@@ -228,16 +228,13 @@ do {                                                                          \
 #define LIBCFS_FREE(ptr, size)                                         \
 do {                                                                   \
        size_t s = (size);                                              \
-       if (unlikely((ptr) == NULL)) {                                  \
-               CERROR("LIBCFS: free NULL '" #ptr "' (%zd bytes) at "   \
-                      "%s:%d\n", s, __FILE__, __LINE__);               \
-               break;                                                  \
+       if (likely(ptr)) {                                              \
+               LIBCFS_FREE_PRE(ptr, (size), "kfreed");                 \
+               if (unlikely(s > LIBCFS_VMALLOC_SIZE))                  \
+                       libcfs_vfree_atomic(ptr);                       \
+               else                                                    \
+                       kfree(ptr);                                     \
        }                                                               \
-       LIBCFS_FREE_PRE(ptr, (size), "kfreed");                         \
-       if (unlikely(s > LIBCFS_VMALLOC_SIZE))                          \
-               libcfs_vfree_atomic(ptr);                               \
-       else                                                            \
-               kfree(ptr);                                             \
 } while (0)
 
 /******************************************************************************/