Replace *[]string with []string in product variables
There is no need for *[]string, []string can already hold a nil
value to specify "not set".
Test: all soong tests
Change-Id: I85a51b042c12aee1565a9287d62924feeeafd486
diff --git a/android/arch.go b/android/arch.go
index 6aeccb0..953e6cf 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -1169,7 +1169,7 @@
targets := make(map[OsType][]Target)
var targetErr error
- addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
+ addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi []string) {
if targetErr != nil {
return
}
@@ -1358,7 +1358,7 @@
for _, config := range archConfigs {
arch, err := decodeArch(os, config.arch, &config.archVariant,
- &config.cpuVariant, &config.abi)
+ &config.cpuVariant, config.abi)
if err != nil {
return nil, err
}
@@ -1373,7 +1373,7 @@
}
// Convert a set of strings from product variables into a single Arch struct
-func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
+func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi []string) (Arch, error) {
stringPtr := func(p *string) string {
if p != nil {
return *p
@@ -1381,13 +1381,6 @@
return ""
}
- slicePtr := func(p *[]string) []string {
- if p != nil {
- return *p
- }
- return nil
- }
-
archType, ok := archTypeMap[arch]
if !ok {
return Arch{}, fmt.Errorf("unknown arch %q", arch)
@@ -1397,7 +1390,7 @@
ArchType: archType,
ArchVariant: stringPtr(archVariant),
CpuVariant: stringPtr(cpuVariant),
- Abi: slicePtr(abi),
+ Abi: abi,
Native: true,
}
diff --git a/android/config.go b/android/config.go
index 122b99b..7b22119 100644
--- a/android/config.go
+++ b/android/config.go
@@ -202,10 +202,10 @@
productVariables: productVariables{
DeviceName: stringPtr("test_device"),
Platform_sdk_version: intPtr(26),
- AAPTConfig: &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
+ AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
- AAPTPrebuiltDPI: &[]string{"xhdpi", "xxhdpi"},
+ AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
},
buildDir: buildDir,
@@ -476,10 +476,7 @@
}
func (c *config) ResourceOverlays() []string {
- if c.productVariables.ResourceOverlays == nil {
- return nil
- }
- return *c.productVariables.ResourceOverlays
+ return c.productVariables.ResourceOverlays
}
func (c *config) PlatformVersionName() string {
@@ -544,7 +541,7 @@
}
func (c *config) ProductAAPTConfig() []string {
- return stringSlice(c.productVariables.AAPTConfig)
+ return c.productVariables.AAPTConfig
}
func (c *config) ProductAAPTPreferredConfig() string {
@@ -556,7 +553,7 @@
}
func (c *config) ProductAAPTPrebuiltDPI() []string {
- return stringSlice(c.productVariables.AAPTPrebuiltDPI)
+ return c.productVariables.AAPTPrebuiltDPI
}
func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
@@ -734,10 +731,10 @@
func (c *config) EnforceRROForModule(name string) bool {
enforceList := c.productVariables.EnforceRROTargets
if enforceList != nil {
- if len(*enforceList) == 1 && (*enforceList)[0] == "*" {
+ if len(enforceList) == 1 && (enforceList)[0] == "*" {
return true
}
- return InList(name, *enforceList)
+ return InList(name, enforceList)
}
return false
}
@@ -745,7 +742,7 @@
func (c *config) EnforceRROExcludedOverlay(path string) bool {
excluded := c.productVariables.EnforceRROExcludedOverlays
if excluded != nil {
- for _, exclude := range *excluded {
+ for _, exclude := range excluded {
if strings.HasPrefix(path, exclude) {
return true
}
@@ -830,10 +827,7 @@
}
func (c *deviceConfig) SystemSdkVersions() []string {
- if c.config.productVariables.DeviceSystemSdkVersions == nil {
- return nil
- }
- return *c.config.productVariables.DeviceSystemSdkVersions
+ return c.config.productVariables.DeviceSystemSdkVersions
}
func (c *deviceConfig) PlatformSystemSdkVersions() []string {
@@ -876,12 +870,12 @@
func (c *deviceConfig) CoverageEnabledForPath(path string) bool {
coverage := false
if c.config.productVariables.CoveragePaths != nil {
- if PrefixInList(path, *c.config.productVariables.CoveragePaths) {
+ if PrefixInList(path, c.config.productVariables.CoveragePaths) {
coverage = true
}
}
if coverage && c.config.productVariables.CoverageExcludePaths != nil {
- if PrefixInList(path, *c.config.productVariables.CoverageExcludePaths) {
+ if PrefixInList(path, c.config.productVariables.CoverageExcludePaths) {
coverage = false
}
}
@@ -962,28 +956,28 @@
if c.productVariables.IntegerOverflowExcludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.IntegerOverflowExcludePaths)
+ return PrefixInList(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 PrefixInList(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 PrefixInList(path, c.productVariables.CFIIncludePaths)
}
func (c *config) XOMDisabledForPath(path string) bool {
if c.productVariables.XOMExcludePaths == nil {
return false
}
- return PrefixInList(path, *c.productVariables.XOMExcludePaths)
+ return PrefixInList(path, c.productVariables.XOMExcludePaths)
}
func (c *config) VendorConfig(name string) VendorConfig {
@@ -1035,11 +1029,3 @@
func (c *config) HiddenAPIExtraAppUsageJars() []string {
return c.productVariables.HiddenAPIExtraAppUsageJars
}
-
-func stringSlice(s *[]string) []string {
- if s != nil {
- return *s
- } else {
- return nil
- }
-}
diff --git a/android/variable.go b/android/variable.go
index 2cccd50..0904cea 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -144,18 +144,18 @@
Platform_vndk_version *string `json:",omitempty"`
Platform_systemsdk_versions []string `json:",omitempty"`
- DeviceName *string `json:",omitempty"`
- DeviceArch *string `json:",omitempty"`
- DeviceArchVariant *string `json:",omitempty"`
- DeviceCpuVariant *string `json:",omitempty"`
- DeviceAbi *[]string `json:",omitempty"`
- DeviceVndkVersion *string `json:",omitempty"`
- DeviceSystemSdkVersions *[]string `json:",omitempty"`
+ DeviceName *string `json:",omitempty"`
+ DeviceArch *string `json:",omitempty"`
+ DeviceArchVariant *string `json:",omitempty"`
+ DeviceCpuVariant *string `json:",omitempty"`
+ DeviceAbi []string `json:",omitempty"`
+ DeviceVndkVersion *string `json:",omitempty"`
+ DeviceSystemSdkVersions []string `json:",omitempty"`
- DeviceSecondaryArch *string `json:",omitempty"`
- DeviceSecondaryArchVariant *string `json:",omitempty"`
- DeviceSecondaryCpuVariant *string `json:",omitempty"`
- DeviceSecondaryAbi *[]string `json:",omitempty"`
+ DeviceSecondaryArch *string `json:",omitempty"`
+ DeviceSecondaryArchVariant *string `json:",omitempty"`
+ DeviceSecondaryCpuVariant *string `json:",omitempty"`
+ DeviceSecondaryAbi []string `json:",omitempty"`
HostArch *string `json:",omitempty"`
HostSecondaryArch *string `json:",omitempty"`
@@ -164,14 +164,14 @@
CrossHostArch *string `json:",omitempty"`
CrossHostSecondaryArch *string `json:",omitempty"`
- ResourceOverlays *[]string `json:",omitempty"`
- EnforceRROTargets *[]string `json:",omitempty"`
- EnforceRROExcludedOverlays *[]string `json:",omitempty"`
+ ResourceOverlays []string `json:",omitempty"`
+ EnforceRROTargets []string `json:",omitempty"`
+ EnforceRROExcludedOverlays []string `json:",omitempty"`
- AAPTCharacteristics *string `json:",omitempty"`
- AAPTConfig *[]string `json:",omitempty"`
- AAPTPreferredConfig *string `json:",omitempty"`
- AAPTPrebuiltDPI *[]string `json:",omitempty"`
+ AAPTCharacteristics *string `json:",omitempty"`
+ AAPTConfig []string `json:",omitempty"`
+ AAPTPreferredConfig *string `json:",omitempty"`
+ AAPTPrebuiltDPI []string `json:",omitempty"`
DefaultAppCertificate *string `json:",omitempty"`
@@ -207,14 +207,14 @@
DisableDexPreoptModules []string `json:",omitempty"`
DexPreoptProfileDir *string `json:",omitempty"`
- IntegerOverflowExcludePaths *[]string `json:",omitempty"`
+ IntegerOverflowExcludePaths []string `json:",omitempty"`
- EnableCFI *bool `json:",omitempty"`
- CFIExcludePaths *[]string `json:",omitempty"`
- CFIIncludePaths *[]string `json:",omitempty"`
+ EnableCFI *bool `json:",omitempty"`
+ CFIExcludePaths []string `json:",omitempty"`
+ CFIIncludePaths []string `json:",omitempty"`
- EnableXOM *bool `json:",omitempty"`
- XOMExcludePaths *[]string `json:",omitempty"`
+ EnableXOM *bool `json:",omitempty"`
+ XOMExcludePaths []string `json:",omitempty"`
VendorPath *string `json:",omitempty"`
OdmPath *string `json:",omitempty"`
@@ -224,9 +224,9 @@
ClangTidy *bool `json:",omitempty"`
TidyChecks *string `json:",omitempty"`
- NativeCoverage *bool `json:",omitempty"`
- CoveragePaths *[]string `json:",omitempty"`
- CoverageExcludePaths *[]string `json:",omitempty"`
+ NativeCoverage *bool `json:",omitempty"`
+ CoveragePaths []string `json:",omitempty"`
+ CoverageExcludePaths []string `json:",omitempty"`
DevicePrefer32BitApps *bool `json:",omitempty"`
DevicePrefer32BitExecutables *bool `json:",omitempty"`
@@ -306,16 +306,16 @@
DeviceArch: stringPtr("arm64"),
DeviceArchVariant: stringPtr("armv8-a"),
DeviceCpuVariant: stringPtr("generic"),
- DeviceAbi: &[]string{"arm64-v8a"},
+ DeviceAbi: []string{"arm64-v8a"},
DeviceSecondaryArch: stringPtr("arm"),
DeviceSecondaryArchVariant: stringPtr("armv8-a"),
DeviceSecondaryCpuVariant: stringPtr("generic"),
- DeviceSecondaryAbi: &[]string{"armeabi-v7a", "armeabi"},
+ DeviceSecondaryAbi: []string{"armeabi-v7a", "armeabi"},
- AAPTConfig: &[]string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
+ AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"},
AAPTPreferredConfig: stringPtr("xhdpi"),
AAPTCharacteristics: stringPtr("nosdcard"),
- AAPTPrebuiltDPI: &[]string{"xhdpi", "xxhdpi"},
+ AAPTPrebuiltDPI: []string{"xhdpi", "xxhdpi"},
Malloc_not_svelte: boolPtr(true),
Safestack: boolPtr(false),