On 2022-04-27 19:49, Guoqing Jiang wrote:
It's standard practice to annotate small functions in headers with
On 4/28/22 12:07 AM, Logan Gunthorpe wrote:
On 2022-04-26 19:28, Guoqing Jiang wrote:Thanks for the link, then I suppose those can be deleted
Marking static functions in C files as inline is not recommended. GCC+static bool ahead_of_reshape(struct mddev *mddev, sector_t sector,I think it can be an inline function.
+ sector_t reshape_sector)
+{
+ if (mddev->reshape_backwards)
+ return sector < reshape_sector;
+ else
+ return sector >= reshape_sector;
+}
will inline it, if it is appropriate.
https://yarchive.net/comp/linux/inline.html
https://www.kernel.org/doc/local/inline.html
linux> grep "static inline" drivers/md/md.h -r
"static inline". Without the inline annotation, any C file that includes
the header and doesn't use the function will emit a "defined but not
used warning".
Functions in headers also should, by definition, be small and
specifically inline-able (ie they are used as a type-safe macro).
static functions in C files (not headers) should not have the inline
keyword as GCC can optimize them and inline them as it sees fit and the
inline keyword doesn't actually do anything.