From: nikita Date: Sat, 1 Sep 2007 14:08:30 +0000 (+0000) Subject: container_of0(): recognize IS_ERR(), and do not convert it. That simplies many call... X-Git-Tag: v1_7_0_51~812 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=8fb149a055bf63e1102d0437724a7f5266de912f;p=fs%2Flustre-release.git container_of0(): recognize IS_ERR(), and do not convert it. That simplies many call-sites. --- diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h index 66bf9a8..613d4fb 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) ^ \