diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cdd56991..923e335c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -91,5 +91,5 @@ jobs: uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 with: # renovate: github=golangci/golangci-lint - version: v2.7.2 + version: v2.11.3 args: "--max-same-issues=0" diff --git a/cmd/windows_exporter/0_service.go b/cmd/windows_exporter/0_service.go index ec054adb..21ec667f 100644 --- a/cmd/windows_exporter/0_service.go +++ b/cmd/windows_exporter/0_service.go @@ -201,7 +201,7 @@ func isWindowsService() (bool, error) { } } - for ; ; parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Pointer(uintptr(unsafe.Pointer(parentProcess)) + uintptr(parentProcess.NextEntryOffset))) { + for ; ; parentProcess = (*windows.SYSTEM_PROCESS_INFORMATION)(unsafe.Add(unsafe.Pointer(parentProcess), uintptr(parentProcess.NextEntryOffset))) { if parentProcess.UniqueProcessID == currentProcess.InheritedFromUniqueProcessId { return strings.EqualFold("services.exe", parentProcess.ImageName.String()), nil } diff --git a/internal/collector/exchange/exchange.go b/internal/collector/exchange/exchange.go index 195b7912..84790b94 100644 --- a/internal/collector/exchange/exchange.go +++ b/internal/collector/exchange/exchange.go @@ -136,10 +136,10 @@ func NewWithFlags(app *kingpin.Application) *Collector { } sb := strings.Builder{} - sb.WriteString(fmt.Sprintf("%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object")) + _, _ = fmt.Fprintf(&sb, "%-32s %-32s\n", "Collector Name", "[PerfID] Perflib Object") for _, cname := range ConfigDefaults.CollectorsEnabled { - sb.WriteString(fmt.Sprintf("%-32s %-32s\n", cname, collectorDesc[cname])) + _, _ = fmt.Fprintf(&sb, "%-32s %-32s\n", cname, collectorDesc[cname]) } app.UsageTemplate(sb.String()).Usage(nil) diff --git a/internal/collector/textfile/textfile_test.go b/internal/collector/textfile/textfile_test.go index 00ebe98e..449d5fb7 100644 --- a/internal/collector/textfile/textfile_test.go +++ b/internal/collector/textfile/textfile_test.go @@ -118,7 +118,7 @@ func TestDuplicateMetricEntry(t *testing.T) { Metric: []*dto.Metric{&metric1, &metric2}, } - var duplicateFamily []*dto.MetricFamily + duplicateFamily := make([]*dto.MetricFamily, 0, 1) duplicateFamily = append(duplicateFamily, &duplicate) @@ -146,7 +146,7 @@ func TestDuplicateMetricEntry(t *testing.T) { Metric: []*dto.Metric{&metric1, &metric3}, } - duplicateFamily = []*dto.MetricFamily{} + duplicateFamily = make([]*dto.MetricFamily, 0, 1) duplicateFamily = append(duplicateFamily, &differentLabels) // Additional label on second metric should not be cause for duplicate detection @@ -171,7 +171,7 @@ func TestDuplicateMetricEntry(t *testing.T) { Type: &metric_type, Metric: []*dto.Metric{&metric3, &metric4}, } - duplicateFamily = []*dto.MetricFamily{} + duplicateFamily = make([]*dto.MetricFamily, 0, 1) duplicateFamily = append(duplicateFamily, &differentValues) // Additional label with different values metric should not be cause for duplicate detection diff --git a/internal/headers/dhcpsapi/dhcpsapi.go b/internal/headers/dhcpsapi/dhcpsapi.go index 0f58f565..09e30379 100644 --- a/internal/headers/dhcpsapi/dhcpsapi.go +++ b/internal/headers/dhcpsapi/dhcpsapi.go @@ -71,6 +71,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) { for _, subnet := range subnets { if err := (func() error { var subnetInfo *DHCP_SUBNET_INFO + err := dhcpGetSubnetInfo(subnet.SubnetAddress, &subnetInfo) if err != nil { return fmt.Errorf("failed to get subnet info: %w", err) @@ -109,6 +110,7 @@ func GetDHCPV4ScopeStatistics() ([]DHCPV4Scope, error) { } var subnetStatistics *DHCP_FAILOVER_STATISTICS + err = dhcpV4FailoverGetScopeStatistics(subnet.SubnetAddress, &subnetStatistics) defer dhcpRpcFreeMemory(unsafe.Pointer(subnetStatistics)) diff --git a/internal/mi/types.go b/internal/mi/types.go index 77578af6..c5eb22b0 100644 --- a/internal/mi/types.go +++ b/internal/mi/types.go @@ -142,7 +142,7 @@ func (c *ClassDecl) Properties() []*PropertyDecl { // Iterate over the number of properties and fetch each property for i := range c.NumProperties { // Get the property pointer at index i - propertyPtr := *(**PropertyDecl)(unsafe.Pointer(uintptr(unsafe.Pointer(propertiesArray)) + uintptr(i)*unsafe.Sizeof(uintptr(0)))) + propertyPtr := *(**PropertyDecl)(unsafe.Add(unsafe.Pointer(propertiesArray), uintptr(i)*unsafe.Sizeof(uintptr(0)))) // Append the property to the slice properties[i] = propertyPtr diff --git a/internal/utils/testutils/handle.go b/internal/utils/testutils/handle.go index dff4182a..1d9e10ae 100644 --- a/internal/utils/testutils/handle.go +++ b/internal/utils/testutils/handle.go @@ -12,6 +12,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 windows package testutils