mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-06 00:55:56 +00:00
checkpatch: discourage use of API that uses numeric source IDs
The numeric source IDs exist from a time before 2000, when there was only one "GMainContext" singleton instance. Nowadays, the source ID is only relative to one GMainContext, and you'd have to track that association yourself. Als, g_source_remove() requires an additional hash lookup, when you could simply track the GSource instance from the start. This API should not be used anymore. Operate on GSouce instances direclty and use API like nm_clear_g_source_inst() nm_g_idle_add_source() nm_g_idle_souce_new() nm_g_source_attach() g_source_attach g_source_destroy g_source_unref etc. Note that if you don't care about to ever remove a source again, like scheduling an idle action that should not be cancelled, then g_idle_add(callback, user_data); is fine. It is only problematic to do something with those numeric IDs. checkpatch.pl would also flag those uses, but these are just warnings and in the few cases where such a warning is emitted wrongly, it's find to ignore them.
This commit is contained in:
parent
b9c10512cb
commit
5388542fc0
|
@ -191,6 +191,7 @@ complain ("This gtk-doc annotation looks wrong") if $line =~ /\*.*\( *(transfer-
|
|||
complain ("Prefer nm_assert() or g_return*() to g_assert*()") if $line =~ /g_assert/ and (not $filename =~ /\/tests\//) and (not $filename =~ /\/nm-test-/);
|
||||
complain ("Use gs_free_error with GError variables") if $line =~ /\bgs_free\b +GError *\*/;
|
||||
complain ("Don't use strcmp/g_strcmp0 unless you need to sort. Consider nm_streq()/nm_streq0(),NM_IN_STRSET() for testing equality") if $line =~ /\b(strcmp|g_strcmp0)\b/;
|
||||
complain ("Don't use API that uses the numeric source id. Instead, use GSource and API like nm_g_idle_add_source(), nm_clear_g_source_inst(), etc.") if $line =~ /\b(g_idle_add|g_idle_add_full|g_timeout_add|g_timeout_add_seconds|g_source_remove|nm_clear_g_source)\b/;
|
||||
#complain ("Use spaces instead of tabs") if $line =~ /\t/;
|
||||
|
||||
# Further on we process stuff without comments.
|
||||
|
|
Loading…
Reference in a new issue