Loading android/arch.go +1 −6 Original line number Diff line number Diff line Loading @@ -1521,12 +1521,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) { // hasArmAbi returns true if arch has at least one arm ABI func hasArmAbi(arch Arch) bool { for _, abi := range arch.Abi { if strings.HasPrefix(abi, "arm") { return true } } return false return PrefixInList(arch.Abi, "arm") } // hasArmArch returns true if targets has at least non-native_bridge arm Android arch Loading android/config.go +6 −10 Original line number Diff line number Diff line Loading @@ -890,11 +890,7 @@ func (c *config) EnforceRROForModule(name string) bool { func (c *config) EnforceRROExcludedOverlay(path string) bool { excluded := c.productVariables.EnforceRROExcludedOverlays if excluded != nil { for _, exclude := range excluded { if strings.HasPrefix(path, exclude) { return true } } return HasAnyPrefix(path, excluded) } return false } Loading Loading @@ -1050,12 +1046,12 @@ func (c *deviceConfig) ClangCoverageEnabled() bool { func (c *deviceConfig) CoverageEnabledForPath(path string) bool { coverage := false if c.config.productVariables.CoveragePaths != nil { if InList("*", c.config.productVariables.CoveragePaths) || PrefixInList(path, c.config.productVariables.CoveragePaths) { if InList("*", c.config.productVariables.CoveragePaths) || HasAnyPrefix(path, c.config.productVariables.CoveragePaths) { coverage = true } } if coverage && c.config.productVariables.CoverageExcludePaths != nil { if PrefixInList(path, c.config.productVariables.CoverageExcludePaths) { if HasAnyPrefix(path, c.config.productVariables.CoverageExcludePaths) { coverage = false } } Loading Loading @@ -1128,21 +1124,21 @@ func (c *config) IntegerOverflowDisabledForPath(path string) bool { if c.productVariables.IntegerOverflowExcludePaths == nil { return false } return PrefixInList(path, c.productVariables.IntegerOverflowExcludePaths) return HasAnyPrefix(path, c.productVariables.IntegerOverflowExcludePaths) } func (c *config) CFIDisabledForPath(path string) bool { if c.productVariables.CFIExcludePaths == nil { return false } return PrefixInList(path, c.productVariables.CFIExcludePaths) return HasAnyPrefix(path, c.productVariables.CFIExcludePaths) } func (c *config) CFIEnabledForPath(path string) bool { if c.productVariables.CFIIncludePaths == nil { return false } return PrefixInList(path, c.productVariables.CFIIncludePaths) return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) } func (c *config) VendorConfig(name string) VendorConfig { Loading android/neverallow.go +2 −11 Original line number Diff line number Diff line Loading @@ -407,8 +407,8 @@ func (r *rule) String() string { } func (r *rule) appliesToPath(dir string) bool { includePath := len(r.paths) == 0 || hasAnyPrefix(dir, r.paths) excludePath := hasAnyPrefix(dir, r.unlessPaths) includePath := len(r.paths) == 0 || HasAnyPrefix(dir, r.paths) excludePath := HasAnyPrefix(dir, r.unlessPaths) return includePath && !excludePath } Loading Loading @@ -474,15 +474,6 @@ func fieldNamesForProperties(propertyNames string) []string { return names } func hasAnyPrefix(s string, prefixes []string) bool { for _, prefix := range prefixes { if strings.HasPrefix(s, prefix) { return true } } return false } func hasAnyProperty(properties []interface{}, props []ruleProperty) bool { for _, v := range props { if hasProperty(properties, v) { Loading android/util.go +2 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ func InList(s string, list []string) bool { } // Returns true if the given string s is prefixed with any string in the given prefix list. func PrefixInList(s string, prefixList []string) bool { func HasAnyPrefix(s string, prefixList []string) bool { for _, prefix := range prefixList { if strings.HasPrefix(s, prefix) { return true Loading @@ -132,7 +132,7 @@ func PrefixInList(s string, prefixList []string) bool { } // Returns true if any string in the given list has the given prefix. func PrefixedStringInList(list []string, prefix string) bool { func PrefixInList(list []string, prefix string) bool { for _, s := range list { if strings.HasPrefix(s, prefix) { return true Loading android/util_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ func TestPrefixInList(t *testing.T) { for _, testCase := range testcases { t.Run(testCase.str, func(t *testing.T) { out := PrefixInList(testCase.str, prefixes) out := HasAnyPrefix(testCase.str, prefixes) if out != testCase.expected { t.Errorf("incorrect output:") t.Errorf(" str: %#v", testCase.str) Loading Loading
android/arch.go +1 −6 Original line number Diff line number Diff line Loading @@ -1521,12 +1521,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) { // hasArmAbi returns true if arch has at least one arm ABI func hasArmAbi(arch Arch) bool { for _, abi := range arch.Abi { if strings.HasPrefix(abi, "arm") { return true } } return false return PrefixInList(arch.Abi, "arm") } // hasArmArch returns true if targets has at least non-native_bridge arm Android arch Loading
android/config.go +6 −10 Original line number Diff line number Diff line Loading @@ -890,11 +890,7 @@ func (c *config) EnforceRROForModule(name string) bool { func (c *config) EnforceRROExcludedOverlay(path string) bool { excluded := c.productVariables.EnforceRROExcludedOverlays if excluded != nil { for _, exclude := range excluded { if strings.HasPrefix(path, exclude) { return true } } return HasAnyPrefix(path, excluded) } return false } Loading Loading @@ -1050,12 +1046,12 @@ func (c *deviceConfig) ClangCoverageEnabled() bool { func (c *deviceConfig) CoverageEnabledForPath(path string) bool { coverage := false if c.config.productVariables.CoveragePaths != nil { if InList("*", c.config.productVariables.CoveragePaths) || PrefixInList(path, c.config.productVariables.CoveragePaths) { if InList("*", c.config.productVariables.CoveragePaths) || HasAnyPrefix(path, c.config.productVariables.CoveragePaths) { coverage = true } } if coverage && c.config.productVariables.CoverageExcludePaths != nil { if PrefixInList(path, c.config.productVariables.CoverageExcludePaths) { if HasAnyPrefix(path, c.config.productVariables.CoverageExcludePaths) { coverage = false } } Loading Loading @@ -1128,21 +1124,21 @@ func (c *config) IntegerOverflowDisabledForPath(path string) bool { if c.productVariables.IntegerOverflowExcludePaths == nil { return false } return PrefixInList(path, c.productVariables.IntegerOverflowExcludePaths) return HasAnyPrefix(path, c.productVariables.IntegerOverflowExcludePaths) } func (c *config) CFIDisabledForPath(path string) bool { if c.productVariables.CFIExcludePaths == nil { return false } return PrefixInList(path, c.productVariables.CFIExcludePaths) return HasAnyPrefix(path, c.productVariables.CFIExcludePaths) } func (c *config) CFIEnabledForPath(path string) bool { if c.productVariables.CFIIncludePaths == nil { return false } return PrefixInList(path, c.productVariables.CFIIncludePaths) return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) } func (c *config) VendorConfig(name string) VendorConfig { Loading
android/neverallow.go +2 −11 Original line number Diff line number Diff line Loading @@ -407,8 +407,8 @@ func (r *rule) String() string { } func (r *rule) appliesToPath(dir string) bool { includePath := len(r.paths) == 0 || hasAnyPrefix(dir, r.paths) excludePath := hasAnyPrefix(dir, r.unlessPaths) includePath := len(r.paths) == 0 || HasAnyPrefix(dir, r.paths) excludePath := HasAnyPrefix(dir, r.unlessPaths) return includePath && !excludePath } Loading Loading @@ -474,15 +474,6 @@ func fieldNamesForProperties(propertyNames string) []string { return names } func hasAnyPrefix(s string, prefixes []string) bool { for _, prefix := range prefixes { if strings.HasPrefix(s, prefix) { return true } } return false } func hasAnyProperty(properties []interface{}, props []ruleProperty) bool { for _, v := range props { if hasProperty(properties, v) { Loading
android/util.go +2 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ func InList(s string, list []string) bool { } // Returns true if the given string s is prefixed with any string in the given prefix list. func PrefixInList(s string, prefixList []string) bool { func HasAnyPrefix(s string, prefixList []string) bool { for _, prefix := range prefixList { if strings.HasPrefix(s, prefix) { return true Loading @@ -132,7 +132,7 @@ func PrefixInList(s string, prefixList []string) bool { } // Returns true if any string in the given list has the given prefix. func PrefixedStringInList(list []string, prefix string) bool { func PrefixInList(list []string, prefix string) bool { for _, s := range list { if strings.HasPrefix(s, prefix) { return true Loading
android/util_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ func TestPrefixInList(t *testing.T) { for _, testCase := range testcases { t.Run(testCase.str, func(t *testing.T) { out := PrefixInList(testCase.str, prefixes) out := HasAnyPrefix(testCase.str, prefixes) if out != testCase.expected { t.Errorf("incorrect output:") t.Errorf(" str: %#v", testCase.str) Loading