Commit Graph

14 Commits

Author SHA1 Message Date
Cole Faust 0e5057e106 Fix errorprone warnings that should be errors
This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I7625fa386afe93823b97cb2ecb8fd09a5856c05b

Former-commit-id: 22f05839f5
2022-11-02 10:13:14 -07:00
Maciej Żenczykowski 0ba23a5ac8 CookieTagMapValue.java - uid U32 -> S32
The kernel is actually not consistent in whether uids & gids
are signed or unsigned, and neither is our Java code, which
also commonly uses just 'int' for uid.  In practice values
greater or equal to 2**31 often don't quite work right.
For example icmp sockets are enabled via a sysctl that
takes a minimum and maximum gid - and these are signed int32s.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6576798cfeb52bf5574bf6853f0f7378022b3a2f
2022-09-17 01:53:47 +00:00
Maciej Żenczykowski e1e03ea435 Merge "ClatEgress4Value.java - replace U32 ifindex with S32" 2022-09-16 17:58:32 +00:00
Maciej Żenczykowski 53a5c00d41 Merge "ClatEgress4Key.java - replace U32 ifindex with S32" 2022-09-16 17:54:30 +00:00
Maciej Żenczykowski 6dbae5ceef Merge changes I9008e20f,I96403646,Ic05adfc4
* changes:
  ClatIngress6Key.java - replace U32 ifindex with S32
  TetherStatsKey.java - replace U32 ifindex with S32
  handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
2022-09-16 17:52:14 +00:00
Maciej Żenczykowski def4359b85 ClatEgress4Value.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9c157a57278dcd43b464c853d1107a933c1fd8df
2022-09-16 06:57:45 +00:00
Maciej Żenczykowski b62de2887b ClatIngress6Value.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iab2d4a13bf7ba45bbe8627adfdfb830f3219bc7b
2022-09-16 06:57:40 +00:00
Maciej Żenczykowski 5d034e7f7a ClatEgress4Key.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Surprisingly it appears no further fixups are required
to make this compile, due to other places already being 'int's.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5a48f12e0fc6274debf645a087f5f3857d90be62
2022-09-16 06:40:07 +00:00
Maciej Żenczykowski b56f69c600 ClatIngress6Key.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Surprisingly it appears no further fixups are required
to make this compile, due to other places already being 'int's.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9008e20f40c983a1bb8a0547a61190f28042b22a
2022-09-16 06:39:57 +00:00
Maciej Żenczykowski fb8e40eaed TetherStatsKey.java - replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Bug: 245472520
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I964036469fe7e0cfa77d9b062bfdbf5d2ae99bf2
2022-09-16 06:36:57 +00:00
Maciej Żenczykowski 49e9660e0e handle "TODO: remove equals/hashCode/toString once aosp/1536721 merged"
aosp/1536721 is merged, so this code duplication should not be needed any more.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic05adfc46495086d7f681322aac7acddc30a2260
2022-09-16 06:35:32 +00:00
Maciej Żenczykowski 09813ced3e replace U32 ifindex with S32
These are allocated in order by the kernel, if we go
over 2 billion, we've got other problems... besides
U32 to S32 conversion will work just fine anyway.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifbb7139e9118dd2d0c52e83c5874132e03760b30
2022-08-18 01:07:11 +00:00
Hungming Chen ef0280288e Move struct CookieTagMap{Key, Value} to Connectivity/common
Need to share struct CookieTagMap{Key, Value} with:
service/src/com/android/server/connectivity/ClatCoordinator.java
service-t/src/com/android/server/net/NetworkStatsService.java
tests/unit/java/com/android/server/connectivity/ClatCoordinatorTest.java
tests/unit/java/com/android/server/net/NetworkStatsServiceTest.java

These files only have different package name as expected.

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapKey.java service-t/src/com/android/server/net/CookieTagMapKey.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

$ diff common/src/com/android/net/module/util/bpf/CookieTagMapValue.java service-t/src/com/android/server/net/CookieTagMapValue.java
  17c17
  <- package com.android.net.module.util.bpf;
  ---
  -> package com.android.server.net;

Bug: 237369591
Test: atest ConnectivityCoverageTests
Change-Id: Ibede81376382f0dd7a032c8c988dd84c7422eece
2022-07-23 03:18:55 +08:00
Hungming Chen 01f2550ac4 Move struct {Clat*, Tether4*, TetherStats*} to connectivity module
Needed because these struct classes should not be exposed.
Only used for the connectivity module and its tests.

Bug: 234160319
Test: atest ConnectivityCoverageTests

The moved files are identical.

diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatIngress6Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatIngress6Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Key.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/Tether4Value.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/Tether4Value.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsKey.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsKey.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/TetherStatsValue.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/TetherStatsValue.java
diff packages/modules/Connectivity/common/src/com/android/net/module/util/bpf/ClatEgress4Key.java frameworks/libs/net/common/device/com/android/net/module/util/bpf/ClatEgress4Key.java
(no diff)

Change-Id: I4ce8045150bdbf04c63c5262c58a0ebcc30d395c
2022-06-29 11:34:19 +00:00