From 82e26e2337ad344ec27112360afba138daa5c3f8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 3 May 2023 17:43:27 +0300 Subject: [PATCH] rosenberg: revert "initialization and struct assignments don't fill holes" This is a partial revert. Initialization mostly does fill holes. The exception is when you completely initialize the struct. I will take care of that in a later commit. Signed-off-by: Dan Carpenter --- check_rosenberg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/check_rosenberg.c b/check_rosenberg.c index 05f7b0ee..0de6f6cd 100644 --- a/check_rosenberg.c +++ b/check_rosenberg.c @@ -144,6 +144,19 @@ static int has_global_scope(struct expression *expr) return toplevel(sym->scope); } +static int was_initialized(struct expression *expr) +{ + struct symbol *sym; + char *name; + + name = expr_to_var_sym(expr, &sym); + if (!name) + return 0; + if (sym->initializer) + return 1; + return 0; +} + static void match_clear(const char *fn, struct expression *expr, void *_arg_no) { struct expression *ptr, *tmp; @@ -268,6 +281,8 @@ static void check_was_initialized(struct expression *data) if (has_global_scope(data)) return; + if (was_initialized(data)) + return; if (was_memset(data)) return; if (warn_on_holey_struct(data)) -- 2.11.4.GIT