From ec1825f3f7e0e6ab4bcbe7e544ab132243c362fe Mon Sep 17 00:00:00 2001 From: Eldon Stegall Date: Tue, 15 Nov 2022 12:50:26 -0500 Subject: [PATCH] Avoid unnecessary pointer indirection --- ina219/ina219.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ina219/ina219.go b/ina219/ina219.go index c327c55..5e2b2c8 100644 --- a/ina219/ina219.go +++ b/ina219/ina219.go @@ -5,7 +5,6 @@ package ina219 import ( - "unsafe" "encoding/binary" "errors" "fmt" @@ -111,7 +110,7 @@ func (d *Dev) Sense() (PowerMonitor, error) { return PowerMonitor{}, errReadShunt } // Least significant bit is 10µV. - pm.Shunt = physic.ElectricPotential(*((*int16)(unsafe.Pointer(&shunt)))) * 10 * physic.MicroVolt + pm.Shunt = physic.ElectricPotential(int16(shunt)) * 10 * physic.MicroVolt bus, err := d.m.ReadUint16(busVoltageRegister) if err != nil { @@ -129,7 +128,7 @@ func (d *Dev) Sense() (PowerMonitor, error) { if err != nil { return PowerMonitor{}, errReadCurrent } - pm.Current = physic.ElectricCurrent(*((*int16)(unsafe.Pointer(¤t)))) * d.currentLSB + pm.Current = physic.ElectricCurrent(int16(current)) * d.currentLSB power, err := d.m.ReadUint16(powerRegister) if err != nil {