Commit 0384892c authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Ilya Dryomov

libceph: fix clang warning for CEPH_DEFINE_OID_ONSTACK

clang complains about assigning a variable to itself during the
declaration:

fs/ceph/ioctl.c:187:26: error: variable 'oid' is uninitialized when used within its own initialization [-Werror,-Wuninitialized]
        CEPH_DEFINE_OID_ONSTACK(oid);
                                ^~~
include/linux/ceph/osdmap.h:122:52: note: expanded from macro 'CEPH_DEFINE_OID_ONSTACK'
        struct ceph_object_id oid = CEPH_OID_INIT_ONSTACK(oid)
                              ~~~                         ^~~
include/linux/ceph/osdmap.h:120:29: note: expanded from macro 'CEPH_OID_INIT_ONSTACK'
    ({ ceph_oid_init(&oid); oid; })
                            ^~~

We use this trick in other places, but it is completely unnecessary
here, as we can just use a regular struct initializer.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 16809372
...@@ -110,17 +110,16 @@ struct ceph_object_id { ...@@ -110,17 +110,16 @@ struct ceph_object_id {
int name_len; int name_len;
}; };
#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) static inline void ceph_oid_init(struct ceph_object_id *oid)
{ {
oid->name = oid->inline_name; *oid = (struct ceph_object_id) __CEPH_OID_INITIALIZER(*oid);
oid->name_len = 0;
} }
#define CEPH_OID_INIT_ONSTACK(oid) \
({ ceph_oid_init(&oid); oid; })
#define CEPH_DEFINE_OID_ONSTACK(oid) \
struct ceph_object_id oid = CEPH_OID_INIT_ONSTACK(oid)
static inline bool ceph_oid_empty(const struct ceph_object_id *oid) static inline bool ceph_oid_empty(const struct ceph_object_id *oid)
{ {
return oid->name == oid->inline_name && !oid->name_len; return oid->name == oid->inline_name && !oid->name_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment