Use g_clear_handle_id() instead of g_source_remove() with
manual ID checking and zeroing.
This simplifies the code and ensures consistent handling of
GSource IDs, since g_clear_handle_id() checks for a non-zero
ID before calling the cleanup function and zeros it afterwards.
No functional change intended.
Mechanical change using the following Coccinelle spatch script:
@@
expression TAG;
@@
- if (TAG > 0) {
+ if (TAG) {
g_source_remove(TAG);
<... when != TAG
TAG = 0;
...>
}
@@
expression TAG;
@@
- g_source_remove(TAG);
- TAG = 0;
+ g_clear_handle_id(&TAG, g_source_remove);
@@
expression TAG;
@@
- if (TAG) {
g_clear_handle_id(&TAG, g_source_remove);
- }
Inspired-by: Matthew Penney <matt@matthewpenney.net>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Matthew Penney <matt@matthewpenney.net>
Message-Id: <20260408100605.66795-3-philmd@linaro.org>
To prepare for the implementation of '-net passt', this patch moves
the generic stream handling functions from net/stream.c into new
net/stream_data.c and net/stream_data.h files.
This refactoring introduces a NetStreamData struct that encapsulates
the generic fields and logic previously in NetStreamState. The
NetStreamState now embeds NetStreamData and delegates the core
stream operations to the new generic functions.
To maintain flexibility for different users of this generic code,
callbacks for send and listen operations are now passed via
function pointers within the NetStreamData struct. This allows
callers to provide their own specific implementations while reusing
the common connection and data transfer logic.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>