From d7999aba5acfdc8b088ad76eb2ad98c12846117a Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Sun, 5 Nov 2023 16:52:30 +0200 Subject: [PATCH] rgw: adding y2k38 annotations to supress coverity issues the supression comments must be directly above the line where the issue is. this is a followup on these commits: edfb5b9049ee897779863d780bfbaa130a7fbc40 aca2668c88a048ab556c53411dcf2ccd43099d50 Signed-off-by: Yuval Lifshitz --- src/rgw/driver/rados/rgw_trim_datalog.cc | 4 ++-- src/rgw/driver/rados/rgw_trim_mdlog.cc | 7 ++++--- src/rgw/rgw_admin.cc | 7 ++++--- src/test/cls_lock/test_cls_lock.cc | 1 + src/test/cls_log/test_cls_log.cc | 2 ++ 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/rgw/driver/rados/rgw_trim_datalog.cc b/src/rgw/driver/rados/rgw_trim_datalog.cc index 12adc6fbaa5..bac0cda8dd6 100644 --- a/src/rgw/driver/rados/rgw_trim_datalog.cc +++ b/src/rgw/driver/rados/rgw_trim_datalog.cc @@ -224,11 +224,11 @@ int DataLogTrimPollCR::operate(const DoutPrefixProvider *dpp) // prevent other gateways from attempting to trim for the duration set_status("acquiring trim lock"); - // interval is a small number and unlikely to overflow - // coverity[store_truncates_time_t:SUPPRESS] yield call(new RGWSimpleRadosLockCR(store->svc()->rados->get_async_processor(), store, rgw_raw_obj(store->svc()->zone->get_zone_params().log_pool, lock_oid), "data_trim", lock_cookie, + // interval is a small number and unlikely to overflow + // coverity[store_truncates_time_t:SUPPRESS] interval.sec())); if (retcode < 0) { // if the lock is already held, go back to sleep and try again later diff --git a/src/rgw/driver/rados/rgw_trim_mdlog.cc b/src/rgw/driver/rados/rgw_trim_mdlog.cc index d97538f9832..5a2e07154d2 100644 --- a/src/rgw/driver/rados/rgw_trim_mdlog.cc +++ b/src/rgw/driver/rados/rgw_trim_mdlog.cc @@ -669,10 +669,11 @@ int MetaTrimPollCR::operate(const DoutPrefixProvider *dpp) // prevent others from trimming for our entire wait interval set_status("acquiring trim lock"); - // interval is a small number and unlikely to overflow - // coverity[store_truncates_time_t:SUPPRESS] yield call(new RGWSimpleRadosLockCR(store->svc()->rados->get_async_processor(), store, - obj, name, cookie, interval.sec())); + obj, name, cookie, + // interval is a small number and unlikely to overflow + // coverity[store_truncates_time_t:SUPPRESS] + interval.sec())); if (retcode < 0) { ldout(cct, 4) << "failed to lock: " << cpp_strerror(retcode) << dendl; continue; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 40146293a2c..ecf16abf2cb 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -3039,19 +3039,20 @@ static int scan_totp(CephContext *cct, ceph::real_time& now, rados::cls::otp::ot uint32_t max_skew = MAX_TOTP_SKEW_HOURS * 3600; while (time_ofs_abs < max_skew) { + // coverity supression: oath_totp_validate2 is an external library function, cannot fix internally + // Further, step_size is a small number and unlikely to overflow int rc = oath_totp_validate2(totp.seed_bin.c_str(), totp.seed_bin.length(), start_time, + // coverity[store_truncates_time_t:SUPPRESS] step_size, time_ofs, 1, nullptr, pins[0].c_str()); if (rc != OATH_INVALID_OTP) { - // oath_totp_validate2 is an external library function, cannot fix internally - // Further, step_size is a small number and unlikely to overflow - // coverity[store_truncates_time_t:SUPPRESS] rc = oath_totp_validate2(totp.seed_bin.c_str(), totp.seed_bin.length(), start_time, + // coverity[store_truncates_time_t:SUPPRESS] step_size, time_ofs - step_size, /* smaller time_ofs moves time forward */ 1, diff --git a/src/test/cls_lock/test_cls_lock.cc b/src/test/cls_lock/test_cls_lock.cc index b915de9c236..ef543ce8647 100644 --- a/src/test/cls_lock/test_cls_lock.cc +++ b/src/test/cls_lock/test_cls_lock.cc @@ -298,6 +298,7 @@ TEST(ClsLock, TestLockDuration) { ASSERT_EQ(-EEXIST, r); } + // coverity[store_truncates_time_t:SUPPRESS] sleep(dur.sec()); ASSERT_EQ(0, l.lock_exclusive(&ioctx, oid)); diff --git a/src/test/cls_log/test_cls_log.cc b/src/test/cls_log/test_cls_log.cc index e8777ac5fed..f8c1a32494a 100644 --- a/src/test/cls_log/test_cls_log.cc +++ b/src/test/cls_log/test_cls_log.cc @@ -79,6 +79,7 @@ void generate_log(librados::IoCtx& ioctx, string& oid, int max, utime_t& start_t int i; for (i = 0; i < max; i++) { + // coverity[store_truncates_time_t:SUPPRESS] uint32_t secs = start_time.sec(); if (modify_time) secs += i; @@ -94,6 +95,7 @@ void generate_log(librados::IoCtx& ioctx, string& oid, int max, utime_t& start_t utime_t get_time(utime_t& start_time, int i, bool modify_time) { + // coverity[store_truncates_time_t:SUPPRESS] uint32_t secs = start_time.sec(); if (modify_time) secs += i; -- 2.39.5