Re: [PATCH] ceph: fix clang warning for CEPH_DEFINE_OID_ONSTACK

From: Arnd Bergmann
Date: Fri Mar 22 2019 - 11:08:11 EST


On Fri, Mar 22, 2019 at 3:40 PM Ilya Dryomov <idryomov@xxxxxxxxx> wrote:
>
> On Fri, Mar 22, 2019 at 3:08 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> Hi Arnd,
>
> I don't like this because the initialization is no longer contained to
> ceph_oid_init(). Now there are two things to patch instead of one.
>
> How is this going to be fixed in other places?

The only other warning like this that I encountered was in
DECLARE_WAIT_QUEUE_HEAD_ONSTACK().

So far, I have no idea for how to solve it, other than disabling
CONFIG_LOCKDEP when clang is used.

Would you prefer this version?

#define CEPH_OID_INITIALIZER(oid) { .name = (oid).inline_name }
#define CEPH_DEFINE_OID_ONSTACK(oid) \
struct ceph_object_id oid = CEPH_OID_INITIALIZER(oid)

static inline void ceph_oid_init(struct ceph_object_id *oid)
{
*oid = (struct ceph_object_id)CEPH_OID_INITIALIZER(*oid);
}




Arnd