[PATCH] iftop: fix compilation with GCC 10

Rosen Penev rosenp at gmail.com
Fri Jul 17 18:26:01 EDT 2020


On Fri, Jul 17, 2020 at 3:49 AM Bjørn Mork <bjorn at mork.no> wrote:
>
> Rosen Penev <rosenp at gmail.com> writes:
> >> On Jul 17, 2020, at 3:06 AM, Felix Fietkau <nbd at nbd.name> wrote:
>
> >>> +--- a/ui_common.h
> >>> ++++ b/ui_common.h
> >>> +@@ -33,12 +33,12 @@ typedef struct host_pair_line_tag {
> >>> +
> >>> + extern options_t options;
> >>> +
> >>> +-sorted_list_type screen_list;
> >>> +-host_pair_line totals;
> >>> +-int peaksent, peakrecv, peaktotal;
> >>> ++static sorted_list_type screen_list;
> >>> ++static host_pair_line totals;
> >>> ++static int peaksent, peakrecv, peaktotal;
> >>> + extern history_type history_totals;
> >>> +-hash_type* screen_hash;
> >>> +-hash_type* service_hash;
> >>> ++static hash_type* screen_hash;
> >>> ++static hash_type* service_hash;
> >>
> >> Declaring these variables as static in a header file seems wrong to me.
> >> Shouldn't this be declared as a global variable in one of the .c files
> >> and extern here?
> >
> > Sure. static creates a smaller patch though.
>
> How does that help if the result is buggy?  I assume these variables are
> declared in a header because their values are actually shared.
Correct. -fno-common (the default in GCC10) mandates that variable
names be unique. No two variables can share the same name.

Interestingly enough, clang has a warning for this
(-Wmissing-variable-declarations).
>
>
> Bjørn
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list