From: Dan Carpenter Date: Fri, 15 Mar 2013 14:46:55 +0000 (+0300) Subject: user_data: the pointer returned from container_of() is ok X-Git-Tag: 1.59~258 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/ed779170a16dbd1c01d62aa0b1eae67f4c2e0b7b user_data: the pointer returned from container_of() is ok Normally if we do math the result is a user macro, but from container_of() it's probably not. Signed-off-by: Dan Carpenter --- diff --git a/check_user_data.c b/check_user_data.c index ef486aed..283868ab 100644 --- a/check_user_data.c +++ b/check_user_data.c @@ -115,6 +115,19 @@ free: return ret; } +static int in_container_of_macro(struct expression *expr) +{ + char *macro; + + macro = get_macro_name(expr->pos); + + if (!macro) + return 0; + if (strcmp(macro, "container_of") == 0) + return 1; + return 0; +} + int is_user_data(struct expression *expr) { struct state_list *slist = NULL; @@ -128,6 +141,8 @@ int is_user_data(struct expression *expr) if (is_capped(expr)) return 0; + if (in_container_of_macro(expr)) + return 0; if (is_user_macro(expr)) return 1;