2 * sparse/check_template.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 * Idea from Michael Stefaniuc and Vincent BĂ©ron's earlier WtoA
14 * Apparently when you are coding WINE, you are not allowed to call
15 * functions that end in capital 'A' from functions that end in
26 static void match_function_def(struct symbol
*sym
)
28 char *func
= get_function();
36 if (func
[len
- 1] == 'W' && len
> 2 && func
[len
- 2] != 'A' )
42 static int allowed_func(const char *fn
)
44 if (!strcmp("lstrcatA", fn
))
46 if (!strcmp("lstrcpyA", fn
))
48 if (!strcmp("lstrcpynA", fn
))
50 if (!strcmp("lstrlenA", fn
))
55 static void match_call(struct expression
*expr
)
63 fn_name
= get_variable_from_expr(expr
->fn
, NULL
);
66 len
= strlen(fn_name
);
67 if (fn_name
[len
- 1] == 'A' && !allowed_func(fn_name
)) {
68 sm_msg("warn: WtoA call %s()", fn_name
);
74 void check_wine_WtoA(int id
)
76 if (option_project
!= PROJ_WINE
)
80 add_hook(&match_function_def
, FUNC_DEF_HOOK
);
81 add_hook(&match_call
, FUNCTION_CALL_HOOK
);