[PATCH] Use gtk_tree_model_get_value() to get the index and date of a dive

Linus Torvalds torvalds at linux-foundation.org
Wed Sep 19 10:25:16 PDT 2012


On Wed, Sep 19, 2012 at 1:10 AM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
>
> mingw-gcc 4.7, mingw-gcc 4.8 provides some of these in time.h as
> macros under POSIX (which is what they are):
>
> #ifndef gmtime_r
> #define gmtime_r(_Time,_Tm)     ({ struct tm *___tmp_tm =               \
>                                                 gmtime((_Time));        \
>                                                 if (___tmp_tm) {        \
>                                                   *(_Tm) = *___tmp_tm;  \
>                                                   ___tmp_tm = (_Tm);    \
>                                                 }                       \
>                                                 ___tmp_tm;      })
> #endif

The above is pure and utter garbage. It doesn't make any sense at all,
and isn't thread-safe in the least.

Anyway, none of this is needed. subsurface isn't really multi-threaded
anyway. The only time you have threads happening is when downloading
from a dive computer, and during that time the only thing subsurface
does is to call process_ui_events() in the other thread.

That assumes that the gtk main loop itself doesn't use gmtime(), or
course, but that had better be a fairly safe assumption.

In any case, the above kind of gmtime_r() does not help *anything* -
it just makes things worse, and makes code using gmtime_t compile, but
not actually *work* right.

Whoever wrote that sh*t should be shot. It's better to not compile at
all, than to compile to something that is wrong.

                Linus


More information about the subsurface mailing list