Skip to content
  • Thomas Haller's avatar
    gsignal: let g_clear_signal_handler() evaluate argument only once · 7777f3bd
    Thomas Haller authored
    Preferably macros behave function-like to minimize surprises. That
    means for example that they evaluate all arguments exactly once.
    
    Rework g_clear_signal_handler() to assign the macro parameters
    to auto variables so they are accessed exactly once.
    
    Also, drop the static assert for the size of (*handler_id_ptr).
    As we now assign to a "gulong *" pointer, the compiler already
    checks the types. In fact, the check is now stricter than before.
    Previously it would have allowed a pointer to a "signed long".
    This is a change in behavior of the macro and the stricter compile
    check could cause a build failure with broken code.
    
    Also, clear the handler id first, before calling
    g_signal_handler_disconnect(). Disconnecting a signal invokes the
    destroy notify, which can have side effects. It just feels cleaner
    to first reset the *_handler_id_ptr, before those side effects
    can happen. Of course, in practice it makes little difference.
    7777f3bd