[11/12] rules.pl: Add workaround to hide a warning about an only once used variable.

Message ID 20220214184257.2406-11-stefan.schantl@ipfire.org
State Accepted
Commit 0564b0c7c98cac0e07f04f8d9e026d9f033fd012
Headers
Series [01/12] location-functions.pl: Rename and set the location for exported databases to "/var/lib/location/ipset/". |

Commit Message

Stefan Schantl Feb. 14, 2022, 6:42 p.m. UTC
  Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 config/firewall/rules.pl | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Peter Müller Feb. 14, 2022, 9:07 p.m. UTC | #1
Ugly, but I see why this is necessary.

Reviewed-by: Peter Müller <peter.mueller@ipfire.org>

> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
>  config/firewall/rules.pl | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
> index 162781f7a..c0878059a 100644
> --- a/config/firewall/rules.pl
> +++ b/config/firewall/rules.pl
> @@ -109,6 +109,10 @@ my $POLICY_INPUT_ACTION    = $fwoptions{"FWPOLICY2"};
>  my $POLICY_FORWARD_ACTION  = $fwoptions{"FWPOLICY"};
>  my $POLICY_OUTPUT_ACTION   = $fwoptions{"FWPOLICY1"};
>  
> +#workaround to suppress a warning when a variable is used only once
> +my @dummy = ( $Location::Functions::ipset_db_directory );
> +undef (@dummy);
> +
>  # MAIN
>  &main();
>
  
Michael Tremer Feb. 15, 2022, 12:37 p.m. UTC | #2
Is it not possible to disable this kind of warning entirely?

It is a stupid idea.

Does declaring the variable as some sort of constant help?

-Michael

> On 14 Feb 2022, at 18:42, Stefan Schantl <stefan.schantl@ipfire.org> wrote:
> 
> Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
> ---
> config/firewall/rules.pl | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
> index 162781f7a..c0878059a 100644
> --- a/config/firewall/rules.pl
> +++ b/config/firewall/rules.pl
> @@ -109,6 +109,10 @@ my $POLICY_INPUT_ACTION    = $fwoptions{"FWPOLICY2"};
> my $POLICY_FORWARD_ACTION  = $fwoptions{"FWPOLICY"};
> my $POLICY_OUTPUT_ACTION   = $fwoptions{"FWPOLICY1"};
> 
> +#workaround to suppress a warning when a variable is used only once
> +my @dummy = ( $Location::Functions::ipset_db_directory );
> +undef (@dummy);
> +
> # MAIN
> &main();
> 
> -- 
> 2.30.2
>
  

Patch

diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
index 162781f7a..c0878059a 100644
--- a/config/firewall/rules.pl
+++ b/config/firewall/rules.pl
@@ -109,6 +109,10 @@  my $POLICY_INPUT_ACTION    = $fwoptions{"FWPOLICY2"};
 my $POLICY_FORWARD_ACTION  = $fwoptions{"FWPOLICY"};
 my $POLICY_OUTPUT_ACTION   = $fwoptions{"FWPOLICY1"};
 
+#workaround to suppress a warning when a variable is used only once
+my @dummy = ( $Location::Functions::ipset_db_directory );
+undef (@dummy);
+
 # MAIN
 &main();