hst: improve doc comments
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m40s
Test / Hakurei (push) Successful in 3m40s
Test / ShareFS (push) Successful in 3m47s
Test / Sandbox (race detector) (push) Successful in 5m3s
Test / Hakurei (race detector) (push) Successful in 5m58s
Test / Flake checks (push) Successful in 1m26s
All checks were successful
Test / Create distribution (push) Successful in 1m3s
Test / Sandbox (push) Successful in 2m40s
Test / Hakurei (push) Successful in 3m40s
Test / ShareFS (push) Successful in 3m47s
Test / Sandbox (race detector) (push) Successful in 5m3s
Test / Hakurei (race detector) (push) Successful in 5m58s
Test / Flake checks (push) Successful in 1m26s
These now read a lot better both in source and on pkgsite. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
46
hst/dbus.go
46
hst/dbus.go
@@ -5,8 +5,26 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// BadInterfaceError is returned when Interface fails an undocumented check in xdg-dbus-proxy,
|
||||
// which would have cause a silent failure.
|
||||
// BadInterfaceError is returned when Interface fails an undocumented check in
|
||||
// xdg-dbus-proxy, which would have cause a silent failure.
|
||||
//
|
||||
// xdg-dbus-proxy fails without output when this condition is not met:
|
||||
//
|
||||
// char *dot = strrchr (filter->interface, '.');
|
||||
// if (dot != NULL)
|
||||
// {
|
||||
// *dot = 0;
|
||||
// if (strcmp (dot + 1, "*") != 0)
|
||||
// filter->member = g_strdup (dot + 1);
|
||||
// }
|
||||
//
|
||||
// trim ".*" since they are removed before searching for '.':
|
||||
//
|
||||
// if (g_str_has_suffix (name, ".*"))
|
||||
// {
|
||||
// name[strlen (name) - 2] = 0;
|
||||
// wildcard = TRUE;
|
||||
// }
|
||||
type BadInterfaceError struct {
|
||||
// Interface is the offending interface string.
|
||||
Interface string
|
||||
@@ -19,7 +37,8 @@ func (e *BadInterfaceError) Error() string {
|
||||
if e == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return "bad interface string " + strconv.Quote(e.Interface) + " in " + e.Segment + " bus configuration"
|
||||
return "bad interface string " + strconv.Quote(e.Interface) +
|
||||
" in " + e.Segment + " bus configuration"
|
||||
}
|
||||
|
||||
// BusConfig configures the xdg-dbus-proxy process.
|
||||
@@ -76,31 +95,14 @@ func (c *BusConfig) Interfaces(yield func(string) bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// CheckInterfaces checks for invalid interface strings based on an undocumented check in xdg-dbus-error,
|
||||
// returning [BadInterfaceError] if one is encountered.
|
||||
// CheckInterfaces checks for invalid interface strings based on an undocumented
|
||||
// check in xdg-dbus-error, returning [BadInterfaceError] if one is encountered.
|
||||
func (c *BusConfig) CheckInterfaces(segment string) error {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
for iface := range c.Interfaces {
|
||||
/*
|
||||
xdg-dbus-proxy fails without output when this condition is not met:
|
||||
char *dot = strrchr (filter->interface, '.');
|
||||
if (dot != NULL)
|
||||
{
|
||||
*dot = 0;
|
||||
if (strcmp (dot + 1, "*") != 0)
|
||||
filter->member = g_strdup (dot + 1);
|
||||
}
|
||||
|
||||
trim ".*" since they are removed before searching for '.':
|
||||
if (g_str_has_suffix (name, ".*"))
|
||||
{
|
||||
name[strlen (name) - 2] = 0;
|
||||
wildcard = TRUE;
|
||||
}
|
||||
*/
|
||||
if strings.IndexByte(strings.TrimSuffix(iface, ".*"), '.') == -1 {
|
||||
return &BadInterfaceError{iface, segment}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user