4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 static int is_le16(struct symbol
*type
)
16 if (type
->ctype
.alignment
!= 2)
18 if (!(type
->ctype
.modifiers
& MOD_UNSIGNED
))
23 static void match_no_le16_param(const char *fn
, struct expression
*expr
, void *param
)
25 struct expression
*arg
;
29 arg
= get_argument_from_call_expr(expr
->args
, (int)param
);
30 arg
= strip_parens(arg
);
33 if (arg
->type
!= EXPR_FORCE_CAST
)
40 arg
= strip_expr(arg
);
41 name
= get_variable_from_expr_complex(arg
, NULL
);
42 sm_msg("warn: don't need to call cpu_to_le16() for '%s'", name
);
46 static void register_funcs_from_file(void)
52 token
= get_tokens_file("kernel.no_le16");
55 if (token_type(token
) != TOKEN_STREAMBEGIN
)
58 while (token_type(token
) != TOKEN_STREAMEND
) {
59 if (token_type(token
) != TOKEN_IDENT
)
61 func
= show_ident(token
->ident
);
63 if (token_type(token
) != TOKEN_NUMBER
)
65 arg
= atoi(token
->number
);
66 add_function_hook(func
, &match_no_le16_param
, INT_PTR(arg
));
72 void check_le16(int id
)
74 if (option_project
!= PROJ_KERNEL
)
79 register_funcs_from_file();