Skip to content

Commit

Permalink
misc: fix hypothetical implicit memory aliasing
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Oct 11, 2023
1 parent edb6a54 commit 3dce75a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/controller/alert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func (r *AlertReconciler) requestsForProviderChange(ctx context.Context, o clien
}

var reqs []reconcile.Request
for _, i := range list.Items {
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&i)})
for i := range list.Items {
reqs = append(reqs, reconcile.Request{NamespacedName: client.ObjectKeyFromObject(&list.Items[i])})
}

return reqs
Expand Down
10 changes: 5 additions & 5 deletions internal/server/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request)
// find matching alerts
alerts := make([]apiv1beta2.Alert, 0)
each_alert:
for _, alert := range allAlerts.Items {
alertLogger := eventLogger.WithValues("alert", client.ObjectKeyFromObject(&alert))
for i, alert := range allAlerts.Items {
alertLogger := eventLogger.WithValues("alert", client.ObjectKeyFromObject(&allAlerts.Items[i]))
ctx := log.IntoContext(ctx, alertLogger)

// skip suspended and not ready alerts
isReady := conditions.IsReady(&alert)
isReady := conditions.IsReady(&allAlerts.Items[i])
if alert.Spec.Suspend || !isReady {
continue each_alert
}
Expand Down Expand Up @@ -123,8 +123,8 @@ func (s *EventServer) handleEvent() func(w http.ResponseWriter, r *http.Request)
eventLogger.Info(fmt.Sprintf("Dispatching event: %s", event.Message))

// dispatch notifications
for _, alert := range alerts {
alertLogger := eventLogger.WithValues("alert", client.ObjectKeyFromObject(&alert))
for i, alert := range alerts {
alertLogger := eventLogger.WithValues("alert", client.ObjectKeyFromObject(&alerts[i]))
ctx := log.IntoContext(ctx, alertLogger)

// verify if event comes from a different namespace
Expand Down
4 changes: 2 additions & 2 deletions internal/server/receiver_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ func (s *ReceiverServer) requestReconciliation(ctx context.Context, logger logr.
return nil
}

for _, resource := range resources.Items {
if err := s.annotate(ctx, &resource); err != nil {
for i, resource := range resources.Items {
if err := s.annotate(ctx, &resources.Items[i]); err != nil {
return fmt.Errorf("failed to annotate resource: '%s/%s.%s': %w", resource.Kind, resource.Name, namespace, err)
} else {
logger.Info(fmt.Sprintf("resource '%s/%s.%s' annotated",
Expand Down

0 comments on commit 3dce75a

Please sign in to comment.