From 8fb149a055bf63e1102d0437724a7f5266de912f Mon Sep 17 00:00:00 2001 From: nikita <nikita> Date: Sat, 1 Sep 2007 14:08:30 +0000 Subject: [PATCH] container_of0(): recognize IS_ERR(), and do not convert it. That simplies many call-sites. --- lnet/include/libcfs/libcfs.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h index 66bf9a8a6f..613d4fb74d 100644 --- a/lnet/include/libcfs/libcfs.h +++ b/lnet/include/libcfs/libcfs.h @@ -44,7 +44,13 @@ #define container_of0(ptr, type, member) \ ({ \ typeof(ptr) __ptr = (ptr); \ - __ptr ? container_of(__ptr, type, member) : NULL; \ + type *__res; \ + \ + if (unlikely(IS_ERR(__ptr) || __ptr == NULL)) \ + __res = (type *)__ptr; \ + else \ + __res = container_of(__ptr, type, member); \ + __res; \ }) /* @@ -225,8 +231,8 @@ do { \ #endif /* !__KERNEL__ */ -/* - * Lustre Error Checksum: calculates checksum +/* + * Lustre Error Checksum: calculates checksum * of Hex number by XORing each bit. */ #define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \ -- GitLab