Skip to content

Commit 938195d

Browse files
fcneufjengelh
authored andcommitted
zcore: constify a few proptag arrays
1 parent f8704e4 commit 938195d

File tree

6 files changed

+58
-104
lines changed

6 files changed

+58
-104
lines changed

exch/zcore/common_util.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,11 @@ BOOL common_util_verify_columns_and_sorts(
115115
/* Cf. oxomsg_extract_delegate for comments */
116116
bool cu_extract_delegate(message_object *pmessage, std::string &username)
117117
{
118-
uint32_t proptag_buff[4];
119-
PROPTAG_ARRAY tmp_proptags;
120118
TPROPVAL_ARRAY tmp_propvals;
121-
122-
tmp_proptags.count = 4;
123-
tmp_proptags.pproptag = proptag_buff;
124-
proptag_buff[0] = PR_SENT_REPRESENTING_ADDRTYPE;
125-
proptag_buff[1] = PR_SENT_REPRESENTING_EMAIL_ADDRESS;
126-
proptag_buff[2] = PR_SENT_REPRESENTING_SMTP_ADDRESS;
127-
proptag_buff[3] = PR_SENT_REPRESENTING_ENTRYID;
119+
static constexpr proptag_t proptag_buff[] =
120+
{PR_SENT_REPRESENTING_ADDRTYPE, PR_SENT_REPRESENTING_EMAIL_ADDRESS,
121+
PR_SENT_REPRESENTING_SMTP_ADDRESS, PR_SENT_REPRESENTING_ENTRYID};
122+
static constexpr PROPTAG_ARRAY tmp_proptags = {std::size(proptag_buff), deconst(proptag_buff)};
128123
if (!pmessage->get_properties(&tmp_proptags, &tmp_propvals))
129124
return FALSE;
130125
if (0 == tmp_propvals.count) {
@@ -1667,16 +1662,14 @@ static EID_ARRAY *common_util_load_folder_messages(store_object *pstore,
16671662
uint32_t table_id;
16681663
uint32_t row_count;
16691664
TARRAY_SET tmp_set;
1670-
PROPTAG_ARRAY proptags;
16711665
EID_ARRAY *pmessage_ids;
16721666

16731667
if (!exmdb_client::load_content_table(pstore->get_dir(), CP_ACP,
16741668
folder_id, username, TABLE_FLAG_NONOTIFICATIONS,
16751669
nullptr, nullptr, &table_id, &row_count))
16761670
return NULL;
1677-
uint32_t tmp_proptag = PidTagMid;
1678-
proptags.count = 1;
1679-
proptags.pproptag = &tmp_proptag;
1671+
static constexpr proptag_t tmp_proptag[] = {PidTagMid};
1672+
static constexpr PROPTAG_ARRAY proptags = {std::size(tmp_proptag), deconst(tmp_proptag)};
16801673
if (!exmdb_client::query_table(pstore->get_dir(), nullptr, CP_ACP,
16811674
table_id, &proptags, 0, row_count, &tmp_set))
16821675
return NULL;
@@ -1748,11 +1741,11 @@ ec_error_t cu_remote_copy_folder(store_object *src_store, uint64_t folder_id,
17481741
username, TABLE_FLAG_NONOTIFICATIONS, nullptr,
17491742
&table_id, &row_count))
17501743
return ecError;
1751-
uint32_t tmp_proptag = PidTagFolderId;
1752-
tmp_proptags.count = 1;
1753-
tmp_proptags.pproptag = &tmp_proptag;
1744+
1745+
static constexpr proptag_t xb_proptag[] = {PidTagFolderId};
1746+
static constexpr PROPTAG_ARRAY xb_proptags = {std::size(xb_proptag), deconst(xb_proptag)};
17541747
if (!exmdb_client::query_table(src_store->get_dir(), nullptr, CP_ACP,
1755-
table_id, &tmp_proptags, 0, row_count, &tmp_set))
1748+
table_id, &xb_proptags, 0, row_count, &tmp_set))
17561749
return ecError;
17571750
exmdb_client::unload_table(src_store->get_dir(), table_id);
17581751
for (size_t i = 0; i < tmp_set.count; ++i) {

exch/zcore/folder_object.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,18 +631,16 @@ BOOL folder_object::set_permissions(const PERMISSION_SET *pperm_set)
631631
{
632632
uint32_t row_num;
633633
uint32_t table_id;
634-
PROPTAG_ARRAY proptags;
635634
TARRAY_SET permission_set;
636635
PERMISSION_DATA *pperm_data;
637-
static constexpr uint32_t proptag_buff[] = {PR_ENTRYID, PR_MEMBER_ID};
638636

639637
auto pfolder = this;
640638
auto dir = pfolder->pstore->get_dir();
641639
if (!exmdb_client::load_permission_table(dir,
642640
pfolder->folder_id, 0, &table_id, &row_num))
643641
return FALSE;
644-
proptags.count = 2;
645-
proptags.pproptag = deconst(proptag_buff);
642+
static constexpr proptag_t proptag_buff[] = {PR_ENTRYID, PR_MEMBER_ID};
643+
static constexpr PROPTAG_ARRAY proptags = {std::size(proptag_buff), deconst(proptag_buff)};
646644
if (!exmdb_client::query_table(dir, nullptr, CP_ACP,
647645
table_id, &proptags, 0, row_num, &permission_set)) {
648646
exmdb_client::unload_table(dir, table_id);

exch/zcore/icsdownctx_object.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2+
// SPDX-FileCopyrightText: 2021–2024 grommunio GmbH
3+
// This file is part of Gromox.
24
#include <cstdint>
35
#include <cstdlib>
46
#include <cstring>
@@ -278,8 +280,6 @@ BOOL icsdownctx_object::sync_folder_change(BOOL *pb_found,
278280
TPROPVAL_ARRAY *pproplist)
279281
{
280282
auto pctx = this;
281-
PROPTAG_ARRAY proptags;
282-
uint32_t proptag_buff[6];
283283
TPROPVAL_ARRAY tmp_propvals;
284284
static const uint8_t fake_false = false;
285285

@@ -304,14 +304,10 @@ BOOL icsdownctx_object::sync_folder_change(BOOL *pb_found,
304304
if (pvalue == nullptr)
305305
return FALSE;
306306
pproplist->emplace_back(PR_ENTRYID, pvalue);
307-
proptags.count = 6;
308-
proptags.pproptag = proptag_buff;
309-
proptag_buff[0] = PidTagParentFolderId;
310-
proptag_buff[1] = PR_DISPLAY_NAME;
311-
proptag_buff[2] = PR_CONTAINER_CLASS;
312-
proptag_buff[3] = PR_ATTR_HIDDEN;
313-
proptag_buff[4] = PR_EXTENDED_FOLDER_FLAGS;
314-
proptag_buff[5] = PidTagChangeNumber;
307+
static constexpr gromox::proptag_t proptag_buff[] =
308+
{PidTagParentFolderId, PR_DISPLAY_NAME, PR_CONTAINER_CLASS,
309+
PR_ATTR_HIDDEN, PR_EXTENDED_FOLDER_FLAGS, PidTagChangeNumber};
310+
static constexpr PROPTAG_ARRAY proptags = {std::size(proptag_buff), deconst(proptag_buff)};
315311
if (!exmdb_client::get_folder_properties(pctx->pstore->get_dir(), CP_ACP,
316312
fid, &proptags, &tmp_propvals))
317313
return FALSE;

exch/zcore/store_object.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,10 @@ static BOOL store_object_cache_propname(store_object *pstore,
7878
std::unique_ptr<store_object> store_object::create(BOOL b_private,
7979
int account_id, const char *account, const char *dir)
8080
{
81-
uint32_t proptag;
82-
PROPTAG_ARRAY proptags;
81+
static constexpr proptag_t proptag = PR_STORE_RECORD_KEY;
82+
const PROPTAG_ARRAY proptags = {1, deconst(&proptag)};
8383
TPROPVAL_ARRAY propvals;
8484

85-
proptags.count = 1;
86-
proptags.pproptag = &proptag;
87-
proptag = PR_STORE_RECORD_KEY;
8885
if (!exmdb_client::get_store_properties(dir, CP_ACP,
8986
&proptags, &propvals)) {
9087
mlog(LV_ERR, "get_store_properties %s: failed", dir);
@@ -1460,18 +1457,15 @@ BOOL store_object::get_permissions(PERMISSION_SET *pperm_set)
14601457
uint32_t row_num;
14611458
uint32_t table_id;
14621459
TARRAY_SET tmp_set;
1463-
uint32_t tmp_proptag;
1464-
PROPTAG_ARRAY proptags;
14651460
uint64_t folder_id = rop_util_make_eid_ex(1, pstore->b_private ?
14661461
PRIVATE_FID_IPMSUBTREE : PUBLIC_FID_IPMSUBTREE);
14671462

14681463
if (!exmdb_client::load_hierarchy_table(
14691464
pstore->dir, folder_id, NULL, TABLE_FLAG_DEPTH,
14701465
NULL, &table_id, &row_num))
14711466
return FALSE;
1472-
proptags.count = 1;
1473-
proptags.pproptag = &tmp_proptag;
1474-
tmp_proptag = PidTagFolderId;
1467+
static constexpr proptag_t tmp_proptag[] = {PidTagFolderId};
1468+
static constexpr PROPTAG_ARRAY proptags = {std::size(tmp_proptag), deconst(tmp_proptag)};
14751469
if (!exmdb_client::query_table(pstore->dir, nullptr, CP_ACP, table_id,
14761470
&proptags, 0, row_num, &tmp_set))
14771471
return FALSE;

exch/zcore/table_object.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -909,18 +909,15 @@ BOOL table_object::filter_rows(uint32_t count, const RESTRICTION *pres,
909909
{
910910
auto ptable = this;
911911
TARRAY_SET tmp_set{};
912-
uint32_t tmp_proptag;
913912
PROPTAG_ARRAY proptags;
914-
PROPTAG_ARRAY tmp_proptags;
915913

916914
switch (ptable->table_type) {
917915
case zcore_tbltype::attachment: {
918916
auto msg = static_cast<message_object *>(ptable->pparent_obj);
919917
if (!msg->get_attachment_table_all_proptags(&proptags))
920918
return FALSE;
921-
tmp_proptag = PR_ATTACH_DATA_BIN;
922-
tmp_proptags.count = 1;
923-
tmp_proptags.pproptag = &tmp_proptag;
919+
static constexpr proptag_t tmp_proptag[] = {PR_ATTACH_DATA_BIN};
920+
static constexpr PROPTAG_ARRAY tmp_proptags = {std::size(tmp_proptag), deconst(tmp_proptag)};
924921
common_util_reduce_proptags(&proptags, &tmp_proptags);
925922
if (!msg->query_attachment_table(&proptags, ptable->position, INT32_MAX, &tmp_set))
926923
return FALSE;
@@ -960,18 +957,14 @@ BOOL table_object::match_row(BOOL b_forward, const RESTRICTION *pres,
960957
int32_t *pposition)
961958
{
962959
auto ptable = this;
963-
PROPTAG_ARRAY proptags;
964-
uint32_t proptag_buff[2];
965960
TPROPVAL_ARRAY tmp_propvals;
966961

967962
if (ptable->table_id == 0)
968963
return FALSE;
969964
auto pinfo = zs_get_info();
970965
auto username = ptable->pstore->b_private ? nullptr : pinfo->get_username();
971-
proptags.count = 2;
972-
proptags.pproptag = proptag_buff;
973-
proptag_buff[0] = PidTagInstID;
974-
proptag_buff[1] = PidTagInstanceNum;
966+
static constexpr proptag_t proptag_buff[] = {PidTagInstID, PidTagInstanceNum};
967+
static constexpr PROPTAG_ARRAY proptags = {std::size(proptag_buff), deconst(proptag_buff)};
975968
return exmdb_client::match_table(ptable->pstore->get_dir(), username,
976969
pinfo->cpid, ptable->table_id, b_forward,
977970
ptable->position, pres, &proptags, pposition,

exch/zcore/zserver.cpp

Lines changed: 32 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,8 @@ void zs_notification_proc(const char *dir, BOOL b_table, uint32_t notify_id,
288288
uint64_t message_id;
289289
struct pollfd fdpoll;
290290
uint64_t old_parentid;
291-
PROPTAG_ARRAY proptags;
292291
TPROPVAL_ARRAY propvals;
293292
DOUBLE_LIST_NODE *pnode;
294-
uint32_t proptag_buff[2];
295293
ZNOTIFICATION *pnotification;
296294
NEWMAIL_ZNOTIFICATION *pnew_mail;
297295
OBJECT_ZNOTIFICATION *pobj_notify;
@@ -335,10 +333,8 @@ void zs_notification_proc(const char *dir, BOOL b_table, uint32_t notify_id,
335333
if (pbin == nullptr)
336334
return;
337335
pnew_mail->parentid = *pbin;
338-
proptags.count = 2;
339-
proptags.pproptag = proptag_buff;
340-
proptag_buff[0] = PR_MESSAGE_CLASS;
341-
proptag_buff[1] = PR_MESSAGE_FLAGS;
336+
static constexpr proptag_t proptag_buff[] = {PR_MESSAGE_CLASS, PR_MESSAGE_FLAGS};
337+
static constexpr PROPTAG_ARRAY proptags = {std::size(proptag_buff), deconst(proptag_buff)};
342338
if (!exmdb_client::get_message_properties(dir, nullptr, CP_ACP,
343339
message_id, &proptags, &propvals))
344340
return;
@@ -1628,8 +1624,6 @@ ec_error_t zs_createmessage(GUID hsession,
16281624
uint32_t tag_access;
16291625
uint32_t permission;
16301626
uint64_t message_id;
1631-
uint32_t proptag_buff[4];
1632-
PROPTAG_ARRAY tmp_proptags;
16331627
TPROPVAL_ARRAY tmp_propvals;
16341628

16351629
auto pinfo = zs_query_session(hsession);
@@ -1657,12 +1651,11 @@ ec_error_t zs_createmessage(GUID hsession,
16571651
} else {
16581652
tag_access = MAPI_ACCESS_MODIFY | MAPI_ACCESS_READ | MAPI_ACCESS_DELETE;
16591653
}
1660-
tmp_proptags.count = 4;
1661-
tmp_proptags.pproptag = proptag_buff;
1662-
proptag_buff[0] = PR_MESSAGE_SIZE_EXTENDED;
1663-
proptag_buff[1] = PR_STORAGE_QUOTA_LIMIT;
1664-
proptag_buff[2] = PR_ASSOC_CONTENT_COUNT;
1665-
proptag_buff[3] = PR_CONTENT_COUNT;
1654+
1655+
static constexpr proptag_t proptag_buff[] =
1656+
{PR_MESSAGE_SIZE_EXTENDED, PR_STORAGE_QUOTA_LIMIT,
1657+
PR_ASSOC_CONTENT_COUNT, PR_CONTENT_COUNT};
1658+
static constexpr PROPTAG_ARRAY tmp_proptags = {std::size(proptag_buff), deconst(proptag_buff)};
16661659
if (!pstore->get_properties(&tmp_proptags, &tmp_propvals))
16671660
return ecError;
16681661
auto num = tmp_propvals.get<const uint32_t>(PR_STORAGE_QUOTA_LIMIT);
@@ -1710,8 +1703,6 @@ ec_error_t zs_deletemessages(GUID hsession, uint32_t hfolder,
17101703
uint32_t permission;
17111704
uint64_t message_id;
17121705
MESSAGE_CONTENT *pbrief;
1713-
uint32_t proptag_buff[2];
1714-
PROPTAG_ARRAY tmp_proptags;
17151706
TPROPVAL_ARRAY tmp_propvals;
17161707
bool notify_non_read = flags & GX_DELMSG_NOTIFY_UNREAD;
17171708

@@ -1770,10 +1761,10 @@ ec_error_t zs_deletemessages(GUID hsession, uint32_t hfolder,
17701761
if (!b_owner)
17711762
continue;
17721763
}
1773-
tmp_proptags.count = 2;
1774-
tmp_proptags.pproptag = proptag_buff;
1775-
proptag_buff[0] = PR_NON_RECEIPT_NOTIFICATION_REQUESTED;
1776-
proptag_buff[1] = PR_READ;
1764+
static constexpr proptag_t proptag_buff[] =
1765+
{PR_NON_RECEIPT_NOTIFICATION_REQUESTED, PR_READ};
1766+
static constexpr PROPTAG_ARRAY tmp_proptags =
1767+
{std::size(proptag_buff), deconst(proptag_buff)};
17771768
if (!exmdb_client::get_message_properties(pstore->get_dir(),
17781769
nullptr, CP_ACP, i_eid, &tmp_proptags, &tmp_propvals))
17791770
return ecError;
@@ -1922,10 +1913,8 @@ ec_error_t zs_setreadflags(GUID hsession, uint32_t hfolder,
19221913
uint64_t folder_id;
19231914
TARRAY_SET tmp_set;
19241915
uint64_t message_id;
1925-
uint32_t tmp_proptag;
19261916
BOOL b_notify = TRUE; /* TODO: Read from config or USER_INFO. */
19271917
BINARY_ARRAY tmp_bins;
1928-
PROPTAG_ARRAY proptags;
19291918
PROBLEM_ARRAY problems;
19301919
MESSAGE_CONTENT *pbrief;
19311920
TPROPVAL_ARRAY propvals;
@@ -1955,9 +1944,9 @@ ec_error_t zs_setreadflags(GUID hsession, uint32_t hfolder,
19551944
pfolder->folder_id, username, TABLE_FLAG_NONOTIFICATIONS,
19561945
&restriction, nullptr, &table_id, &row_count))
19571946
return ecError;
1958-
proptags.count = 1;
1959-
proptags.pproptag = &tmp_proptag;
1960-
tmp_proptag = PR_ENTRYID;
1947+
1948+
static constexpr proptag_t tmp_proptag[] = {PR_ENTRYID};
1949+
static constexpr PROPTAG_ARRAY proptags = {std::size(tmp_proptag), deconst(tmp_proptag)};
19611950
if (!exmdb_client::query_table(pstore->get_dir(), username,
19621951
CP_ACP, table_id, &proptags, 0, row_count, &tmp_set)) {
19631952
exmdb_client::unload_table(pstore->get_dir(), table_id);
@@ -3356,8 +3345,6 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
33563345
zs_objtype mapi_type;
33573346
uint16_t rcpt_num;
33583347
char command_buff[1024];
3359-
uint32_t proptag_buff[6];
3360-
PROPTAG_ARRAY tmp_proptags;
33613348
TPROPVAL_ARRAY tmp_propvals;
33623349

33633350
auto pinfo = zs_query_session(hsession);
@@ -3388,10 +3375,9 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
33883375
if (rcpt_num > g_max_rcpt)
33893376
return ecTooManyRecips;
33903377

3391-
tmp_proptags.count = 1;
3392-
tmp_proptags.pproptag = proptag_buff;
3393-
proptag_buff[0] = PR_ASSOCIATED;
3394-
if (!pmessage->get_properties(&tmp_proptags, &tmp_propvals))
3378+
static constexpr proptag_t proptag_buff1[] = {PR_ASSOCIATED};
3379+
static constexpr PROPTAG_ARRAY tmp_proptags1 = {std::size(proptag_buff1), deconst(proptag_buff1)};
3380+
if (!pmessage->get_properties(&tmp_proptags1, &tmp_propvals))
33953381
return ecError;
33963382
auto flag = tmp_propvals.get<const uint8_t>(PR_ASSOCIATED);
33973383
/* FAI message cannot be sent */
@@ -3417,12 +3403,11 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
34173403
repr_grant >= repr_grant::send_as);
34183404
if (err != ecSuccess)
34193405
return err;
3420-
tmp_proptags.count = 3;
3421-
tmp_proptags.pproptag = proptag_buff;
3422-
proptag_buff[0] = PR_MAX_SUBMIT_MESSAGE_SIZE;
3423-
proptag_buff[1] = PR_PROHIBIT_SEND_QUOTA;
3424-
proptag_buff[2] = PR_MESSAGE_SIZE_EXTENDED;
3425-
if (!pstore->get_properties(&tmp_proptags, &tmp_propvals))
3406+
static constexpr proptag_t proptag_buff2[] =
3407+
{PR_MAX_SUBMIT_MESSAGE_SIZE, PR_PROHIBIT_SEND_QUOTA, PR_MESSAGE_SIZE_EXTENDED};
3408+
static const PROPTAG_ARRAY tmp_proptags2 =
3409+
{std::size(proptag_buff2), deconst(proptag_buff2)};
3410+
if (!pstore->get_properties(&tmp_proptags2, &tmp_propvals))
34263411
return ecError;
34273412

34283413
auto sendquota = tmp_propvals.get<uint32_t>(PR_PROHIBIT_SEND_QUOTA);
@@ -3436,15 +3421,14 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
34363421
ssize_t max_length = -1;
34373422
if (num != nullptr)
34383423
max_length = *num;
3439-
tmp_proptags.count = 6;
3440-
tmp_proptags.pproptag = proptag_buff;
3441-
proptag_buff[0] = PR_MESSAGE_SIZE;
3442-
proptag_buff[1] = PR_MESSAGE_FLAGS;
3443-
proptag_buff[2] = PR_DEFERRED_SEND_TIME;
3444-
proptag_buff[3] = PR_DEFERRED_SEND_NUMBER;
3445-
proptag_buff[4] = PR_DEFERRED_SEND_UNITS;
3446-
proptag_buff[5] = PR_DELETE_AFTER_SUBMIT;
3447-
if (!pmessage->get_properties(&tmp_proptags, &tmp_propvals))
3424+
3425+
static constexpr proptag_t proptag_buff3[] =
3426+
{PR_MESSAGE_SIZE, PR_MESSAGE_FLAGS, PR_DEFERRED_SEND_TIME,
3427+
PR_DEFERRED_SEND_NUMBER, PR_DEFERRED_SEND_UNITS,
3428+
PR_DELETE_AFTER_SUBMIT};
3429+
static constexpr PROPTAG_ARRAY tmp_proptags3 =
3430+
{std::size(proptag_buff3), deconst(proptag_buff3)};
3431+
if (!pmessage->get_properties(&tmp_proptags3, &tmp_propvals))
34483432
return ecError;
34493433
num = tmp_propvals.get<uint32_t>(PR_MESSAGE_SIZE);
34503434
if (num == nullptr)
@@ -4784,8 +4768,6 @@ ec_error_t zs_importreadstates(GUID hsession,
47844768
zs_objtype mapi_type;
47854769
uint64_t folder_id;
47864770
uint32_t permission;
4787-
uint32_t proptag_buff[2];
4788-
PROPTAG_ARRAY tmp_proptags;
47894771
TPROPVAL_ARRAY tmp_propvals;
47904772

47914773
auto pinfo = zs_query_session(hsession);
@@ -4824,10 +4806,8 @@ ec_error_t zs_importreadstates(GUID hsession,
48244806
if (!b_owner)
48254807
continue;
48264808
}
4827-
tmp_proptags.count = 2;
4828-
tmp_proptags.pproptag = proptag_buff;
4829-
proptag_buff[0] = PR_ASSOCIATED;
4830-
proptag_buff[1] = PR_READ;
4809+
static constexpr proptag_t proptag_buff[] = {PR_ASSOCIATED, PR_READ};
4810+
static constexpr PROPTAG_ARRAY tmp_proptags = {std::size(proptag_buff), deconst(proptag_buff)};
48314811
if (!exmdb_client::get_message_properties(pstore->get_dir(),
48324812
nullptr, CP_ACP, message_id, &tmp_proptags, &tmp_propvals))
48334813
return ecError;

0 commit comments

Comments
 (0)