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
Fixes for issues found during SCA #21419
Conversation
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/librbd/api/Image.cc
Outdated
@@ -274,6 +274,7 @@ int Image<I>::deep_copy(I *src, librados::IoCtx& dest_md_ctx, | |||
r = dest->state->open(false); | |||
if (r < 0) { | |||
lderr(cct) << "failed to read newly created header" << dendl; | |||
delete dest; |
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.
👎 -- ImageState::open
will automatically delete the ImageCtx
upon failure [1]
[1] https://github.com/ceph/ceph/blob/master/src/librbd/ImageState.cc#L254
src/librbd/internal.cc
Outdated
@@ -1772,6 +1772,7 @@ bool compare_by_name(const child_info_t& c1, const child_info_t& c2) | |||
r = dest->state->open(false); | |||
if (r < 0) { | |||
lderr(cct) << "failed to read newly created header" << dendl; | |||
delete dest; |
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.
👎 -- ImageState::open
will automatically delete the ImageCtx
upon failure [1]
[1] https://github.com/ceph/ceph/blob/master/src/librbd/ImageState.cc#L254
src/client/hypertable/CephBroker.cc
Outdated
@@ -200,22 +200,22 @@ void CephBroker::read(ResponseCallbackRead *cb, uint32_t fd, uint32_t amount) { | |||
|
|||
if (!m_open_file_map.get(fd, fdata)) { | |||
char errbuf[32]; | |||
sprintf(errbuf, "%d", fd); | |||
sprintf(errbuf, "%u", fd); |
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.
we'd better to print an uint32_t using the macro of PRIu32
instead of %u
, which works on platforms with 32bit integers but not on some other platforms.
src/common/TrackedOp.cc
Outdated
@@ -152,7 +152,7 @@ OpTracker::OpTracker(CephContext *cct_, bool tracking, uint32_t num_shards): | |||
lock("OpTracker::lock"), cct(cct_) { | |||
for (uint32_t i = 0; i < num_optracker_shards; i++) { | |||
char lock_name[32] = {0}; | |||
snprintf(lock_name, sizeof(lock_name), "%s:%d", "OpTracker::ShardedLock", i); | |||
snprintf(lock_name, sizeof(lock_name), "%s:%u", "OpTracker::ShardedLock", i); |
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.
use PRIu32 if you please.
src/osd/OSD.h
Outdated
@@ -1733,7 +1733,7 @@ class OSD : public Dispatcher, | |||
auto &&sdata = osd->shards[i]; | |||
|
|||
char queue_name[32] = {0}; | |||
snprintf(queue_name, sizeof(queue_name), "%s%d", "OSD:ShardedOpWQ:", i); | |||
snprintf(queue_name, sizeof(queue_name), "%s%u", "OSD:ShardedOpWQ:", i); |
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.
PRIu32
src/msg/async/EventKqueue.cc
Outdated
sizeof(struct SaveEvent)*newsize); | ||
if (!sav_events) { | ||
void *_realloc = NULL; | ||
if ((_realloc = realloc(sav_events, izeof(struct SaveEvent)*newsize)) == NULL) { |
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.
s/izeof/sizeof/, could use "if with initialization" introduced by C++17, like
if (void* new_events = realloc(sav_events, sizeof(struct SaveEvent)*newsize)); !new_events) {
lderr(cct) << __func__ << " unable to realloc memory: "
<< cpp_strerror(errno) << dendl;
free(sav_events);
return -ENOMEM;
} else {
sav_events = new_events;
}
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.
Strange, it compiled here fine.
src/rgw/rgw_common.h
Outdated
@@ -1048,7 +1048,7 @@ struct rgw_bucket { | |||
uint64_t id; | |||
decode(id, bl); | |||
char buf[16]; | |||
snprintf(buf, sizeof(buf), "%llu", (long long)id); | |||
snprintf(buf, sizeof(buf), "%" PRIu64 , id); |
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.
remove the space before ","
src/client/hypertable/CephBroker.cc
Outdated
cb->error(Error::DFSBROKER_BAD_FILE_HANDLE, errbuf); | ||
return; | ||
} | ||
|
||
int r; | ||
if ((r = ceph_fsync(cmount, fdata->fd, true)) != 0) { | ||
std::string errs(cpp_strerror(r)); | ||
HT_ERRORF("flush failed: fd=%d ceph_fd=%d - %s", fd, fdata->fd, errs.c_str()); | ||
HT_ERRORF("flush failed: fd=%lu ceph_fd=%d - %s", (Lu)fd, fdata->fd, errs.c_str()); |
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.
PRIu32
src/client/hypertable/CephBroker.cc
Outdated
|
||
if (!m_open_file_map.get(fd, fdata)) { | ||
char errbuf[32]; | ||
sprintf(errbuf, "%d", fd); | ||
sprintf(errbuf, "%u", fd); |
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.
PRIu32
src/client/hypertable/CephBroker.cc
Outdated
@@ -409,19 +409,19 @@ int CephBroker::rmdir_recursive(const char *directory) { | |||
void CephBroker::flush(ResponseCallback *cb, uint32_t fd) { | |||
OpenFileDataCephPtr fdata; | |||
|
|||
HT_DEBUGF("flush fd=%d", fd); | |||
HT_DEBUGF("flush fd=%lu", (Lu)fd); |
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.
PRIu32
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 can do that, but this needs changes in more than these places since this kind of code is already used a lot in the file.
src/rgw/rgw_website.cc
Outdated
@@ -94,6 +94,7 @@ bool RGWBucketWebsiteConf::should_redirect(const string& key, const int http_err | |||
RGWBWRoutingRule redirect_all_rule; | |||
redirect_all_rule.redirect_info.redirect = redirect_all; | |||
redirect_all.http_redirect_code = 301; | |||
redirect_all_rule.condition = {}; |
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.
can you please move this fix into the condition itself?
struct RGWBWRoutingRuleCondition
{
std::string key_prefix_equals;
- uint16_t http_error_code_returned_equals;
+ uint16_t http_error_code_returned_equals = 0;
48aba5b
to
eaf4dcf
Compare
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Co-authored-by: Casey Bodley <cbodley@redhat.com> Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for: [src/compressor/lz4/LZ4Compressor.h:105]: (style) Condition 'r!=(int)compressed_pairs[i].first' is always true Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix for: [src/krbd.cc:549]: (portability) Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
eaf4dcf
to
0c478d7
Compare
make check failed ... looks like an issue with the agent: "Agent went offline during the build" |
i guess the "make check" timed out. retest this please |
Seems to work now. |
@dalgaaf please note, we use ceph/ceph for "official" branches, like jewel, luminous, mimic, and it's advised to send PRs from our own repos instead. |
Fixes for: