2 * smatch/check_return.c
4 * Copyright (C) 2011 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 #include "smatch_slist.h"
15 static void match_return(struct expression
*ret_value
)
17 struct expression
*expr
;
23 if (ret_value
->type
!= EXPR_PREOP
|| ret_value
->op
!= '-')
26 macro
= get_macro_name(expr
->unop
->pos
);
27 if (macro
&& !strcmp(macro
, "PTR_ERR")) {
28 sm_msg("warn: returning -%s()", macro
);
35 expr
= get_assigned_expr(ret_value
->unop
);
38 if (expr
->type
!= EXPR_CALL
)
41 sm_msg("warn: should this return really be negated?");
44 void check_return_negative_var(int id
)
46 if (option_project
!= PROJ_KERNEL
)
50 add_hook(&match_return
, RETURN_HOOK
);