Skip to content

Commit 4359f65

Browse files
committed
Appease gosec
1 parent 2ff423f commit 4359f65

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pdata/pprofile/attributes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ var errTooManyTableEntries = errors.New("too many entries in AttributeTable")
4040
// The record can be any struct that implements an `AttributeIndices` method.
4141
func PutAttribute(table AttributeTableSlice, record attributable, key string, value pcommon.Value) error {
4242
for i := range record.AttributeIndices().Len() {
43-
idx := record.AttributeIndices().At(i)
44-
if idx < 0 || idx >= int32(table.Len()) {
43+
idx := int(record.AttributeIndices().At(i))
44+
if idx < 0 || idx >= table.Len() {
4545
return fmt.Errorf("index value %d out of range in AttributeIndices[%d]", idx, i)
4646
}
47-
attr := table.At(int(idx))
47+
attr := table.At(idx)
4848
if attr.Key() == key {
4949
if attr.Value().Equal(value) {
5050
// Attribute already exists, nothing to do.

pdata/pprofile/attributes_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func testPutAttribute(t *testing.T, record attributable) {
9494
require.Equal(t, indicesLen, record.AttributeIndices().Len())
9595

9696
// Set the last index to the table length, which is out of range.
97-
record.AttributeIndices().SetAt(indicesLen-1, int32(tableLen))
97+
record.AttributeIndices().SetAt(indicesLen-1, int32(tableLen)) //nolint:gosec
9898
// Try putting a new attribute, make sure it fails, and that table/indices didn't change.
9999
require.Error(t, PutAttribute(table, record, "newKey", pcommon.NewValueStr("value")))
100100
require.Equal(t, tableLen, table.Len())

0 commit comments

Comments
 (0)