Remove message->priority field

A warning is emitted from sd_bus_message_{get,set}_priority. Those functions
are exposed by pystemd, so we have no easy way of checking if anything is
calling them.

Just making the functions always return without doing anything would be an
option, but then we could leave the caller with an undefined variable. So I
think it's better to make the functions emit a warnings and return priority=0
in the get operation.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-04-03 18:17:18 +02:00 committed by Lennart Poettering
parent 6635f57d3e
commit c3362c2f97
5 changed files with 18 additions and 8 deletions

View File

@ -65,7 +65,7 @@
<para>Output for a signal message (with <constant>SD_BUS_MESSAGE_DUMP_WITH_HEADER</constant>):
<programlisting>
‣ Type=signal Endian=l Flags=1 Version=1 Priority=0 Cookie=22
‣ Type=signal Endian=l Flags=1 Version=1 Cookie=22
Path=/value/a Interface=org.freedesktop.DBus.Properties Member=PropertiesChanged
MESSAGE "sa{sv}as" {
STRING "org.freedesktop.systemd.ValueTest";

View File

@ -1200,7 +1200,6 @@ static int message_json(sd_bus_message *m, FILE *f) {
JSON_BUILD_PAIR("endian", JSON_BUILD_STRING(e)),
JSON_BUILD_PAIR("flags", JSON_BUILD_INTEGER(m->header->flags)),
JSON_BUILD_PAIR("version", JSON_BUILD_INTEGER(m->header->version)),
JSON_BUILD_PAIR_CONDITION(m->priority != 0, "priority", JSON_BUILD_INTEGER(m->priority)),
JSON_BUILD_PAIR("cookie", JSON_BUILD_INTEGER(BUS_MESSAGE_COOKIE(m))),
JSON_BUILD_PAIR_CONDITION(m->reply_cookie != 0, "reply_cookie", JSON_BUILD_INTEGER(m->reply_cookie)),
JSON_BUILD_PAIR_CONDITION(m->sender, "sender", JSON_BUILD_STRING(m->sender)),

View File

@ -56,7 +56,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
if (flags & SD_BUS_MESSAGE_DUMP_WITH_HEADER) {
fprintf(f,
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u Priority=%"PRIi64,
"%s%s%s Type=%s%s%s Endian=%c Flags=%u Version=%u",
m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "",
@ -69,8 +69,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
m->header->endian,
m->header->flags,
m->header->version,
m->priority);
m->header->version);
/* Display synthetic message serial number in a more readable
* format than (uint32_t) -1 */

View File

@ -5924,18 +5924,31 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
}
_public_ int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority) {
static bool warned = false;
assert_return(m, -EINVAL);
assert_return(priority, -EINVAL);
*priority = m->priority;
if (!warned) {
log_debug("sd_bus_message_get_priority() is deprecated and always returns 0.");
warned = true;
}
*priority = 0;
return 0;
}
_public_ int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority) {
static bool warned = false;
assert_return(m, -EINVAL);
assert_return(!m->sealed, -EPERM);
m->priority = priority;
if (!warned) {
log_debug("sd_bus_message_set_priority() is deprecated and does nothing.");
warned = true;
}
return 0;
}

View File

@ -76,7 +76,6 @@ struct sd_bus_message {
usec_t monotonic;
usec_t realtime;
uint64_t seqnum;
int64_t priority;
uint64_t verify_destination_id;
bool sealed:1;