[pbs-devel] [PATCH proxmox-backup 12/12] cleanup: remove unnecessary 'mut' and '.clone()'
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Jan 12 14:58:26 CET 2021
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/bin/proxmox-backup-client.rs | 2 +-
src/bin/proxmox-backup-proxy.rs | 2 +-
src/bin/proxmox_backup_client/mount.rs | 2 +-
src/client/backup_writer.rs | 5 +----
src/server/command_socket.rs | 2 +-
src/tools/async_channel_writer.rs | 2 +-
src/tools/broadcast_future.rs | 2 +-
tests/worker-task-abort.rs | 2 +-
8 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/bin/proxmox-backup-client.rs b/src/bin/proxmox-backup-client.rs
index d91f04cc..2cd00c2e 100644
--- a/src/bin/proxmox-backup-client.rs
+++ b/src/bin/proxmox-backup-client.rs
@@ -305,7 +305,7 @@ async fn backup_directory<P: AsRef<Path>>(
)?;
let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size);
- let (mut tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
+ let (tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
let stream = ReceiverStream::new(rx)
.map_err(Error::from);
diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs
index c8eb237c..39e8d537 100644
--- a/src/bin/proxmox-backup-proxy.rs
+++ b/src/bin/proxmox-backup-proxy.rs
@@ -164,7 +164,7 @@ async fn run() -> Result<(), Error> {
}
fn accept_connections(
- mut listener: tokio::net::TcpListener,
+ listener: tokio::net::TcpListener,
acceptor: Arc<openssl::ssl::SslAcceptor>,
debug: bool,
) -> tokio::sync::mpsc::Receiver<Result<std::pin::Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>, Error>> {
diff --git a/src/bin/proxmox_backup_client/mount.rs b/src/bin/proxmox_backup_client/mount.rs
index 204ed7fc..f8410709 100644
--- a/src/bin/proxmox_backup_client/mount.rs
+++ b/src/bin/proxmox_backup_client/mount.rs
@@ -294,7 +294,7 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
// poll until loop file is mapped (or errors)
select! {
- res = session_fut => {
+ _res = session_fut => {
bail!("FUSE session unexpectedly ended before loop file mapping");
},
res = st_recv.try_next() => {
diff --git a/src/client/backup_writer.rs b/src/client/backup_writer.rs
index bcbd6f28..e7a6d6bd 100644
--- a/src/client/backup_writer.rs
+++ b/src/client/backup_writer.rs
@@ -583,6 +583,7 @@ impl BackupWriter {
})
.merge_known_chunks()
.try_for_each(move |merged_chunk_info| {
+ let upload_queue = upload_queue.clone();
if let MergedChunkInfo::New(chunk_info) = merged_chunk_info {
let offset = chunk_info.offset;
@@ -610,7 +611,6 @@ impl BackupWriter {
let new_info = MergedChunkInfo::Known(vec![(offset, digest)]);
- let mut upload_queue = upload_queue.clone();
future::Either::Left(h2
.send_request(request, upload_data)
.and_then(move |response| async move {
@@ -621,7 +621,6 @@ impl BackupWriter {
})
)
} else {
- let mut upload_queue = upload_queue.clone();
future::Either::Right(async move {
upload_queue
.send((merged_chunk_info, None))
@@ -673,8 +672,6 @@ impl BackupWriter {
break;
}
- let mut upload_queue = upload_queue.clone();
-
if verbose { eprintln!("send test data ({} bytes)", data.len()); }
let request = H2Client::request_builder("localhost", "POST", "speedtest", None, None).unwrap();
let request_future = self.h2.send_request(request, Some(bytes::Bytes::from(data.clone()))).await?;
diff --git a/src/server/command_socket.rs b/src/server/command_socket.rs
index 08e59173..84d4e9fe 100644
--- a/src/server/command_socket.rs
+++ b/src/server/command_socket.rs
@@ -21,7 +21,7 @@ where
let backup_user = crate::backup::backup_user()?;
let backup_gid = backup_user.gid.as_raw();
- let mut socket = UnixListener::bind(&path)?;
+ let socket = UnixListener::bind(&path)?;
let func = Arc::new(func);
diff --git a/src/tools/async_channel_writer.rs b/src/tools/async_channel_writer.rs
index 4bb56ac5..f48bd555 100644
--- a/src/tools/async_channel_writer.rs
+++ b/src/tools/async_channel_writer.rs
@@ -58,7 +58,7 @@ impl AsyncChannelWriter {
}
}
- let mut sender = match self.sender.take() {
+ let sender = match self.sender.take() {
Some(sender) => sender,
None => return Poll::Ready(Err(io_err_other("no sender"))),
};
diff --git a/src/tools/broadcast_future.rs b/src/tools/broadcast_future.rs
index 1c82bdc3..3c96d2dc 100644
--- a/src/tools/broadcast_future.rs
+++ b/src/tools/broadcast_future.rs
@@ -159,7 +159,7 @@ fn test_broadcast_future() {
.map_err(|err| { panic!("got error {}", err); })
.map(|_| ());
- let mut rt = tokio::runtime::Runtime::new().unwrap();
+ let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
let r1 = tokio::spawn(receiver1);
let r2 = tokio::spawn(receiver2);
diff --git a/tests/worker-task-abort.rs b/tests/worker-task-abort.rs
index 5b73c8b9..7ec3958c 100644
--- a/tests/worker-task-abort.rs
+++ b/tests/worker-task-abort.rs
@@ -39,7 +39,7 @@ fn worker_task_abort() -> Result<(), Error> {
let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
let errmsg1 = errmsg.clone();
- let mut rt = tokio::runtime::Runtime::new().unwrap();
+ let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move {
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
--
2.20.1
More information about the pbs-devel
mailing list