public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Leo Hofmann <hofmann@leo-andres.de>
To: development@lists.ipfire.org
Subject: Re: [PATCH 2/2] menu: Fix warnings, clean code
Date: Thu, 07 Apr 2022 10:47:27 +0200	[thread overview]
Message-ID: <9f9b1330-84ec-4724-fc6d-e34cfb6e4c17@leo-andres.de> (raw)
In-Reply-To: <20220406133940.803-2-hofmann@leo-andres.de>

[-- Attachment #1: Type: text/plain, Size: 5937 bytes --]

Hi,

looking at this patch again, I'm unhappy with the default value operator. The "enabled" field is only numeric everywhere else.
So I should prevent the grep output from ending up in this field, altough it would be accepted as a "truthy" value.

I'll send a better patch. Sorry for the noise!

Best regards
Leo

Am 06.04.2022 um 15:39 schrieb Leo-Andres Hofmann:
> This patch adds default values and removes a missing translation
> to fix "uninitialized value" and "odd number of elements" warnings.
>
> Removes function calls from functions.pl that have already been
> handled by the header before it is loaded by eval().
>
> Signed-off-by: Leo-Andres Hofmann<hofmann(a)leo-andres.de>
> ---
>   config/cfgroot/header.pl                     |  4 +++-
>   config/menu/20-status.menu                   |  4 ++--
>   config/menu/30-network.menu                  |  2 +-
>   html/html/themes/ipfire/include/functions.pl | 14 ++++----------
>   langs/de/cgi-bin/de.pl                       |  1 -
>   langs/fr/cgi-bin/fr.pl                       |  1 -
>   6 files changed, 10 insertions(+), 16 deletions(-)
>
> diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl
> index e6d2b7c78..92e454dd1 100644
> --- a/config/cfgroot/header.pl
> +++ b/config/cfgroot/header.pl
> @@ -46,7 +46,7 @@ my $menu = \%menuhash;
>   %settings = ();
>   %ethsettings = ();
>   %pppsettings = ();
> -(a)URI = ();
> +my @URI = split('\?', $ENV{'REQUEST_URI'});
>   
>   ### Make sure this is an SSL request
>   if ($ENV{'SERVER_ADDR'} && $ENV{'HTTPS'} ne 'on') {
> @@ -596,3 +596,5 @@ sub _read_manualpage_hash() {
>   	}
>   	close($file);
>   }
> +
> +1; # End of package "Header"
> diff --git a/config/menu/20-status.menu b/config/menu/20-status.menu
> index 2bcf0d5e8..6ab68ec8c 100644
> --- a/config/menu/20-status.menu
> +++ b/config/menu/20-status.menu
> @@ -49,7 +49,7 @@
>   	$substatus->{'54.networkovpnsrv'} = {
>   				'caption' => "$Lang::tr{'vpn statistic n2n'}",
>   				'uri' => '/cgi-bin/netovpnsrv.cgi',
> -				'title' => "$Lang::tr{'vpn statistics n2n'}",
> +				'title' => "$Lang::tr{'vpn statistic n2n'}",
>   				'enabled' => 1,
>   			  };
>       $substatus->{'60.hardwaregraphs'} = {
> @@ -90,7 +90,7 @@
>       $substatus->{'75.atm-status'} = {'caption' => 'Atm-status',
>   				  'uri' => '/cgi-bin/atm-status.cgi',
>   				  'title' => 'Atm-status',
> -				  'enabled' => `find /sys/class/atm/*/device 2>/dev/null`,
> +				  'enabled' => `find /sys/class/atm/*/device 2>/dev/null` // 0,
>   				  };
>       $substatus->{'76.mdstat'} = {'caption' => 'Mdstat',
>   				  'uri' => '/cgi-bin/mdstat.cgi',
> diff --git a/config/menu/30-network.menu b/config/menu/30-network.menu
> index 19571a870..faef89a41 100644
> --- a/config/menu/30-network.menu
> +++ b/config/menu/30-network.menu
> @@ -67,7 +67,7 @@
>   				  'caption' => $Lang::tr{'aliases'},
>   				  'uri' => '/cgi-bin/aliases.cgi',
>   				  'title' => "$Lang::tr{'aliases'}",
> -				  'enabled' => `grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings`,
> +				  'enabled' => `grep "RED_TYPE=STATIC" /var/ipfire/ethernet/settings` // 0,
>   				  };
>       $subnetwork->{'80.macadressmenu'} = {
>   				  'caption' => $Lang::tr{'mac address menu'},
> diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl
> index 40afb3ce3..5a9ddbf88 100644
> --- a/html/html/themes/ipfire/include/functions.pl
> +++ b/html/html/themes/ipfire/include/functions.pl
> @@ -31,8 +31,6 @@
>   # IPFire default theme.                                                       #
>   ###############################################################################
>   
> -require "${General::swroot}/lang.pl";
> -
>   ###############################################################################
>   #
>   # print menu html elements for submenu entries
> @@ -103,16 +101,11 @@ sub openpage {
>   	my $extrahead = shift;
>   	my $suppressMenu = shift;
>   
> -	@URI=split ('\?',  $ENV{'REQUEST_URI'} );
> -	&General::readhash("${swroot}/main/settings", \%settings);
> -	&genmenu();
> -
>   	my $headline = "IPFire";
>   	if (($settings{'WINDOWWITHHOSTNAME'} eq 'on') || ($settings{'WINDOWWITHHOSTNAME'} eq '')) {
>   		$headline =  "$settings{'HOSTNAME'}.$settings{'DOMAINNAME'}";
>   	}
>   
> -
>   print <<END;
>   <!DOCTYPE html>
>   <html>
> @@ -163,7 +156,10 @@ print <<END
>   END
>   ;
>   
> -&showmenu() if ($suppressMenu != 1);
> +unless($suppressMenu) {
> +	&genmenu();
> +	&showmenu();
> +}
>   
>   print <<END
>   	<div class="bigbox fixed">
> @@ -268,5 +264,3 @@ sub openbox {
>   sub closebox {
>   	print "</div>";
>   }
> -
> -1;
> diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl
> index 0be097609..ab9e0d52e 100644
> --- a/langs/de/cgi-bin/de.pl
> +++ b/langs/de/cgi-bin/de.pl
> @@ -2880,7 +2880,6 @@
>   'vpn start action start' => 'Immer An',
>   'vpn statistic n2n' => 'OpenVPN: Netz-zu-Netz-Statistik',
>   'vpn statistic rw' => 'OpenVPN: Roadwarrior-Statistik',
> -'vpn statistics n2n' => 'OpenVPN: Netz-zu-Netz-Statistiken',
>   'vpn subjectaltname' => 'SubjectAlternativeName',
>   'vpn subjectaltname missing' => 'SubjectAlternativeName darf nicht leer bleiben.',
>   'vpn wait' => 'WARTE',
> diff --git a/langs/fr/cgi-bin/fr.pl b/langs/fr/cgi-bin/fr.pl
> index 60ea0dcc5..74184a416 100644
> --- a/langs/fr/cgi-bin/fr.pl
> +++ b/langs/fr/cgi-bin/fr.pl
> @@ -2956,7 +2956,6 @@
>   'vpn start action start' => 'Toujours démarré',
>   'vpn statistic n2n' => 'OpenVPN (site-à-site)',
>   'vpn statistic rw' => 'OpenVPN (client nomade)',
> -'vpn statistics n2n' => 'OpenVPN (site-à-site)',
>   'vpn subjectaltname' => 'Nom de l\'objet',
>   'vpn subjectaltname missing' => 'Le nom de l\'objet ne peut être vide.',
>   'vpn wait' => 'ATTENTE',

      reply	other threads:[~2022-04-07  8:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06 13:39 [PATCH 1/2] manualpages: Add path and file extension to the configuration Leo-Andres Hofmann
2022-04-06 13:39 ` [PATCH 2/2] menu: Fix warnings, clean code Leo-Andres Hofmann
2022-04-07  8:47   ` Leo Hofmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f9b1330-84ec-4724-fc6d-e34cfb6e4c17@leo-andres.de \
    --to=hofmann@leo-andres.de \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox