three-eight-nine-ds-base/fix-using-borrow-on-a-double-reference.patch
2023-08-03 14:10:45 +08:00

56 lines
2.1 KiB
Diff

From 1d5586780b7144b3e1fa17b827f461b10f076be4 Mon Sep 17 00:00:00 2001
From: Simon Pichugin <spichugi@redhat.com>
Date: Mon, 24 Jul 2023 15:42:11 -0700
Subject: [PATCH] fix using borrow() on a double reference
Reference: https://github.com/389ds/389-ds-base/pull/5854
error: using `.borrow()` on a double reference, which returns
`&concread::cowcell::CowCellReadTxn<CacheStats>` instead of borrowing the inner type
We're getting the error about borrowing a double reference because
we're trying to borrow a type that is already a reference.
Fix - use the type directly.
---
src/librslapd/src/cache.rs | 4 +---
src/slapi_r_plugin/src/value.rs | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/librslapd/src/cache.rs b/src/librslapd/src/cache.rs
index 092c81d..b025c83 100644
--- a/src/librslapd/src/cache.rs
+++ b/src/librslapd/src/cache.rs
@@ -1,6 +1,5 @@
// This exposes C-FFI capable bindings for the concread concurrently readable cache.
use concread::arcache::{ARCache, ARCacheBuilder, ARCacheReadTxn, ARCacheWriteTxn};
-use std::borrow::Borrow;
use std::convert::TryInto;
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
@@ -56,8 +55,7 @@ pub extern "C" fn cache_char_stats(
debug_assert!(!cache.is_null());
&(*cache) as &ARCacheChar
};
- let stat_rguard = cache_ref.inner.view_stats();
- let stats = stat_rguard.borrow();
+ let stats = cache_ref.inner.view_stats();
*reader_hits = stats.reader_hits.try_into().unwrap();
*reader_includes = stats.reader_includes.try_into().unwrap();
*write_hits = stats.write_hits.try_into().unwrap();
diff --git a/src/slapi_r_plugin/src/value.rs b/src/slapi_r_plugin/src/value.rs
index cd56529..2fd35c8 100644
--- a/src/slapi_r_plugin/src/value.rs
+++ b/src/slapi_r_plugin/src/value.rs
@@ -182,7 +182,7 @@ impl From<&Uuid> for Value {
let s_ptr = cstr.as_ptr();
Box::leak(cstr);
- let mut v = unsafe { slapi_value_new() };
+ let v = unsafe { slapi_value_new() };
unsafe {
(*v).bv.len = len;
(*v).bv.data = s_ptr as *const u8;
--
2.27.0