Skip to content

Commit 8829554

Browse files
committed
src: resolve various cov-scan warnings
pdu_processor_init: CID 1635250: (#1 of 1): Using a moved object (USE_AFTER_MOVE) 3. return_with_moved_parameter: Returning while reference parameter names is in a moved state. do_perftest: CID 1635246: (#2 of 2): Division or modulo by zero (DIVIDE_BY_ZERO) 4. divide_by_zero: In function call operator /, division by expression fcount which may be zero has undefined behavior. timeindex_delete: CID 1635249: (#1 of 1): Use of auto that causes a copy (AUTO_CAUSES_COPY) auto_causes_copy: Using the auto keyword without an & causes the copy of an object of type std::string. [False positive; there is copy elision happening here.] oxcmail_export: CID 1635241: (#1 of 1): Unchecked return value (CHECKED_RETURN) 106. check_return: Calling set_field without checking return value (as is done elsewhere 56 out of 70 times). mt2exm: CID 1635240: (#2 of 2): Using a moved object (USE_AFTER_MOVE) 19. use_after_move: digest is used after it has been already moved.
1 parent 3ceef79 commit 8829554

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

exch/exmdb/common_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4720,7 +4720,7 @@ bool timeindex_delete(sqlite3 *db, uint64_t fid, uint64_t mid)
47204720
{
47214721
if (fid == 0)
47224722
return true;
4723-
auto q = mid == 0 ?
4723+
const auto &q = mid == 0 ?
47244724
fmt::format("DELETE FROM msgtime_index WHERE folder_id={}", fid) :
47254725
fmt::format("DELETE FROM msgtime_index WHERE folder_id={} AND message_id={}", fid, mid);
47264726
return gx_sql_exec(db, q) == SQLITE_OK;

exch/http/pdu_processor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static size_t pdu_processor_ndr_stack_size(NDR_STACK_ROOT *pstack_root, int type
186186

187187
void pdu_processor_init(int connection_num, const char *netbios_name,
188188
const char *dns_name, const char *dns_domain, BOOL header_signing,
189-
size_t max_request_mem, const std::span<const static_module> &names)
189+
size_t max_request_mem, std::span<const static_module> &&names)
190190
{
191191
static constexpr unsigned int connection_ratio = 10;
192192
union {

exch/http/pdu_processor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct BLOB_NODE {
103103
DATA_BLOB blob;
104104
};
105105

106-
extern void pdu_processor_init(int connection_num, const char *netbios_name, const char *dns_name, const char *dns_domain, BOOL header_signing, size_t max_request_mem, const std::span<const gromox::static_module> &names);
106+
extern void pdu_processor_init(int connection_num, const char *netbios_name, const char *dns_name, const char *dns_domain, BOOL header_signing, size_t max_request_mem, std::span<const gromox::static_module> &&names);
107107
extern int pdu_processor_run();
108108
extern void pdu_processor_stop();
109109
extern std::unique_ptr<PDU_PROCESSOR> pdu_processor_create(const char *host, uint16_t tcp_port);

lib/mapi/oxcmail.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3619,7 +3619,8 @@ static BOOL oxcmail_export_mail_head(const MESSAGE_CONTENT *pmsg,
36193619
if (str != nullptr && !phead->set_field("Content-Location", str))
36203620
return FALSE;
36213621

3622-
phead->set_field("X-Mailer", "gromox-oxcmail " PACKAGE_VERSION);
3622+
if (!phead->set_field("X-Mailer", "gromox-oxcmail " PACKAGE_VERSION))
3623+
/* ignore */;
36233624
auto guid = PS_INTERNET_HEADERS;
36243625
for (size_t i = 0; i < pmsg->proplist.count; ++i) {
36253626
auto proptag = pmsg->proplist.ppropval[i].proptag;

tools/mbop_locale.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ static void do_perftest(const char *lang)
3535
auto delta = now - t_start;
3636
if (delta < std::chrono::seconds(1))
3737
continue;
38+
if (fcount == 0)
39+
fcount = 1; /* calm static-analyzer */
3840
auto d = std::chrono::duration_cast<std::chrono::microseconds>(delta) / fcount;
3941
fprintf(stderr, "\r\e[2K%llu µs\e[K", static_cast<unsigned long long>(d.count()));
4042
t_start = now;

tools/mt2exm.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static int exm_folder(const ob_desc &obd, TPROPVAL_ARRAY &props,
380380
}
381381

382382
static int exm_create_msg(uint64_t parent_fld, MESSAGE_CONTENT *ctnt,
383-
const std::string &im_repr, Json::Value &&digest)
383+
const std::string &im_repr, Json::Value &digest)
384384
{
385385
uint64_t msg_id = 0, change_num = 0;
386386
if (!exmdb_client->allocate_message_id(g_storedir, parent_fld, &msg_id)) {
@@ -421,6 +421,7 @@ static int exm_create_msg(uint64_t parent_fld, MESSAGE_CONTENT *ctnt,
421421
return -EIO;
422422
}
423423
auto djson = json_to_str(digest);
424+
digest["file"].clear();
424425

425426
uint64_t outmid = 0, outcn = 0;
426427
if (!exmdb_client->write_message(g_storedir, CP_UTF8, parent_fld,
@@ -562,7 +563,7 @@ static int exm_message(const ob_desc &obd, MESSAGE_CONTENT &ctnt,
562563
if (i > 0 && i % 1024 == 0)
563564
fprintf(stderr, "mt2exm repeat %u/%u\n", i, g_repeat_iter);
564565
auto ret = exm_create_msg(folder_it->second.fid_to,
565-
&ctnt, im_repr, std::move(digest));
566+
&ctnt, im_repr, digest);
566567
if (ret != EXIT_SUCCESS)
567568
return ret;
568569
}

0 commit comments

Comments
 (0)