From nobody Mon Jul 21 06:17:13 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4blqtd6DkWz62Cmw; Mon, 21 Jul 2025 06:17:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4blqtd3SyPz3Sjv; Mon, 21 Jul 2025 06:17:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ko4PgCZn9aYjpZBV1Nd7aEP48ElF2OSc8h9e74TgzFI=; b=VB51vFwkyW3tIsNJK9M4hiUT01MIDVbXylVpBv0zv1oYFK0a2GP33upf4JVkM/hB5SCd+b d2ynN75OxF2ght0ysInP75g+dly5jhH2B/nk9gLMmAN9QwDNXEl6iypfdU9YmJsB/c1gGU vS96p+A9f+lo/hPtDyrqpWIFW8ixSiDpDAd1Btenv5xjItDvRCWMJDAVTNpCb2ileGGYoK B0NCeLHZdE2xlhXQU3OHKc3UOta3DdCIHNFZsw9j3TGzyvRef3rJyms9qgJYW23EO3suAs i+2DdRwGM0fpjuqznB0e616ih0yYk+8rK6HVJckhuMhsXb2AyoBqFJQ7z9P8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1753078633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Ko4PgCZn9aYjpZBV1Nd7aEP48ElF2OSc8h9e74TgzFI=; b=csg0A+ODgvsmDxJ3Vaw+4BDL69eFGmzG4jmnCa1rjw9nFwlqJ99HPfcOWcH321JkFoz4C3 kfOriOtL+vSG+P2gd8mtLBlGb4F56QvfXQpkAeopbae0SW8vqZJoPKygxovtu1g+Pu3ZJg Ff+QG1kuVJWXw3WPxLvLaILB57TMQmkNira9Y0j4hPreFis5Wb3JJJHOIZk0dIXL7CTCgn T/+d5zr2EzCnzdwqjexL152QCEtaOaTMnnHT5vcPjN+jgFAs4iiDxNNa1htJpnOcA8iNZi dpXq9uW+qUAuuzJO72RPTWtBQiKkBPeHDCJu+Cw2qy2HENzIK9bV9yFyA+CKgQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1753078633; a=rsa-sha256; cv=none; b=AVlEeFeupR10TWwQxJbvNkK5Kgu9f6oI5S4Ul5v/e61iIS7OMp8F56Dnuz06ZX8nqYvDGA 4X4emDoON6zJCZMyahcuNPs1h60c8LkCzAFqXLtxsSZjQiPzgnaBu8VhKSEKICrJgTFKYf YsG3ve6FR1K7jdFxX3cGujfedlW7rsudAb9SxV9LFGJqFCJmsUIScF+mXIE4oxC7E35i+s XzO48KDUPbguu75BUGakys5UUmREZva4jrbtOuzlTFV5gOp6f/vCTJkZmR6RuZZGV5GTl0 h7o7AUWEqM0XtoypC+8uum4vMbrK+/2HEtnIf0Xch0r9devnmSFzxuKcWoS9Pg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4blqtd2MRyzmVR; Mon, 21 Jul 2025 06:17:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56L6HDYt071268; Mon, 21 Jul 2025 06:17:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56L6HD8M071265; Mon, 21 Jul 2025 06:17:13 GMT (envelope-from git) Date: Mon, 21 Jul 2025 06:17:13 GMT Message-Id: <202507210617.56L6HD8M071265@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 1c675fb36545 - main - libusb: implement libusb_free_pollfds List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1c675fb36545e9da8eef995140275263fd169d3b Auto-Submitted: auto-generated The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=1c675fb36545e9da8eef995140275263fd169d3b commit 1c675fb36545e9da8eef995140275263fd169d3b Author: ShengYi Hung AuthorDate: 2025-07-09 07:38:17 +0000 Commit: ShengYi Hung CommitDate: 2025-07-21 06:15:15 +0000 libusb: implement libusb_free_pollfds libusb provides an API that frees the storage for pollfds regardless of their contents. It does not check whether the file descriptors inside are already closed. Approved by: markj (mentor), lwhsu(mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51221 --- lib/libusb/libusb.3 | 6 ++++++ lib/libusb/libusb.h | 3 ++- lib/libusb/libusb10_io.c | 9 +++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 74b85d4aa17e..da927f8985a8 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -775,6 +775,12 @@ argument can be either of LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED or LIBUSB_HOTPLUG_ .Ft void .Fn libusb_hotplug_deregister_callback "libusb_context *ctx" "libusb_hotplug_callback_handle handle" This function unregisters a hotplug filter. +.Pp +.Ft void +.Fn libusb_free_pollfds "const struct libusb_pollfd **pollfds" +This function releases the memory storage in +.Fa pollfds , +and is safe to call when the argument is NULL. .Sh LIBUSB VERSION 0.1 COMPATIBILITY The library is also compliant with LibUSB version 0.1.12. .Pp diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 6fb1c19fad13..1962152c0b68 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -573,7 +573,8 @@ int libusb_handle_events(libusb_context * ctx); int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv); int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv); void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); -const struct libusb_pollfd **libusb_get_pollfds(libusb_context * ctx); +const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx); +void libusb_free_pollfds(const struct libusb_pollfd **pollfds); /* Synchronous device I/O */ diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c index dd541b09caa6..ea365162df5a 100644 --- a/lib/libusb/libusb10_io.c +++ b/lib/libusb/libusb10_io.c @@ -842,3 +842,12 @@ libusb_transfer_get_stream_id(struct libusb_transfer *transfer) /* get stream ID */ return (sxfer->stream_id); } + +void +libusb_free_pollfds(const struct libusb_pollfd **pollfds) +{ + if (pollfds == NULL) + return; + + free(pollfds); +}