[pve-devel] [PATCH pve-network 4/8] ipam: netbox: no conditional assignments for descriptions

Stefan Hanreich s.hanreich at proxmox.com
Fri Mar 7 18:43:48 CET 2025


While it should make practically no difference, it opens up potential
errors in the future, so just remove the conditional assignments and
explicitly define the variable as undef, so the intention is more
clear.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 src/PVE/Network/SDN/Ipams/NetboxPlugin.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
index 99ff3d9..6e1f78b 100644
--- a/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
+++ b/src/PVE/Network/SDN/Ipams/NetboxPlugin.pm
@@ -169,7 +169,8 @@ sub add_next_freeip {
 	die "could not find id for prefix $cidr";
     }
 
-    my $description = "mac:$mac" if $mac;
+    my $description = undef;
+    $description = "mac:$mac" if $mac;
 
     eval {
 	my $result = netbox_api_request($plugin_config, "POST", "/ipam/prefixes/$internalid/available-ips/", {
@@ -197,7 +198,8 @@ sub add_range_next_freeip {
 	die "could not find id for ip range $range->{'start-address'}:$range->{'end-address'}";
     }
 
-    my $description = "mac:$data->{mac}" if $data->{mac};
+    my $description = undef;
+    $description = "mac:$data->{mac}" if $data->{mac};
 
     eval {
 	my $result = netbox_api_request($plugin_config, "POST", "/ipam/ip-ranges/$internalid/available-ips/", {
-- 
2.39.5




More information about the pve-devel mailing list