[infer] model android.app.AlarmManager.cancel(PendingIntent) as not accepting a null parameter

Reviewed By: sblackshear

Differential Revision: D7378602

fbshipit-source-id: 94281a2
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 8cfbdef7e0
commit 2e14f9c9c3

@ -0,0 +1,19 @@
/*
* Copyright (c) 2018 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package android.app;
import android.app.PendingIntent;
public abstract class AlarmManager {
void cancel(PendingIntent operation) {
operation.cancel();
}
}

@ -178,7 +178,8 @@ let mapPut_list =
(** Models for @Nullable annotations *)
let annotated_list_nullable =
check_not_null_list @ check_state_list @ check_argument_list
@ [ (n1, "android.os.Parcel.writeList(java.util.List):void")
@ [ (o1, "android.app.AlarmManager.cancel(android.app.PendingIntent):void")
; (n1, "android.os.Parcel.writeList(java.util.List):void")
; (n2, "android.os.Parcel.writeParcelable(android.os.Parcelable,int):void")
; (n1, "android.os.Parcel.writeString(java.lang.String):void")
; ( (o, [o; o; n; n; n])

@ -11,13 +11,15 @@ package codetoanalyze.java.eradicate;
import com.google.common.base.Preconditions;
import java.lang.System;
import javax.annotation.Nullable;
import android.app.AlarmManager;
import android.app.PendingIntent;
import com.facebook.infer.annotation.Assertions;
import java.lang.System;
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nullable;
public class NullMethodCall {
@ -300,4 +302,9 @@ public class NullMethodCall {
return nullableField.toString();
}
void nullMethodCallWithAlarmManager(
AlarmManager manager, @Nullable PendingIntent intent) {
manager.cancel(intent);
}
}

@ -37,21 +37,22 @@ codetoanalyze/java/eradicate/NullFieldAccess.java, int NullFieldAccess.arrayLeng
codetoanalyze/java/eradicate/NullFieldAccess.java, int NullFieldAccess.useInterface(NullFieldAccess$I), 2, ERADICATE_NULL_FIELD_ACCESS, ERROR, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess$I.c at line 52)]
codetoanalyze/java/eradicate/NullFieldAccess.java, int NullFieldAccess.useX(), 2, ERADICATE_NULL_FIELD_ACCESS, ERROR, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.x at line 37)]
codetoanalyze/java/eradicate/NullFieldAccess.java, int NullFieldAccess.useZ(), 2, ERADICATE_NULL_FIELD_ACCESS, ERROR, [origin,Object `c` could be null when accessing field `NullFieldAccess$C.n`. (Origin: field NullFieldAccess.z at line 47)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall$Inner.outerField(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.fld at line 74)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall$Inner.outerPrivateField(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.pfld at line 85)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall.testSystemGetenvBad(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `envValue` in the call to `length()` could be null. (Origin: call to getenv(...) modelled in modelTables.ml at line 246)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(Object), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `NullMethodCall.nullableField` in the call to `toString()` could be null. (Origin: field NullMethodCall.nullableField at line 286)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall$Inner.outerField(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.fld at line 76)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall$Inner.outerPrivateField(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: field NullMethodCall.pfld at line 87)]
codetoanalyze/java/eradicate/NullMethodCall.java, int NullMethodCall.testSystemGetenvBad(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `envValue` in the call to `length()` could be null. (Origin: call to getenv(...) modelled in modelTables.ml at line 248)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.FP_propagatesNonNullAfterComparisonFieldOkay(Object), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `NullMethodCall.nullableField` in the call to `toString()` could be null. (Origin: field NullMethodCall.nullableField at line 288)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.FP_propagatesNonNullAfterComparisonParameterOkay(Object,Object), 3, ERADICATE_NULL_METHOD_CALL, ERROR, [The value of `nullableParameter` in the call to `toString()` could be null. (Origin: method parameter nullableParameter)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.callOnNull(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 25)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testExceptionPerInstruction(int), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 186)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testFieldAssignmentIfThenElse(String), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 177)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 4, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `m.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 269)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 5, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `hm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 270)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `chm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 271)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 4, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `m.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 278)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 5, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `hm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 279)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `chm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 280)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testSystemGetPropertyReturn(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 241)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.callOnNull(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 27)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.nullMethodCallWithAlarmManager(AlarmManager,PendingIntent), 2, ERADICATE_PARAMETER_NOT_NULLABLE, ERROR, [`cancel(...)` needs a non-null value in parameter 1 but argument `intent` can be null. (Origin: method parameter intent)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testExceptionPerInstruction(int), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 188)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testFieldAssignmentIfThenElse(String), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: null constant at line 179)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 4, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `m.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 271)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 5, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `hm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 272)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapGetBad(Map,HashMap,ConcurrentHashMap), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `chm.get(...)` in the call to `toString()` could be null. (Origin: call to get(...) modelled in modelTables.ml at line 273)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 4, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `m.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 280)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 5, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `hm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 281)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testMapRemoveBad(Map,HashMap,ConcurrentHashMap), 6, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `chm.remove(...)` in the call to `toString()` could be null. (Origin: call to remove(...) modelled in modelTables.ml at line 282)]
codetoanalyze/java/eradicate/NullMethodCall.java, void NullMethodCall.testSystemGetPropertyReturn(), 2, ERADICATE_NULL_METHOD_CALL, ERROR, [origin,The value of `s` in the call to `length()` could be null. (Origin: call to getProperty(...) modelled in modelTables.ml at line 243)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, ParameterNotNullable$ConstructorCall.<init>(ParameterNotNullable,int), 1, ERADICATE_PARAMETER_NOT_NULLABLE, ERROR, [origin,`ParameterNotNullable$ConstructorCall(...)` needs a non-null value in parameter 2 but argument `null` can be null. (Origin: null constant at line 102)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, String ParameterNotNullable.testSystemGetPropertyArgument(), 1, ERADICATE_PARAMETER_NOT_NULLABLE, ERROR, [origin,`getProperty(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 71)]
codetoanalyze/java/eradicate/ParameterNotNullable.java, String ParameterNotNullable.testSystemGetenvBad(), 1, ERADICATE_PARAMETER_NOT_NULLABLE, ERROR, [origin,`getenv(...)` needs a non-null value in parameter 1 but argument `null` can be null. (Origin: null constant at line 76)]

Loading…
Cancel
Save