New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rgw: Initializes uninitialized members #16855
Conversation
src/rgw/rgw_file.h
Outdated
@@ -91,7 +91,7 @@ namespace rgw { | |||
*/ | |||
struct fh_key | |||
{ | |||
rgw_fh_hk fh_hk; | |||
rgw_fh_hk fh_hk {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a constructor in rgw_fh_hk
that accepts an integer to do this change.
Otherwise, it should be like this: http://en.cppreference.com/w/cpp/language/value_initialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Thanks for comment.
I believe something as:
rgw_fh_hk fh_hk {};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Can you please respond
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think rgw_fh_hk fh_hk {};
is good here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbodley Yes, I meant the same. Thanks.
src/rgw/rgw_common.h
Outdated
@@ -1197,7 +1197,7 @@ struct RGWBucketInfo | |||
bool has_website; | |||
RGWBucketWebsiteConf website_conf; | |||
|
|||
RGWBucketIndexType index_type; | |||
RGWBucketIndexType index_type = RGWBIType_Indexless; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why RGWBIType_Indexless
? Any justification ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Here is what i interpreted
Inside decode function
void decode(bufferlist::iterator& bl){
if (struct_v >= 15) {
uint32_t it;
::decode(it, bl);
index_type = (RGWBucketIndexType)it; //This would be decoded. We can consider would be valid index not Indexless
} else {
index_type = RGWBIType_Normal; //says normal Index
}
}
So I feel Indexless is bad case here. But your opinion would be valuable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Can you please provide feedback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Can you please respond??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RGWBIType_Normal
is probably a better default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbodley I also think RGWBIType_Normal
is the default value, considering the above decode()
logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin can you please comment on my comments..
src/rgw/rgw_common.h
Outdated
@@ -1197,7 +1197,7 @@ struct RGWBucketInfo | |||
bool has_website; | |||
RGWBucketWebsiteConf website_conf; | |||
|
|||
RGWBucketIndexType index_type; | |||
RGWBucketIndexType index_type = RGWBIType_Indexless; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Here is what i interpreted
Inside decode function
void decode(bufferlist::iterator& bl){
if (struct_v >= 15) {
uint32_t it;
::decode(it, bl);
index_type = (RGWBucketIndexType)it; //This would be decoded. We can consider would be valid index not Indexless
} else {
index_type = RGWBIType_Normal; //says normal Index
}
}
So I feel Indexless is bad case here. But your opinion would be valuable.
src/rgw/rgw_file.h
Outdated
@@ -91,7 +91,7 @@ namespace rgw { | |||
*/ | |||
struct fh_key | |||
{ | |||
rgw_fh_hk fh_hk; | |||
rgw_fh_hk fh_hk {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joscollin Thanks for comment.
I believe something as:
rgw_fh_hk fh_hk {};
src/rgw/rgw_common.h
Outdated
@@ -1197,7 +1197,7 @@ struct RGWBucketInfo | |||
bool has_website; | |||
RGWBucketWebsiteConf website_conf; | |||
|
|||
RGWBucketIndexType index_type; | |||
RGWBucketIndexType index_type = RGWBIType_Indexless; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbodley I also think RGWBIType_Normal
is the default value, considering the above decode()
logic.
src/rgw/rgw_file.h
Outdated
@@ -91,7 +91,7 @@ namespace rgw { | |||
*/ | |||
struct fh_key | |||
{ | |||
rgw_fh_hk fh_hk; | |||
rgw_fh_hk fh_hk {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cbodley Yes, I meant the same. Thanks.
9f95b25
to
4bca8f8
Compare
@joscollin Done changes. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes the coverity issues: ** 1352181 Uninitialized scalar field 2. uninit_member: Non-static class member field fh_hk.bucket is not initialized in this constructor nor in any functions that it calls. CID 1352181 (ceph#1 of 1): Uninitialized scalar field (UNINIT_CTOR) 4. uninit_member: Non-static class member field fh_hk.object is not initialized in this constructor nor in any functions that it calls. ** 1353424 Uninitialized scalar field CID 1353424 (ceph#1 of 1): Uninitialized scalar field (UNINIT_CTOR) 5. uninit_member: Non-static class member watch_handle is not initialized in this constructor nor in any functions that it calls. ** 1355240 Uninitialized scalar field CID 1355240 (ceph#1 of 1): Uninitialized scalar field (UNINIT_CTOR) 2. uninit_member: Non-static class member index_type is not initialized in this constructor nor in any functions that it calls. Signed-off-by: Amit Kumar <amitkuma@redhat.com>
Fixes the coverity issues:
** 1352181 Uninitialized scalar field
2. uninit_member: Non-static class member field fh_hk.bucket is
not initialized in this constructor nor in any functions that it calls.
CID 1352181 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
4. uninit_member: Non-static class member field fh_hk.object is
not initialized in this constructor nor in any functions that it calls.
** 1353424 Uninitialized scalar field
CID 1353424 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
5. uninit_member: Non-static class member watch_handle is not initialized
in this constructor nor in any functions that it calls.
** 1355240 Uninitialized scalar field
CID 1355240 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
2. uninit_member: Non-static class member index_type is not initialized
in this constructor nor in any functions that it calls.
Signed-off-by: Amit Kumar amitkuma@redhat.com