Skip to content

more elegant handling of @result in resolve #105

@Zugschlus

Description

@Zugschlus

Hi,

please consider the following patch to resolve() which just initializes @Result to an empty list which is then pushd to by the code. That way, the extra logic at the end of the function can go since we never return an undefined value

diff --git a/src/ferm b/src/ferm
index dc29ef0..72f0bf4 100755
--- a/src/ferm
+++ b/src/ferm
@@ -1320,7 +1320,7 @@ sub resolve($@) {
     $type = ($domain eq 'ip6') ? 'AAAA' : 'A'
         unless $type;
 
-    my @result;
+    my @result = ();
     foreach my $hostname (@names) {
         my $numeric_type = identify_numeric_address($hostname);
         if (defined $numeric_type) {
@@ -1360,9 +1360,6 @@ sub resolve($@) {
     @result = resolve($domain, \@result, undef)
       if $type eq 'NS' or $type eq 'MX';
 
-    # if there are no records, return an empty array instead of "undefined"
-    return [] unless length @result;
-
     return @result;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions