We used to warn about casts to or from non-scalar types and only after we silently accept forced casts. But, while non-scalar casts are illegal C, in the kernel it's sometimes needed to use __force on non-scalar types. Avoid useless warning by checking for non-scalar types after having checked for forced casts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- evaluate.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/evaluate.c b/evaluate.c index db3b6b66a..194b97218 100644 --- a/evaluate.c +++ b/evaluate.c @@ -2962,9 +2962,6 @@ static struct symbol *evaluate_cast(struct expression *expr) if (ttype == &void_ctype) goto out; - if (tclass & (TYPE_COMPOUND | TYPE_FN)) - warning(expr->pos, "cast to non-scalar"); - stype = source->ctype; if (!stype) { expression_error(expr, "cast from unknown type"); @@ -2972,12 +2969,15 @@ static struct symbol *evaluate_cast(struct expression *expr) } sclass = classify_type(stype, &stype); - if (sclass & TYPE_COMPOUND) - warning(expr->pos, "cast from non-scalar"); - if (expr->type == EXPR_FORCE_CAST) goto out; + if (tclass & (TYPE_COMPOUND | TYPE_FN)) + warning(expr->pos, "cast to non-scalar"); + + if (sclass & TYPE_COMPOUND) + warning(expr->pos, "cast from non-scalar"); + /* allowed cast unfouls */ if (sclass & TYPE_FOULED) stype = unfoul(stype); -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html