Skip to content

Commit 0e07767

Browse files
committed
mapi_lib: switch TPROPVAL_ARRAY::set to return ec_error_t
1 parent 5869f63 commit 0e07767

35 files changed

+685
-683
lines changed

exch/emsmdb/fastupctx_object.cpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,24 @@ static BOOL fastupctx_object_create_folder(fastupctx_object *pctx,
115115
if (!pproplist->has(PR_DISPLAY_NAME))
116116
return FALSE;
117117
tmp_type = FOLDER_GENERIC;
118-
if (pproplist->set(PR_FOLDER_TYPE, &tmp_type) != 0)
119-
return FALSE;
120-
if (pproplist->set(PidTagParentFolderId, &parent_id) != 0)
118+
if (pproplist->set(PR_FOLDER_TYPE, &tmp_type) != ecSuccess ||
119+
pproplist->set(PidTagParentFolderId, &parent_id) != ecSuccess)
121120
return FALSE;
122121
auto dir = pctx->pstream->plogon->get_dir();
123122
if (!exmdb_client->allocate_cn(dir, &change_num))
124123
return FALSE;
125-
if (pproplist->set(PidTagChangeNumber, &change_num) != 0)
124+
if (pproplist->set(PidTagChangeNumber, &change_num) != ecSuccess)
126125
return FALSE;
127126
auto pbin = cu_xid_to_bin({pctx->pstream->plogon->guid(), change_num});
128127
if (pbin == nullptr)
129128
return FALSE;
130-
if (pproplist->set(PR_CHANGE_KEY, pbin) != 0)
129+
if (pproplist->set(PR_CHANGE_KEY, pbin) != ecSuccess)
131130
return FALSE;
132131
auto pbin1 = pproplist->get<BINARY>(PR_PREDECESSOR_CHANGE_LIST);
133132
auto newval = common_util_pcl_append(pbin1, pbin);
134133
if (newval == nullptr)
135134
return FALSE;
136-
if (pproplist->set(PR_PREDECESSOR_CHANGE_LIST, newval) != 0)
135+
if (pproplist->set(PR_PREDECESSOR_CHANGE_LIST, newval) != ecSuccess)
137136
return FALSE;
138137
auto pinfo = emsmdb_interface_get_emsmdb_info();
139138
ec_error_t err = ecSuccess;
@@ -196,19 +195,22 @@ fastupctx_object_write_message(fastupctx_object *pctx, uint64_t folder_id)
196195
auto dir = plogon->get_dir();
197196
if (!exmdb_client->allocate_cn(dir, &change_num))
198197
return ecRpcFailed;
199-
if (pproplist->set(PidTagChangeNumber, &change_num) != 0)
200-
return ecRpcFailed;
198+
auto err = pproplist->set(PidTagChangeNumber, &change_num);
199+
if (err != ecSuccess)
200+
return err;
201201
auto pbin = cu_xid_to_bin({plogon->guid(), change_num});
202202
if (pbin == nullptr)
203203
return ecRpcFailed;
204-
if (pproplist->set(PR_CHANGE_KEY, pbin) != 0)
205-
return ecRpcFailed;
204+
err = pproplist->set(PR_CHANGE_KEY, pbin);
205+
if (err != ecSuccess)
206+
return err;
206207
auto pbin1 = pproplist->get<BINARY>(PR_PREDECESSOR_CHANGE_LIST);
207208
auto pvalue = common_util_pcl_append(pbin1, pbin);
208209
if (pvalue == nullptr)
209210
return ecRpcFailed;
210-
if (pproplist->set(PR_PREDECESSOR_CHANGE_LIST, pvalue) != 0)
211-
return ecRpcFailed;
211+
err = pproplist->set(PR_PREDECESSOR_CHANGE_LIST, pvalue);
212+
if (err != ecSuccess)
213+
return err;
212214
auto pinfo = emsmdb_interface_get_emsmdb_info();
213215
ec_error_t e_result = ecRpcFailed;
214216
if (!exmdb_client->write_message(dir, pinfo->cpid, folder_id,
@@ -345,8 +347,9 @@ ec_error_t fastupctx_object::record_marker(uint32_t marker)
345347
m_content->set_attachments_internal(pattachments);
346348
pproplist = m_content->get_proplist();
347349
uint8_t tmp_byte = marker == STARTFAIMSG;
348-
if (pproplist->set(PR_ASSOCIATED, &tmp_byte) != 0)
349-
return ecRpcFailed;
350+
auto err = pproplist->set(PR_ASSOCIATED, &tmp_byte);
351+
if (err != ecSuccess)
352+
return err;
350353
pmarker->marker = marker;
351354
pmarker->msg = m_content;
352355
break;
@@ -698,8 +701,7 @@ ec_error_t fastupctx_object::record_propval(const TAGGED_PROPVAL *ppropval)
698701
case 0:
699702
switch (pctx->root_element) {
700703
case ROOT_ELEMENT_FOLDERCONTENT:
701-
return m_props->set(*ppropval) == 0 ?
702-
ecSuccess : ecRpcFailed;
704+
return m_props->set(*ppropval);
703705
case ROOT_ELEMENT_MESSAGECONTENT: {
704706
auto msg = static_cast<message_object *>(pctx->pobject);
705707
const TPROPVAL_ARRAY av = {1, deconst(ppropval)};
@@ -719,24 +721,23 @@ ec_error_t fastupctx_object::record_propval(const TAGGED_PROPVAL *ppropval)
719721
return ecRpcFailed;
720722
case STARTTOPFLD:
721723
case STARTSUBFLD:
722-
return m_props->set(*ppropval) == 0 ? ecSuccess : ecRpcFailed;
724+
return m_props->set(*ppropval);
723725
case STARTMESSAGE:
724726
case STARTFAIMSG:
725-
return pnode->props->set(*ppropval) == 0 ? ecSuccess : ecRpcFailed;
727+
return pnode->props->set(*ppropval);
726728
case STARTEMBED:
727729
case NEWATTACH:
728730
if (pctx->root_element == ROOT_ELEMENT_ATTACHMENTCONTENT ||
729731
pctx->root_element == ROOT_ELEMENT_MESSAGECONTENT)
730732
return exmdb_client->set_instance_property(pctx->pstream->plogon->get_dir(),
731733
pnode->instance_id, ppropval, &b_result) == TRUE ?
732734
ecSuccess : ecRpcFailed;
733-
return pnode->props->set(*ppropval) == 0 ? ecSuccess : ecRpcFailed;
735+
return pnode->props->set(*ppropval);
734736
case STARTRECIP:
735737
if (pctx->root_element == ROOT_ELEMENT_ATTACHMENTCONTENT ||
736738
pctx->root_element == ROOT_ELEMENT_MESSAGECONTENT)
737-
return m_props->set(*ppropval) == 0 ?
738-
ecSuccess : ecRpcFailed;
739-
return pnode->props->set(*ppropval) == 0 ? ecSuccess : ecRpcFailed;
739+
return m_props->set(*ppropval);
740+
return pnode->props->set(*ppropval);
740741
default:
741742
return ecRpcFailed;
742743
}

exch/emsmdb/ics_state.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,22 @@ TPROPVAL_ARRAY *ics_state::serialize()
145145
auto pbin = pstate->pgiven->serialize();
146146
if (pbin == nullptr)
147147
return NULL;
148-
if (pproplist->set(MetaTagIdsetGiven1, pbin) != 0) {
148+
if (pproplist->set(MetaTagIdsetGiven1, pbin) != ecSuccess) {
149149
rop_util_free_binary(pbin);
150150
return NULL;
151151
}
152152
rop_util_free_binary(pbin);
153153
}
154154

155155
std::unique_ptr<BINARY, mdel> ser(pstate->pseen->serialize());
156-
if (ser == nullptr || pproplist->set(MetaTagCnsetSeen, ser.get()) != 0)
156+
if (ser == nullptr || pproplist->set(MetaTagCnsetSeen, ser.get()) != ecSuccess)
157157
return NULL;
158158

159159
if (ICS_STATE_CONTENTS_DOWN == pstate->type ||
160160
ICS_STATE_CONTENTS_UP == pstate->type) {
161161
decltype(ser) s(pstate->pseen_fai->serialize());
162162
if (s == nullptr ||
163-
pproplist->set(MetaTagCnsetSeenFAI, s.get()) != 0)
163+
pproplist->set(MetaTagCnsetSeenFAI, s.get()) != ecSuccess)
164164
return NULL;
165165
}
166166

@@ -169,7 +169,7 @@ TPROPVAL_ARRAY *ics_state::serialize()
169169
!pstate->pread->empty())) {
170170
decltype(ser) s(pstate->pread->serialize());
171171
if (s == nullptr ||
172-
pproplist->set(MetaTagCnsetRead, s.get()) != 0)
172+
pproplist->set(MetaTagCnsetRead, s.get()) != ecSuccess)
173173
return NULL;
174174
}
175175
return pproplist.release();

exch/emsmdb/oxcfxics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ oxcfxics_load_folder_content(logon_object *plogon, uint64_t folder_id,
107107
return NULL;
108108
auto pproplist = pfldctnt->get_proplist();
109109
for (size_t i = 0; i < tmp_propvals.count; ++i)
110-
if (pproplist->set(tmp_propvals.ppropval[i]) != 0)
110+
if (pproplist->set(tmp_propvals.ppropval[i]) != ecSuccess)
111111
return NULL;
112112
/*
113113
* Gromox does not have split public folders, so no need to emit

exch/ews/context.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,9 +1704,11 @@ EWSContext::MCONT_PTR EWSContext::toContent(const std::string& dir, const sFolde
17041704
}
17051705
getNamedTags(dir, shape, true);
17061706

1707-
for (const TAGGED_PROPVAL &prop : shape.write())
1708-
if (content->proplist.set(prop) == -ENOMEM)
1707+
for (const TAGGED_PROPVAL &prop : shape.write()) {
1708+
auto err = content->proplist.set(prop);
1709+
if (err == ecServerOOM)
17091710
throw EWSError::NotEnoughMemory(E3217);
1711+
}
17101712
return content;
17111713
}
17121714

exch/ews/requests.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,13 +1598,12 @@ void process(mUpdateItemRequest&& request, XMLElement* response, const EWSContex
15981598
content->proplist.erase(tag);
15991599
for (const auto &prop : shape.write()) {
16001600
auto ret = content->proplist.set(prop);
1601-
if (ret == -ENOMEM)
1601+
if (ret == ecServerOOM)
16021602
throw EWSError::ItemSave(E3035);
16031603
}
1604-
auto ret = content->proplist.set(PidTagMid, EWSContext::construct<uint64_t>(rop_util_make_eid(1, mid.message_global_counter)));
1605-
if (ret == -ENOMEM)
1604+
auto error = content->proplist.set(PidTagMid, EWSContext::construct<uint64_t>(rop_util_make_eid(1, mid.message_global_counter)));
1605+
if (error == ecServerOOM)
16061606
throw EWSError::ItemSave(E3035);
1607-
ec_error_t error;
16081607
if (!ctx.plugin().exmdb.write_message(dir.c_str(),
16091608
CP_ACP, parentFolder.folderId, content.get(),
16101609
&error) || error != ecSuccess)

exch/ews/serialization.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,25 @@ std::string sSyncState::serialize()
192192
if (!pproplist)
193193
throw EWSError::NotEnoughMemory(E3035);
194194
std::unique_ptr<BINARY, Cleaner> ser(given.serialize());
195-
if (!ser || pproplist->set(MetaTagIdsetGiven1, ser.get()))
195+
if (!ser || pproplist->set(MetaTagIdsetGiven1, ser.get()) == ecServerOOM)
196196
throw EWSError::NotEnoughMemory(E3036);
197197
ser.reset(seen.serialize());
198-
if (!ser || pproplist->set(MetaTagCnsetSeen, ser.get()))
198+
if (!ser || pproplist->set(MetaTagCnsetSeen, ser.get()) == ecServerOOM)
199199
throw EWSError::NotEnoughMemory(E3037);
200200
ser.reset();
201201
if (!seen_fai.empty()) {
202202
ser.reset(seen_fai.serialize());
203-
if (!ser || pproplist->set(MetaTagCnsetSeenFAI, ser.get()))
203+
if (!ser || pproplist->set(MetaTagCnsetSeenFAI, ser.get()) == ecServerOOM)
204204
throw EWSError::NotEnoughMemory(E3038);
205205
}
206206
if (!read.empty()) {
207207
ser.reset(read.serialize());
208-
if (!ser || pproplist->set(MetaTagCnsetRead, ser.get()))
208+
if (!ser || pproplist->set(MetaTagCnsetRead, ser.get()) == ecServerOOM)
209209
throw EWSError::NotEnoughMemory(E3039);
210210
}
211211
ser.reset();
212-
if (readOffset != 0 && pproplist->set(MetaTagReadOffset, &readOffset) != 0)
213-
/* ignore error */;
212+
if (readOffset != 0 && pproplist->set(MetaTagReadOffset, &readOffset) == ecServerOOM)
213+
throw EWSError::NotEnoughMemory(E3039);
214214

215215
EXT_PUSH stateBuffer;
216216
if (!stateBuffer.init(nullptr, 0, EXT_FLAG_WCOUNT) ||

exch/ews/structures.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,11 +2500,12 @@ void tEmailAddressType::mkRecipient(TPROPVAL_ARRAY* rcpt, uint32_t type) const
25002500
if (!EmailAddress)
25012501
throw EWSError::InvalidRecipients(E3290);
25022502
auto displayname = Name ? Name->c_str() : EmailAddress->c_str();
2503-
if (rcpt->set(PR_DISPLAY_NAME, displayname) ||
2504-
rcpt->set(PR_TRANSMITABLE_DISPLAY_NAME, displayname) ||
2505-
rcpt->set(PR_ADDRTYPE, RoutingType ? RoutingType->c_str() : "SMTP") ||
2506-
rcpt->set(PR_EMAIL_ADDRESS, EmailAddress->c_str()) ||
2507-
rcpt->set(PR_RECIPIENT_TYPE, &type))
2503+
ec_error_t err;
2504+
if ((err = rcpt->set(PR_DISPLAY_NAME, displayname)) == ecServerOOM ||
2505+
(err = rcpt->set(PR_TRANSMITABLE_DISPLAY_NAME, displayname)) == ecServerOOM ||
2506+
(err = rcpt->set(PR_ADDRTYPE, RoutingType ? RoutingType->c_str() : "SMTP")) == ecServerOOM ||
2507+
(err = rcpt->set(PR_EMAIL_ADDRESS, EmailAddress->c_str())) == ecServerOOM ||
2508+
(err = rcpt->set(PR_RECIPIENT_TYPE, &type)) == ecServerOOM)
25082509
throw EWSError::NotEnoughMemory(E3291);
25092510
}
25102511

0 commit comments

Comments
 (0)