Skip to content

Commit a2a7cd6

Browse files
committed
Fix errors introduced with guid-by-value change
Signed-off-by: Kevin Parsons <[email protected]>
1 parent d918a0a commit a2a7cd6

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

hvsock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (addr *HvsockAddr) String() string {
4646
func VsockServiceID(port uint32) guid.GUID {
4747
g, _ := guid.FromString("00000000-facb-11e6-bd58-64006a7986d3")
4848
g.Data1 = port
49-
return *g
49+
return g
5050
}
5151

5252
func (addr *HvsockAddr) raw() rawHvsockAddr {

pkg/etw/eventopt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66

77
type eventOptions struct {
88
descriptor *eventDescriptor
9-
activityID *guid.GUID
10-
relatedActivityID *guid.GUID
9+
activityID guid.GUID
10+
relatedActivityID guid.GUID
1111
tags uint32
1212
}
1313

@@ -59,14 +59,14 @@ func WithTags(newTags uint32) EventOpt {
5959
}
6060

6161
// WithActivityID specifies the activity ID of the event to be written.
62-
func WithActivityID(activityID *guid.GUID) EventOpt {
62+
func WithActivityID(activityID guid.GUID) EventOpt {
6363
return func(options *eventOptions) {
6464
options.activityID = activityID
6565
}
6666
}
6767

6868
// WithRelatedActivityID specifies the parent activity ID of the event to be written.
69-
func WithRelatedActivityID(activityID *guid.GUID) EventOpt {
69+
func WithRelatedActivityID(activityID guid.GUID) EventOpt {
7070
return func(options *eventOptions) {
7171
options.relatedActivityID = activityID
7272
}

pkg/etw/newprovider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
// provider ID to be manually specified. This is most useful when there is an
1616
// existing provider ID that must be used to conform to existing diagnostic
1717
// infrastructure.
18-
func NewProviderWithID(name string, id *guid.GUID, callback EnableCallback) (provider *Provider, err error) {
18+
func NewProviderWithID(name string, id guid.GUID, callback EnableCallback) (provider *Provider, err error) {
1919
providerCallbackOnce.Do(func() {
2020
globalProviderCallback = windows.NewCallback(providerCallbackAdapter)
2121
})
@@ -29,7 +29,7 @@ func NewProviderWithID(name string, id *guid.GUID, callback EnableCallback) (pro
2929
provider.ID = id
3030
provider.callback = callback
3131

32-
if err := eventRegister((*windows.GUID)(provider.ID), globalProviderCallback, uintptr(provider.index), &provider.handle); err != nil {
32+
if err := eventRegister((*windows.GUID)(&provider.ID), globalProviderCallback, uintptr(provider.index), &provider.handle); err != nil {
3333
return nil, err
3434
}
3535

pkg/etw/newprovider_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import (
77
)
88

99
// NewProviderWithID returns a nil provider on unsupported platforms.
10-
func NewProviderWithID(name string, id *guid.GUID, callback EnableCallback) (provider *Provider, err error) {
10+
func NewProviderWithID(name string, id guid.GUID, callback EnableCallback) (provider *Provider, err error) {
1111
return nil, nil
1212
}

pkg/etw/provider.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// name and ID (GUID), which should always have a 1:1 mapping to each other
1515
// (e.g. don't use multiple provider names with the same ID, or vice versa).
1616
type Provider struct {
17-
ID *guid.GUID
17+
ID guid.GUID
1818
handle providerHandle
1919
metadata []byte
2020
callback EnableCallback
@@ -61,9 +61,9 @@ const (
6161

6262
// EnableCallback is the form of the callback function that receives provider
6363
// enable/disable notifications from ETW.
64-
type EnableCallback func(*guid.GUID, ProviderState, Level, uint64, uint64, uintptr)
64+
type EnableCallback func(guid.GUID, ProviderState, Level, uint64, uint64, uintptr)
6565

66-
func providerCallback(sourceID *guid.GUID, state ProviderState, level Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr, i uintptr) {
66+
func providerCallback(sourceID guid.GUID, state ProviderState, level Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr, i uintptr) {
6767
provider := providers.getProvider(uint(i))
6868

6969
switch state {
@@ -86,7 +86,7 @@ func providerCallback(sourceID *guid.GUID, state ProviderState, level Level, mat
8686
// different size, it has only pointer-sized arguments, which are then cast to
8787
// the appropriate types when calling providerCallback.
8888
func providerCallbackAdapter(sourceID *guid.GUID, state uintptr, level uintptr, matchAnyKeyword uintptr, matchAllKeyword uintptr, filterData uintptr, i uintptr) uintptr {
89-
providerCallback(sourceID, ProviderState(state), Level(level), uint64(matchAnyKeyword), uint64(matchAllKeyword), filterData, i)
89+
providerCallback(*sourceID, ProviderState(state), Level(level), uint64(matchAnyKeyword), uint64(matchAllKeyword), filterData, i)
9090
return 0
9191
}
9292

@@ -97,7 +97,7 @@ func providerCallbackAdapter(sourceID *guid.GUID, state uintptr, level uintptr,
9797
// The algorithm is roughly:
9898
// Hash = Sha1(namespace + arg.ToUpper().ToUtf16be())
9999
// Guid = Hash[0..15], with Hash[7] tweaked according to RFC 4122
100-
func providerIDFromName(name string) *guid.GUID {
100+
func providerIDFromName(name string) guid.GUID {
101101
buffer := sha1.New()
102102

103103
namespace := []byte{0x48, 0x2C, 0x2D, 0xB2, 0xC3, 0x90, 0x47, 0xC8, 0x87, 0xF8, 0x1A, 0x15, 0xBF, 0xC1, 0x30, 0xFB}
@@ -108,7 +108,7 @@ func providerIDFromName(name string) *guid.GUID {
108108
sum := buffer.Sum(nil)
109109
sum[7] = (sum[7] & 0xf) | 0x50
110110

111-
return &guid.GUID{
111+
return guid.GUID{
112112
Data1: binary.LittleEndian.Uint32(sum[0:4]),
113113
Data2: binary.LittleEndian.Uint16(sum[4:6]),
114114
Data3: binary.LittleEndian.Uint16(sum[6:8]),
@@ -219,8 +219,8 @@ func (provider *Provider) WriteEvent(name string, eventOpts []EventOpt, fieldOpt
219219
// the ETW infrastructure.
220220
func (provider *Provider) writeEventRaw(
221221
descriptor *eventDescriptor,
222-
activityID *guid.GUID,
223-
relatedActivityID *guid.GUID,
222+
activityID guid.GUID,
223+
relatedActivityID guid.GUID,
224224
metadataBlobs [][]byte,
225225
dataBlobs [][]byte) error {
226226

@@ -235,5 +235,5 @@ func (provider *Provider) writeEventRaw(
235235
dataDescriptors = append(dataDescriptors, newEventDataDescriptor(eventDataDescriptorTypeUserData, blob))
236236
}
237237

238-
return eventWriteTransfer(provider.handle, descriptor, (*windows.GUID)(activityID), (*windows.GUID)(relatedActivityID), dataDescriptorCount, &dataDescriptors[0])
238+
return eventWriteTransfer(provider.handle, descriptor, (*windows.GUID)(&activityID), (*windows.GUID)(&relatedActivityID), dataDescriptorCount, &dataDescriptors[0])
239239
}

pkg/etw/sample/sample.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/sirupsen/logrus"
1212
)
1313

14-
func callback(sourceID *guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
14+
func callback(sourceID guid.GUID, state etw.ProviderState, level etw.Level, matchAnyKeyword uint64, matchAllKeyword uint64, filterData uintptr) {
1515
fmt.Printf("Callback: isEnabled=%d, level=%d, matchAnyKeyword=%d\n", state, level, matchAnyKeyword)
1616
}
1717

0 commit comments

Comments
 (0)