[libvirt PATCH] util: Do not report useless error in virPortAllocatorRelease

Jiri Denemark posted 1 patch 1 year, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/19562943bd4ecaf5bf38db577b86c83fca6f2346.1652861303.git.jdenemar@redhat.com
src/util/virportallocator.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
[libvirt PATCH] util: Do not report useless error in virPortAllocatorRelease
Posted by Jiri Denemark 1 year, 11 months ago
If the port allocator bitmap does not have enough bits to keep the state
of the port we're going to release, the port is not reserved and thus is
trivially released without doing anything. No need to report an error in
such case.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/util/virportallocator.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index 44edd8f99a..97ab362749 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -254,12 +254,7 @@ virPortAllocatorRelease(unsigned short port)
         return 0;
 
     VIR_WITH_OBJECT_LOCK_GUARD(pa) {
-        if (virBitmapClearBit(pa->bitmap, port) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Failed to release port %d"),
-                           port);
-            return -1;
-        }
+        ignore_value(virBitmapClearBit(pa->bitmap, port));
     }
 
     return 0;
-- 
2.35.1
Re: [libvirt PATCH] util: Do not report useless error in virPortAllocatorRelease
Posted by Pavel Hrdina 1 year, 11 months ago
On Wed, May 18, 2022 at 10:08:23AM +0200, Jiri Denemark wrote:
> If the port allocator bitmap does not have enough bits to keep the state
> of the port we're going to release, the port is not reserved and thus is
> trivially released without doing anything. No need to report an error in
> such case.
> 
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  src/util/virportallocator.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>