net_util: tap: remove needless copy

One can call `to_vec()` anyway if one needs an owned copy. This change
further helps to prevent needless copies in upcoming changes.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster 2025-06-17 12:37:13 +02:00 committed by Rob Bradford
parent 3864230430
commit b8be33dff7
2 changed files with 3 additions and 3 deletions

View file

@ -135,7 +135,7 @@ pub fn open_tap(
// same device.
tap = open_tap_rx_q_0(if_name, ip_addr, netmask, host_mac, mtu, num_rx_q, flags)?;
// Set the name of the tap device we open in subsequent iterations.
ifname = String::from_utf8(tap.get_if_name()).unwrap();
ifname = String::from_utf8(tap.get_if_name().to_vec()).unwrap();
} else {
tap = Tap::open_named(ifname.as_str(), num_rx_q, flags).map_err(Error::TapOpen)?;

View file

@ -481,8 +481,8 @@ impl Tap {
ifreq
}
pub fn get_if_name(&self) -> Vec<u8> {
self.if_name.clone()
pub fn get_if_name(&self) -> &[u8] {
&self.if_name
}
#[cfg(fuzzing)]