Skip to content

Commit 2d30efd

Browse files
cmaglieFederico Fissore
authored and
Federico Fissore
committed
ctag parser: removed useless return errors
Signed-off-by: Cristian Maglie <[email protected]>
1 parent f15ff61 commit 2d30efd

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

Diff for: src/arduino.cc/builder/ctags_to_prototypes.go

+14-24
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ package builder
3232
import (
3333
"arduino.cc/builder/constants"
3434
"arduino.cc/builder/types"
35-
"arduino.cc/builder/utils"
3635
"strings"
3736
)
3837

@@ -41,10 +40,7 @@ type CTagsToPrototypes struct{}
4140
func (s *CTagsToPrototypes) Run(context map[string]interface{}) error {
4241
tags := context[constants.CTX_COLLECTED_CTAGS].([]*CTag)
4342

44-
lineWhereToInsertPrototypes, err := findLineWhereToInsertPrototypes(tags)
45-
if err != nil {
46-
return utils.WrapError(err)
47-
}
43+
lineWhereToInsertPrototypes := findLineWhereToInsertPrototypes(tags)
4844
if lineWhereToInsertPrototypes != -1 {
4945
context[constants.CTX_LINE_WHERE_TO_INSERT_PROTOTYPES] = lineWhereToInsertPrototypes
5046
}
@@ -55,36 +51,30 @@ func (s *CTagsToPrototypes) Run(context map[string]interface{}) error {
5551
return nil
5652
}
5753

58-
func findLineWhereToInsertPrototypes(tags []*CTag) (int, error) {
59-
firstFunctionLine, err := firstFunctionAtLine(tags)
60-
if err != nil {
61-
return -1, utils.WrapError(err)
62-
}
63-
firstFunctionPointerAsArgument, err := firstFunctionPointerUsedAsArgument(tags)
64-
if err != nil {
65-
return -1, utils.WrapError(err)
66-
}
54+
func findLineWhereToInsertPrototypes(tags []*CTag) int {
55+
firstFunctionLine := firstFunctionAtLine(tags)
56+
firstFunctionPointerAsArgument := firstFunctionPointerUsedAsArgument(tags)
6757
if firstFunctionLine != -1 && firstFunctionPointerAsArgument != -1 {
6858
if firstFunctionLine < firstFunctionPointerAsArgument {
69-
return firstFunctionLine, nil
59+
return firstFunctionLine
7060
} else {
71-
return firstFunctionPointerAsArgument, nil
61+
return firstFunctionPointerAsArgument
7262
}
7363
} else if firstFunctionLine == -1 {
74-
return firstFunctionPointerAsArgument, nil
64+
return firstFunctionPointerAsArgument
7565
} else {
76-
return firstFunctionLine, nil
66+
return firstFunctionLine
7767
}
7868
}
7969

80-
func firstFunctionPointerUsedAsArgument(tags []*CTag) (int, error) {
70+
func firstFunctionPointerUsedAsArgument(tags []*CTag) int {
8171
functionNames := collectFunctionNames(tags)
8272
for _, tag := range tags {
8373
if functionNameUsedAsFunctionPointerIn(tag, functionNames) {
84-
return tag.Line, nil
74+
return tag.Line
8575
}
8676
}
87-
return -1, nil
77+
return -1
8878
}
8979

9080
func functionNameUsedAsFunctionPointerIn(tag *CTag, functionNames []string) bool {
@@ -106,13 +96,13 @@ func collectFunctionNames(tags []*CTag) []string {
10696
return names
10797
}
10898

109-
func firstFunctionAtLine(tags []*CTag) (int, error) {
99+
func firstFunctionAtLine(tags []*CTag) int {
110100
for _, tag := range tags {
111101
if !tagIsUnknown(tag) && tag.IsHandled() && tag.Kind == KIND_FUNCTION {
112-
return tag.Line, nil
102+
return tag.Line
113103
}
114104
}
115-
return -1, nil
105+
return -1
116106
}
117107

118108
func toPrototypes(tags []*CTag) []*types.Prototype {

0 commit comments

Comments
 (0)