diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-04-25 15:15:52 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-04-26 18:12:22 +0200 |
commit | 51fbf3da9ee34a8143df5baeda6032c1747446d2 (patch) | |
tree | f5edbd047f5e4aea72b710403a0aa208b238c83b /pkg/systemd/dbus.go | |
parent | 216d9243077f478a9c7ffda1c6e0b1fcbad9ee76 (diff) | |
download | podman-51fbf3da9ee34a8143df5baeda6032c1747446d2.tar.gz podman-51fbf3da9ee34a8143df5baeda6032c1747446d2.tar.bz2 podman-51fbf3da9ee34a8143df5baeda6032c1747446d2.zip |
enable gocritic linter
The linter ensures a common code style.
- use switch/case instead of else if
- use if instead of switch/case for single case statement
- add space between comment and text
- detect the use of defer with os.Exit()
- use short form var += "..." instead of var = var + "..."
- detect problems with append()
```
newSlice := append(orgSlice, val)
```
This could lead to nasty bugs because the orgSlice will be changed in
place if it has enough capacity too hold the new elements. Thus we
newSlice might not be a copy.
Of course most of the changes are just cosmetic and do not cause any
logic errors but I think it is a good idea to enforce a common style.
This should help maintainability.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/systemd/dbus.go')
-rw-r--r-- | pkg/systemd/dbus.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/pkg/systemd/dbus.go b/pkg/systemd/dbus.go index b35f778ab..6887a466e 100644 --- a/pkg/systemd/dbus.go +++ b/pkg/systemd/dbus.go @@ -26,39 +26,39 @@ func IsSystemdSessionValid(uid int) bool { if rootless.IsRootless() { conn, err = GetLogindConnection(rootless.GetRootlessUID()) if err != nil { - //unable to fetch systemd object for logind + // unable to fetch systemd object for logind logrus.Debugf("systemd-logind: %s", err) return false } object = conn.Object(dbusDest, godbus.ObjectPath(dbusPath)) if err := object.Call(dbusInterface+".GetSeat", 0, "seat0").Store(&seat0Path); err != nil { - //unable to get seat0 path. + // unable to get seat0 path. logrus.Debugf("systemd-logind: %s", err) return false } seat0Obj := conn.Object(dbusDest, seat0Path) activeSession, err := seat0Obj.GetProperty(dbusDest + ".Seat.ActiveSession") if err != nil { - //unable to get active sessions. + // unable to get active sessions. logrus.Debugf("systemd-logind: %s", err) return false } activeSessionMap, ok := activeSession.Value().([]interface{}) if !ok || len(activeSessionMap) < 2 { - //unable to get active session map. + // unable to get active session map. logrus.Debugf("systemd-logind: %s", err) return false } activeSessionPath, ok := activeSessionMap[1].(godbus.ObjectPath) if !ok { - //unable to fetch active session path. + // unable to fetch active session path. logrus.Debugf("systemd-logind: %s", err) return false } activeSessionObj := conn.Object(dbusDest, activeSessionPath) sessionUser, err := activeSessionObj.GetProperty(dbusDest + ".Session.User") if err != nil { - //unable to fetch session user from activeSession path. + // unable to fetch session user from activeSession path. logrus.Debugf("systemd-logind: %s", err) return false } @@ -75,7 +75,7 @@ func IsSystemdSessionValid(uid int) bool { if !ok { return false } - //active session found which belongs to following rootless user + // active session found which belongs to following rootless user if activeUID == uint32(uid) { return true } |