Skip to content

Commit

Permalink
chore: go fmt: required formatting.
Browse files Browse the repository at this point in the history
Ticket: None
Signed-off-by: Peter Grzybowski <peter@northern.tech>
(cherry picked from commit e287fad)
  • Loading branch information
merlin-northern authored and kacf committed Dec 9, 2022
1 parent e277ee9 commit 4104860
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 16 deletions.
51 changes: 44 additions & 7 deletions client/dbus/dbus_libgio.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Northern.tech AS
// Copyright 2022 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodbus && cgo
// +build !nodbus,cgo

package dbus
Expand Down Expand Up @@ -66,7 +67,12 @@ func (d *dbusAPILibGio) BusGet(busType uint) (Handle, error) {

// BusProxyNew creates a proxy for accessing an interface over DBus
// https://developer.gnome.org/gio/stable/GDBusProxy.html#g-dbus-proxy-new-sync
func (d *dbusAPILibGio) BusProxyNew(conn Handle, name string, objectPath string, interfaceName string) (Handle, error) {
func (d *dbusAPILibGio) BusProxyNew(
conn Handle,
name string,
objectPath string,
interfaceName string,
) (Handle, error) {
var gerror *C.GError
gconn := C.to_gdbusconnection(unsafe.Pointer(conn))
flags := C.GDBusProxyFlags(GDbusProxyFlagsDoNotLoadProperties)
Expand All @@ -76,7 +82,16 @@ func (d *dbusAPILibGio) BusProxyNew(conn Handle, name string, objectPath string,
defer C.free(unsafe.Pointer(cobjectPath))
cinterfaceName := C.CString(interfaceName)
defer C.free(unsafe.Pointer(cinterfaceName))
proxy := C.g_dbus_proxy_new_sync(gconn, flags, nil, cname, cobjectPath, cinterfaceName, nil, &gerror)
proxy := C.g_dbus_proxy_new_sync(
gconn,
flags,
nil,
cname,
cobjectPath,
cinterfaceName,
nil,
&gerror,
)
if Handle(gerror) != nil {
return Handle(nil), ErrorFromNative(Handle(gerror))
} else if proxy == nil {
Expand All @@ -88,13 +103,26 @@ func (d *dbusAPILibGio) BusProxyNew(conn Handle, name string, objectPath string,

// BusProxyCall synchronously invokes a method method on a proxy
// https://developer.gnome.org/gio/stable/GDBusProxy.html#g-dbus-proxy-call-sync
func (d *dbusAPILibGio) BusProxyCall(proxy Handle, methodName string, params interface{}, timeout int) (DBusCallResponse, error) {
func (d *dbusAPILibGio) BusProxyCall(
proxy Handle,
methodName string,
params interface{},
timeout int,
) (DBusCallResponse, error) {
var gerror *C.GError
gproxy := C.to_gdbusproxy(unsafe.Pointer(proxy))
cmethodName := C.CString(methodName)
defer C.free(unsafe.Pointer(cmethodName))
flags := C.GDBusCallFlags(GDBusCallFlagsNone)
result := C.g_dbus_proxy_call_sync(gproxy, cmethodName, nil, flags, C.gint(timeout), nil, &gerror)
result := C.g_dbus_proxy_call_sync(
gproxy,
cmethodName,
nil,
flags,
C.gint(timeout),
nil,
&gerror,
)
if Handle(gerror) != nil {
return nil, ErrorFromNative(Handle(gerror))
}
Expand Down Expand Up @@ -155,7 +183,10 @@ func (d *dbusAPILibGio) HandleSignal(signalName string, params []SignalParams) {
}

// WaitForSignal waits for a DBus signal
func (d *dbusAPILibGio) WaitForSignal(signalName string, timeout time.Duration) ([]SignalParams, error) {
func (d *dbusAPILibGio) WaitForSignal(
signalName string,
timeout time.Duration,
) ([]SignalParams, error) {
channel := d.GetChannelForSignal(signalName)
select {
case p := <-channel:
Expand All @@ -166,7 +197,13 @@ func (d *dbusAPILibGio) WaitForSignal(signalName string, timeout time.Duration)
}

//export handle_on_signal_callback
func handle_on_signal_callback(proxy *C.GDBusProxy, senderName *C.gchar, signalName *C.gchar, params *C.GVariant, userData C.gpointer) {
func handle_on_signal_callback(
proxy *C.GDBusProxy,
senderName *C.gchar,
signalName *C.gchar,
params *C.GVariant,
userData C.gpointer,
) {
goSignalName := C.GoString(signalName)
api, _ := GetDBusAPI()
var goParams []SignalParams
Expand Down
3 changes: 2 additions & 1 deletion client/dbus/dbus_libgio_helpers.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 Northern.tech AS
// Copyright 2022 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodbus && cgo
// +build !nodbus,cgo

// Based on: https://github.com/gotk3/gotk3/blob/v0.5.0/gio/utils.go
Expand Down
3 changes: 2 additions & 1 deletion client/dbus/dbus_libgio_response.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Northern.tech AS
// Copyright 2022 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !nodbus && cgo
// +build !nodbus,cgo

package dbus
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type SessionsConfig struct {
}

// Counter for the limits and restrictions for the File Transfer
//on and off the device(MEN-4325)
// on and off the device(MEN-4325)
type RateLimits struct {
// Maximum bytes count allowed to transfer per minute
// this is per device global limit, which is consulted
Expand Down
4 changes: 2 additions & 2 deletions connection/connection.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Northern.tech AS
// Copyright 2022 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,7 @@ type Connection struct {
done chan bool
}

//Websocket connection routine. setup the ping-pong and connection settings
// Websocket connection routine. setup the ping-pong and connection settings
func NewConnection(u url.URL,
token string,
writeWait time.Duration,
Expand Down
8 changes: 4 additions & 4 deletions utils/fs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Northern.tech AS
// Copyright 2022 Northern.tech AS
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,9 +27,9 @@ var (
ErrUnsupported = errors.New("unsupported platform")
)

//Returns ture if the path points to a directory or file inside chroot
//in case chroot is an empty string it is treated as root directory, i.e.:
//all paths are in that chroot
// Returns ture if the path points to a directory or file inside chroot
// in case chroot is an empty string it is treated as root directory, i.e.:
// all paths are in that chroot
func IsInChroot(path string, chroot string) bool {
if chroot == "" {
return true
Expand Down

0 comments on commit 4104860

Please sign in to comment.