* [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again)
@ 2020-09-08 22:16 Masahiro Yamada
2020-09-08 22:16 ` [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning Masahiro Yamada
2020-09-10 17:24 ` [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Nick Desaulniers
0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2020-09-08 22:16 UTC (permalink / raw)
To: linux-kbuild
Cc: Masahiro Yamada, Mauro Carvalho Chehab, Nathan Chancellor,
Nick Desaulniers, clang-built-linux, linux-kernel
Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete
to free array") fixed two lines, but there is one more.
(cppcheck does not report it for some reason...)
This was detected by Clang.
"make HOSTCXX=clang++ xconfig" reports the following:
scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
delete data;
^
[]
scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here
char *data = new char[count + 1];
^
Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again")
Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/kconfig/qconf.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 8638785328a7..c7216b9110fc 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1276,7 +1276,7 @@ void ConfigInfoView::clicked(const QUrl &url)
}
free(result);
- delete data;
+ delete[] data;
}
void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning 2020-09-08 22:16 [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Masahiro Yamada @ 2020-09-08 22:16 ` Masahiro Yamada 2020-09-09 14:09 ` Boris Kolpackov 2020-09-10 17:24 ` [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Nick Desaulniers 1 sibling, 1 reply; 6+ messages in thread From: Masahiro Yamada @ 2020-09-08 22:16 UTC (permalink / raw) To: linux-kbuild Cc: Masahiro Yamada, Nathan Chancellor, Nick Desaulniers, clang-built-linux, linux-kernel "make HOSTCXX=clang++ xconfig" reports the following: HOSTCXX scripts/kconfig/qconf.o In file included from scripts/kconfig/qconf.cc:23: In file included from scripts/kconfig/lkc.h:15: scripts/kconfig/lkc_proto.h:26:13: warning: 'get_relations_str' has C-linkage specified, but returns incomplete type 'struct gstr' which could be incompatible with C [-Wreturn-type-c-linkage] struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); ^ Currently, get_relations_str() is declared before the struct gstr definition. Move all declarations of menu.c functions below. BTW, some are declared in lkc.h and some in lkc_proto.h, but the difference is unclear. I guess some refactoring is needed. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> --- scripts/kconfig/lkc.h | 47 +++++++++++++++++++++++-------------- scripts/kconfig/lkc_proto.h | 14 ----------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index d4ca8297364f..8454649b17bd 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -66,23 +66,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) fprintf(stderr, "Error in writing or end of file.\n"); } -/* menu.c */ -void _menu_init(void); -void menu_warn(struct menu *menu, const char *fmt, ...); -struct menu *menu_add_menu(void); -void menu_end_menu(void); -void menu_add_entry(struct symbol *sym); -void menu_add_dep(struct expr *dep); -void menu_add_visibility(struct expr *dep); -struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); -void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); -void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option_modules(void); -void menu_add_option_defconfig_list(void); -void menu_add_option_allnoconfig_y(void); -void menu_finalize(struct menu *parent); -void menu_set_type(int type); - /* util.c */ struct file *file_lookup(const char *name); void *xmalloc(size_t size); @@ -109,6 +92,36 @@ void str_append(struct gstr *gs, const char *s); void str_printf(struct gstr *gs, const char *fmt, ...); const char *str_get(struct gstr *gs); +/* menu.c */ +void _menu_init(void); +void menu_warn(struct menu *menu, const char *fmt, ...); +struct menu *menu_add_menu(void); +void menu_end_menu(void); +void menu_add_entry(struct symbol *sym); +void menu_add_dep(struct expr *dep); +void menu_add_visibility(struct expr *dep); +struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); +void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); +void menu_add_option_modules(void); +void menu_add_option_defconfig_list(void); +void menu_add_option_allnoconfig_y(void); +void menu_finalize(struct menu *parent); +void menu_set_type(int type); + +extern struct menu rootmenu; + +bool menu_is_empty(struct menu *menu); +bool menu_is_visible(struct menu *menu); +bool menu_has_prompt(struct menu *menu); +const char *menu_get_prompt(struct menu *menu); +struct menu *menu_get_root_menu(struct menu *menu); +struct menu *menu_get_parent_menu(struct menu *menu); +bool menu_has_help(struct menu *menu); +const char *menu_get_help(struct menu *menu); +struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); +void menu_get_ext_help(struct menu *menu, struct gstr *help); + /* symbol.c */ void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index f9ab98238aef..9e81be33c40f 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -12,20 +12,6 @@ bool conf_get_changed(void); void conf_set_changed_callback(void (*fn)(void)); void conf_set_message_callback(void (*fn)(const char *s)); -/* menu.c */ -extern struct menu rootmenu; - -bool menu_is_empty(struct menu *menu); -bool menu_is_visible(struct menu *menu); -bool menu_has_prompt(struct menu *menu); -const char * menu_get_prompt(struct menu *menu); -struct menu * menu_get_root_menu(struct menu *menu); -struct menu * menu_get_parent_menu(struct menu *menu); -bool menu_has_help(struct menu *menu); -const char * menu_get_help(struct menu *menu); -struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); -void menu_get_ext_help(struct menu *menu, struct gstr *help); - /* symbol.c */ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning 2020-09-08 22:16 ` [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning Masahiro Yamada @ 2020-09-09 14:09 ` Boris Kolpackov 2020-09-17 16:07 ` Masahiro Yamada 0 siblings, 1 reply; 6+ messages in thread From: Boris Kolpackov @ 2020-09-09 14:09 UTC (permalink / raw) To: Masahiro Yamada Cc: linux-kbuild, Nathan Chancellor, Nick Desaulniers, clang-built-linux, linux-kernel Masahiro Yamada <masahiroy@kernel.org> writes: > Currently, get_relations_str() is declared before the struct gstr > definition. Yes, I also ran into this while building the kconfig code with MSVC. I just moved the struct gstr definition before lkc_proto.h #include but your fix works just as well. Acked-by: Boris Kolpackov <boris@codesynthesis.com> > BTW, some are declared in lkc.h and some in lkc_proto.h, but the > difference is unclear. I guess some refactoring is needed. Yes, please. My (potentially incorrect) understanding is that lkc_proto.h was for functions that are not (or should not be) used by clients but should nevertheless have prototypes due to -Wmissing-prototypes. I, however, believe this no longer holds and so would vote to merge lkc_proto.h into lkc.h. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning 2020-09-09 14:09 ` Boris Kolpackov @ 2020-09-17 16:07 ` Masahiro Yamada 0 siblings, 0 replies; 6+ messages in thread From: Masahiro Yamada @ 2020-09-17 16:07 UTC (permalink / raw) To: Boris Kolpackov Cc: Linux Kbuild mailing list, Nathan Chancellor, Nick Desaulniers, clang-built-linux, Linux Kernel Mailing List On Wed, Sep 9, 2020 at 11:09 PM Boris Kolpackov <boris@codesynthesis.com> wrote: > > Masahiro Yamada <masahiroy@kernel.org> writes: > > > Currently, get_relations_str() is declared before the struct gstr > > definition. > > Yes, I also ran into this while building the kconfig code with MSVC. > I just moved the struct gstr definition before lkc_proto.h #include > but your fix works just as well. > > Acked-by: Boris Kolpackov <boris@codesynthesis.com> > > > > BTW, some are declared in lkc.h and some in lkc_proto.h, but the > > difference is unclear. I guess some refactoring is needed. > > Yes, please. My (potentially incorrect) understanding is that lkc_proto.h > was for functions that are not (or should not be) used by clients but > should nevertheless have prototypes due to -Wmissing-prototypes. I, > however, believe this no longer holds and so would vote to merge > lkc_proto.h into lkc.h. > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/boris.20200909155725%40codesynthesis.com. Applied to linux-kbuild/fixes. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) 2020-09-08 22:16 [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Masahiro Yamada 2020-09-08 22:16 ` [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning Masahiro Yamada @ 2020-09-10 17:24 ` Nick Desaulniers 2020-09-17 16:08 ` Masahiro Yamada 1 sibling, 1 reply; 6+ messages in thread From: Nick Desaulniers @ 2020-09-10 17:24 UTC (permalink / raw) To: Masahiro Yamada Cc: Linux Kbuild mailing list, Mauro Carvalho Chehab, Nathan Chancellor, clang-built-linux, LKML On Tue, Sep 8, 2020 at 3:17 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete > to free array") fixed two lines, but there is one more. > (cppcheck does not report it for some reason...) > > This was detected by Clang. > > "make HOSTCXX=clang++ xconfig" reports the following: > > scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] > delete data; > ^ > [] > scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here > char *data = new char[count + 1]; > ^ > > Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again") > Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array") > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > --- > > scripts/kconfig/qconf.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc > index 8638785328a7..c7216b9110fc 100644 > --- a/scripts/kconfig/qconf.cc > +++ b/scripts/kconfig/qconf.cc > @@ -1276,7 +1276,7 @@ void ConfigInfoView::clicked(const QUrl &url) > } > > free(result); > - delete data; > + delete[] data; > } > > void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) > -- > 2.25.1 > -- Thanks, ~Nick Desaulniers ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) 2020-09-10 17:24 ` [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Nick Desaulniers @ 2020-09-17 16:08 ` Masahiro Yamada 0 siblings, 0 replies; 6+ messages in thread From: Masahiro Yamada @ 2020-09-17 16:08 UTC (permalink / raw) To: Nick Desaulniers Cc: Linux Kbuild mailing list, Mauro Carvalho Chehab, Nathan Chancellor, clang-built-linux, LKML On Fri, Sep 11, 2020 at 2:24 AM 'Nick Desaulniers' via Clang Built Linux <clang-built-linux@googlegroups.com> wrote: > > On Tue, Sep 8, 2020 at 3:17 PM Masahiro Yamada <masahiroy@kernel.org> wrote: > > > > Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete > > to free array") fixed two lines, but there is one more. > > (cppcheck does not report it for some reason...) > > > > This was detected by Clang. > > > > "make HOSTCXX=clang++ xconfig" reports the following: > > > > scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] > > delete data; > > ^ > > [] > > scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here > > char *data = new char[count + 1]; > > ^ > > > > Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again") > > Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array") > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> > > > --- > > > > scripts/kconfig/qconf.cc | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc > > index 8638785328a7..c7216b9110fc 100644 > > --- a/scripts/kconfig/qconf.cc > > +++ b/scripts/kconfig/qconf.cc > > @@ -1276,7 +1276,7 @@ void ConfigInfoView::clicked(const QUrl &url) > > } > > > > free(result); > > - delete data; > > + delete[] data; > > } > > > > void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) > > -- > > 2.25.1 > > > > > -- > Thanks, > ~Nick Desaulniers > > -- > You received this message because you are subscribed to the Google Groups "Clang Built Linux" group. > To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CAKwvOdnP7UmpRPL8XjzoMPjgQb9Di8OXk9UEX8NWaa35A01Q3Q%40mail.gmail.com. Applied to linux-kbuild/fixes. -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-17 16:20 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-09-08 22:16 [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Masahiro Yamada 2020-09-08 22:16 ` [PATCH 2/2] kconfig: fix incomplete type 'struct gstr' warning Masahiro Yamada 2020-09-09 14:09 ` Boris Kolpackov 2020-09-17 16:07 ` Masahiro Yamada 2020-09-10 17:24 ` [PATCH 1/2] kconfig: qconf: use delete[] instead of delete to free array (again) Nick Desaulniers 2020-09-17 16:08 ` Masahiro Yamada
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox