Skip to content

Commit

Permalink
Revert "tools: use initialization rather than assignment to construct…
Browse files Browse the repository at this point in the history
… serialize descriptors"

This reverts commit 23d5954. clang
gets confused when seeing brace-init-lists and emits what I see as
false positive warnings:

lib/exmdb_rpc.cpp:27:28: warning: suggest braces around initialization of subobject [-Wmissing-braces]
   27 | exreq_get_named_propids q{exmdb_callid::get_named_propids, deconst(dir), b_create, deconst(ppropnames)};

Since the rules for brace-init-lists are kind of intransparent for
human readers as well, do without initialization of this kind.
  • Loading branch information
jengelh committed Oct 10, 2023
1 parent 91c37ac commit b8b8792
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
11 changes: 8 additions & 3 deletions exch/exmdb_provider/exmdb_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ BOOL exmdb_client_relay_delivery(const char *dir, const char *from_address,
exmdb_server::set_dir(original_dir);
return b_result;
}
exreq_deliver_message q{exmdb_callid::deliver_message, deconst(dir),
deconst(from_address), deconst(account), cpid, 0,
deconst(pmsg), deconst(pdigest)};
exreq_deliver_message q{};
exresp_deliver_message r{};
q.call_id = exmdb_callid::deliver_message;
q.dir = deconst(dir);
q.from_address = deconst(from_address);
q.account = deconst(account);
q.cpid = cpid;
q.pmsg = deconst(pmsg);
q.pdigest = deconst(pdigest);
if (!exmdb_client_do_rpc(&q, &r))
return FALSE;
*presult = r.result;
Expand Down
8 changes: 5 additions & 3 deletions include/gromox/exmdb_rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ enum class exmdb_callid : uint8_t {
};

struct exreq {
exmdb_callid call_id;
char *dir;
exreq() = default; /* Prevent use of direct-list-init */
exmdb_callid call_id{};
char *dir = nullptr;
};

struct exreq_connect : public exreq {
Expand Down Expand Up @@ -856,7 +857,8 @@ struct exreq_recalc_store_size : public exreq {
};

struct exresp {
exmdb_callid call_id;
exresp() = default; /* Prevent use of direct-init-list */
exmdb_callid call_id{};
};

struct exresp_get_all_named_propids : public exresp {
Expand Down
4 changes: 2 additions & 2 deletions lib/exmdb_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ static pack_result exmdb_pull(EXT_PULL &x, exreq_get_content_sync &d)
BINARY tmp_bin;
uint8_t tmp_byte;

memset(&d, 0, sizeof(d));
d = {};
TRY(x.g_uint64(&d.folder_id));
TRY(x.g_uint8(&tmp_byte));
if (tmp_byte != 0)
Expand Down Expand Up @@ -2038,7 +2038,7 @@ static pack_result exmdb_pull(EXT_PULL &x, exreq_get_hierarchy_sync &d)
BINARY tmp_bin;
uint8_t tmp_byte;

memset(&d, 0, sizeof(d));
d = {};
TRY(x.g_uint64(&d.folder_id));
TRY(x.g_uint8(&tmp_byte));
if (tmp_byte != 0)
Expand Down
12 changes: 7 additions & 5 deletions tools/exmidl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,23 @@
}

print "BOOL exmdb_client_remote::$func($rbsig)\n{\n";
print "\texreq_$func q{exmdb_callid::$func, deconst(dir)";
print "\texreq_$func q{};\n\texresp_$func r{};\n";
print "\n";
print "\tq.call_id = exmdb_callid::$func;\n";
print "\tq.dir = deconst(dir);\n";
for (@$iargs) {
my($type, $field) = @$_;
if (substr($type, -1, 1) eq "*") {
print ", deconst($field)";
print "\tq.$field = deconst($field);\n";
} elsif (substr($type, -1, 1) eq "&") {
# struct members should continue to use a pointer,
# because refs are so awkward to assign (more so during
# deserialization than with serialization)
print ", deconst(&$field)";
print "\tq.$field = deconst(&$field);\n";
} else {
print ", $field";
print "\tq.$field = $field;\n";
}
}
print "};\n\texresp_$func r{};\n";
print "\tif (!exmdb_client_do_rpc(&q, &r))\n\t\treturn false;\n";
for (@$oargs) {
my($type, $field) = @$_;
Expand Down
10 changes: 5 additions & 5 deletions tools/zcidl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@
}

print "uint32_t zclient_$func($rbsig)\n{\n";
print "\tzcreq_$func q{zcore_callid::$func";
print "\tzcreq_$func q{};\n\tzcresp_$func r{};\n\n";
print "\tq.call_id = zcore_callid::$func;\n";
for (@$iargs) {
my($type, $field) = @$_;
if (substr($type, -1, 1) eq "*") {
print ", deconst($field)";
print "\tq.$field = deconst($field);\n";
} elsif (substr($type, -1, 1) eq "&") {
print ", deconst(&$field)";
print "\tq.$field = deconst(&$field);\n";
} else {
print ", $field";
print "\tq.$field = $field;\n";
}
}
print "};\n\tzcresp_$func r{};\n\n";
print "\tif (!zclient_do_rpc(&q, &r))\n\t\treturn ecRpcFailed;\n";
if (scalar(@$oargs) > 0) {
print "\tif (r.result != ecSuccess)\n\t\treturn r.result;\n";
Expand Down

0 comments on commit b8b8792

Please sign in to comment.