4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 static void match_no_le16_param(const char *fn
, struct expression
*expr
, void *param
)
16 struct expression
*arg
;
20 arg
= get_argument_from_call_expr(expr
->args
, (int)param
);
23 macro_name
= get_macro_name(&arg
->pos
);
24 if (!macro_name
|| strcmp(macro_name
, "cpu_to_le16"))
27 arg
= strip_expr(arg
);
28 name
= get_variable_from_expr_complex(arg
, NULL
);
29 sm_msg("warn: don't need to call cpu_to_le16() for '%s'", name
);
33 static void register_funcs_from_file(void)
39 token
= get_tokens_file("kernel.no_le16");
42 if (token_type(token
) != TOKEN_STREAMBEGIN
)
45 while (token_type(token
) != TOKEN_STREAMEND
) {
46 if (token_type(token
) != TOKEN_IDENT
)
48 func
= show_ident(token
->ident
);
50 if (token_type(token
) != TOKEN_NUMBER
)
52 arg
= atoi(token
->number
);
53 add_function_hook(func
, &match_no_le16_param
, INT_PTR(arg
));
59 void check_le16(int id
)
61 if (option_project
!= PROJ_KERNEL
)
64 register_funcs_from_file();