Skip to content

Commit f1daea0

Browse files
committed
Remove some empty if branches found by semgrep
1 parent b9e3905 commit f1daea0

File tree

9 files changed

+5
-14
lines changed

9 files changed

+5
-14
lines changed

src/analyses/base.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ struct
511511
if M.tracing then M.trace "reachability" "Checking value %a\n" VD.pretty value;
512512
match value with
513513
| Top ->
514-
if VD.is_immediate_type t then () else M.info ~category:Unsound "Unknown value in %s could be an escaped pointer address!" description; empty
514+
if not (VD.is_immediate_type t) then M.info ~category:Unsound "Unknown value in %s could be an escaped pointer address!" description; empty
515515
| Bot -> (*M.debug ~category:Analyzer "A bottom value when computing reachable addresses!";*) empty
516516
| Address adrs when AD.is_top adrs ->
517517
M.info ~category:Unsound "Unknown address in %s has escaped." description; AD.remove Addr.NullPtr adrs (* return known addresses still to be a bit more sane (but still unsound) *)

src/analyses/poisonVariables.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ struct
8282
M.info ~category:(Behavior (Undefined Other)) ~loc:(Node longjmp_node) "Since setjmp at %a, potentially all locals were modified! Reading them will yield Undefined Behavior." Node.pretty ctx.prev_node
8383
else if not (Queries.VS.is_empty modified_locals) then
8484
M.info ~category:(Behavior (Undefined Other)) ~loc:(Node longjmp_node) "Since setjmp at %a, locals %a were modified! Reading them will yield Undefined Behavior." Node.pretty ctx.prev_node Queries.VS.pretty modified_locals
85-
else
86-
()
8785
) longjmp_nodes;
8886
D.join modified_locals ctx.local
8987
| Access {ad; kind = Read; _} ->

src/cdomain/value/cdomains/arrayDomain.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,6 @@ let array_oob_check ( type a ) (module Idx: IntDomain.Z with type t = a) (x, l)
855855
| _ ->
856856
AnalysisStateUtil.set_mem_safety_flag InvalidDeref;
857857
M.warn ~category:M.Category.Behavior.Undefined.ArrayOutOfBounds.unknown "May access array out of bounds"
858-
else ()
859858

860859

861860
module TrivialWithLength (Val: LatticeWithInvalidate) (Idx: IntDomain.Z): S with type value = Val.t and type idx = Idx.t =

src/common/framework/cfgTools.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,6 @@ let getGlobalInits (file: file) : edges =
695695
Hashtbl.add inits (assign lval) ()
696696
else if not (Hashtbl.mem inits (assign (any_index lval))) then
697697
Hashtbl.add inits (assign (any_index lval)) ()
698-
else
699-
()
700698
| CompoundInit (typ, lst) ->
701699
let ntyp = match typ, lst with
702700
| TArray(t, None, attr), [] -> TArray(t, Some zero, attr) (* set initializer type to t[0] for flexible array members of structs that are intialized with {} *)

src/common/util/cilfacade.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ let do_preprocess ast =
8484
let f fd visitor_fun = ignore @@ visitCilFunction (visitor_fun fd) fd in
8585
if active_visitors <> [] then
8686
iterGlobals ast (function GFun (fd,_) -> List.iter (f fd) active_visitors | _ -> ())
87-
else
88-
()
8987

9088
(** @raise GoblintCil.FrontC.ParseError
9189
@raise GoblintCil.Errormsg.Error *)

src/framework/constraints.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ struct
17331733
let compare_locals h1 h2 =
17341734
let eq, le, gr, uk = ref 0, ref 0, ref 0, ref 0 in
17351735
let f k v1 =
1736-
if not (PP.mem h2 k) then () else
1736+
if PP.mem h2 k then
17371737
let v2 = PP.find h2 k in
17381738
let b1 = D.leq v1 v2 in
17391739
let b2 = D.leq v2 v1 in

src/solver/generic.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ module SoundBoxSolverImpl =
256256
H.replace called x ();
257257
(* set the new value for [x] *)
258258
eval_rhs_event x;
259-
let set_x d = if H.mem called x then set x d else () in
259+
let set_x d = if H.mem called x then set x d in
260260
Option.may (fun f -> set_x (f (eval x) side)) (S.system x);
261261
(* remove [x] from called *)
262262
H.remove called x

src/solver/sLR.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ module Make0 =
327327
let k = X.get_key x in
328328
let _ = work := H.insert !work x in
329329
let _ = P.rem_item stable x in
330-
if k >= sk then () else
330+
if k < sk then
331331
let _ = X.set_value x (D.bot ()) in
332332
(* ignore @@ Pretty.printf " also restarting %d: %a\n" k S.Var.pretty_trace x; *)
333333
(* flush_all (); *)
@@ -348,7 +348,7 @@ module Make0 =
348348
let (i,nonfresh) = X.get_index y in
349349
let _ = if xi <= i then HM.replace wpoint y () in
350350
let _ = if (V.ver>2) && xi <= i then work := H.insert (!work) y in
351-
let _ = if nonfresh then () else solve y in
351+
let _ = if not nonfresh then solve y in
352352
let _ = L.add infl y x in
353353
X.get_value y
354354

src/transform/evalAssert.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ module EvalAssert = struct
130130
[cStmt "{ %I:asserts %S:b }" (fun n t -> makeVarinfo true "unknown" (TVoid [])) b_loc [("asserts", FI b_assert_instr); ("b", FS block.bstmts)]]
131131
in
132132
block.bstmts <- with_asserts
133-
else
134-
()
135133
in
136134
if emit_other then (add_asserts b1; add_asserts b2);
137135
s

0 commit comments

Comments
 (0)