sd-bus: add define for the maximum name length

Less magic numbers in the code…
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-04-11 14:07:22 +02:00
parent cfcc0059bf
commit fb270a26b2
2 changed files with 6 additions and 3 deletions

View file

@ -97,7 +97,7 @@ bool interface_name_is_valid(const char *p) {
dot = false;
}
if (q - p > 255)
if (q - p > SD_BUS_MAXIMUM_NAME_LENGTH)
return false;
if (dot)
@ -139,7 +139,7 @@ bool service_name_is_valid(const char *p) {
dot = false;
}
if (q - p > 255)
if (q - p > SD_BUS_MAXIMUM_NAME_LENGTH)
return false;
if (dot)
@ -170,7 +170,7 @@ bool member_name_is_valid(const char *p) {
return false;
}
if (q - p > 255)
if (q - p > SD_BUS_MAXIMUM_NAME_LENGTH)
return false;
return true;

View file

@ -36,6 +36,9 @@ _SD_BEGIN_DECLARATIONS;
/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-signature */
#define SD_BUS_MAXIMUM_SIGNATURE_LENGTH 255
/* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names */
#define SD_BUS_MAXIMUM_NAME_LENGTH 255
/* Types */
typedef struct sd_bus sd_bus;