2019-06-04 11:11:38 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-10-17 19:52:24 +03:00
|
|
|
/// Remove unneeded conversion to bool
|
|
|
|
///
|
|
|
|
//# Relational and logical operators evaluate to bool,
|
|
|
|
//# explicit conversion is overly verbose and unneeded.
|
|
|
|
//
|
2019-06-04 11:11:38 +03:00
|
|
|
// Copyright: (C) 2016 Andrew F. Davis <afd@ti.com>
|
2016-10-17 19:52:24 +03:00
|
|
|
|
|
|
|
virtual patch
|
|
|
|
virtual context
|
|
|
|
virtual org
|
|
|
|
virtual report
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// For patch mode
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
@depends on patch@
|
|
|
|
expression A, B;
|
|
|
|
symbol true, false;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
A == B
|
|
|
|
|
|
|
|
|
A != B
|
|
|
|
|
|
|
|
|
A > B
|
|
|
|
|
|
|
|
|
A < B
|
|
|
|
|
|
|
|
|
A >= B
|
|
|
|
|
|
|
|
|
A <= B
|
|
|
|
|
|
|
|
|
A && B
|
|
|
|
|
|
|
|
|
A || B
|
|
|
|
)
|
|
|
|
- ? true : false
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// For context mode
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
@r depends on !patch@
|
|
|
|
expression A, B;
|
|
|
|
symbol true, false;
|
|
|
|
position p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
A == B
|
|
|
|
|
|
|
|
|
A != B
|
|
|
|
|
|
|
|
|
A > B
|
|
|
|
|
|
|
|
|
A < B
|
|
|
|
|
|
|
|
|
A >= B
|
|
|
|
|
|
|
|
|
A <= B
|
|
|
|
|
|
|
|
|
A && B
|
|
|
|
|
|
|
|
|
A || B
|
|
|
|
)
|
|
|
|
* ? true : false@p
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// For org mode
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
@script:python depends on r&&org@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "WARNING: conversion to bool not needed here"
|
|
|
|
coccilib.org.print_todo(p[0], msg)
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// For report mode
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
|
|
|
@script:python depends on r&&report@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "WARNING: conversion to bool not needed here"
|
|
|
|
coccilib.report.print_report(p[0], msg)
|