diff --git a/infer/src/IR/Localise.ml b/infer/src/IR/Localise.ml index e93188297..c70016835 100644 --- a/infer/src/IR/Localise.ml +++ b/infer/src/IR/Localise.ml @@ -523,7 +523,7 @@ let desc_double_lock pname_opt object_str loc = let descriptions = [mutex_str; msg; at_line tags loc] in { no_desc with descriptions; tags = !tags } -let desc_unsafe_guarded_by_access pname accessed_fld guarded_by_str loc = +let desc_unsafe_guarded_by_access accessed_fld guarded_by_str loc = let line_info = at_line (Tags.create ()) loc in let accessed_fld_str = Fieldname.to_string accessed_fld in let annot_str = Printf.sprintf "@GuardedBy(\"%s\")" guarded_by_str in @@ -531,14 +531,15 @@ let desc_unsafe_guarded_by_access pname accessed_fld guarded_by_str loc = MF.monospaced_to_string (Printf.sprintf "synchronized(%s)" guarded_by_str) in let msg = Format.asprintf - "The field %a is annotated with %a, but the lock %a is not held during the access to the field %s. Consider wrapping the access in a %s block or annotating %s with %a" + "The field %a is annotated with %a, but the lock %a is not held during the access to the \ + field %s. Since the current method is non-private, it can be called from outside the \ + current class without synchronization. Consider wrapping the access in a %s block or making \ + the method private." MF.pp_monospaced accessed_fld_str MF.pp_monospaced annot_str MF.pp_monospaced guarded_by_str line_info - syncronized_str - (Typ.Procname.to_string pname) - MF.pp_monospaced annot_str in + syncronized_str in { no_desc with descriptions = [msg]; } diff --git a/infer/src/IR/Localise.mli b/infer/src/IR/Localise.mli index 38afe9b98..c0cc3c0a9 100644 --- a/infer/src/IR/Localise.mli +++ b/infer/src/IR/Localise.mli @@ -308,8 +308,7 @@ val desc_inherently_dangerous_function : Typ.Procname.t -> error_desc val desc_unary_minus_applied_to_unsigned_expression : string option -> string -> Location.t -> error_desc -val desc_unsafe_guarded_by_access : - Typ.Procname.t -> Fieldname.t -> string -> Location.t -> error_desc +val desc_unsafe_guarded_by_access : Fieldname.t -> string -> Location.t -> error_desc val desc_tainted_value_reaching_sensitive_function : PredSymb.taint_kind -> string -> Typ.Procname.t -> Typ.Procname.t -> Location.t -> error_desc diff --git a/infer/src/backend/rearrange.ml b/infer/src/backend/rearrange.ml index 617d04e86..faa977998 100644 --- a/infer/src/backend/rearrange.ml +++ b/infer/src/backend/rearrange.ml @@ -815,7 +815,7 @@ let add_guarded_by_constraints tenv prop lexp pdesc = let warn accessed_fld guarded_by_str = let loc = State.get_loc () in let err_desc = - Localise.desc_unsafe_guarded_by_access pname accessed_fld guarded_by_str loc in + Localise.desc_unsafe_guarded_by_access accessed_fld guarded_by_str loc in let exn = Exceptions.Unsafe_guarded_by_access (err_desc, __POS__) in Reporting.log_error pname exn in let rec is_read_write_lock typ =