[libosmocore PATCH 11/12] vty: avoid using a .data variable.

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Diego Elio Pettenò flameeyes at flameeyes.eu
Fri Jun 29 20:01:28 UTC 2012


no_password_check was the only initialized, non-relocated data in the
set of libraries, inverting its logic let us keep it in .bss
(non-initialized data, which is mapped to the zero page).

Signed-off-by: Diego Elio Pettenò <flameeyes at flameeyes.eu>
---
 src/vty/vty.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/vty/vty.c b/src/vty/vty.c
index 28c2266..67ee100 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -78,7 +78,7 @@ char *vty_cwd = NULL;
 /* Configure lock. */
 static int vty_config;
 
-static int no_password_check = 1;
+static int password_check;
 
 void *tall_vty_ctx;
 
@@ -1492,7 +1492,7 @@ vty_create (int vty_sock, void *priv)
   vty->fd = vty_sock;
   vty->priv = priv;
   vty->type = VTY_TERM;
-  if (no_password_check)
+  if (!password_check)
     {
       if (host.advanced)
 	vty->node = ENABLE_NODE;
@@ -1515,7 +1515,7 @@ vty_create (int vty_sock, void *priv)
   else
     vty->lines = -1;
 
-  if (! no_password_check)
+  if (password_check)
     {
       /* Vty is not available if password isn't set. */
       if (host.password == NULL && host.password_encrypt == NULL)
@@ -1529,7 +1529,7 @@ vty_create (int vty_sock, void *priv)
 
   /* Say hello to the world. */
   vty_hello (vty);
-  if (! no_password_check)
+  if (password_check)
     vty_out (vty, "%sUser Access Verification%s%s", VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
 
   /* Setting up terminal. */
@@ -1573,14 +1573,14 @@ DEFUN(line_vty,
 /* vty login. */
 DEFUN(vty_login, vty_login_cmd, "login", "Enable password checking\n")
 {
-	no_password_check = 0;
+	password_check = 1;
 	return CMD_SUCCESS;
 }
 
 DEFUN(no_vty_login,
       no_vty_login_cmd, "no login", NO_STR "Enable password checking\n")
 {
-	no_password_check = 1;
+	password_check = 0;
 	return CMD_SUCCESS;
 }
 
@@ -1650,7 +1650,7 @@ static int vty_config_write(struct vty *vty)
 	vty_out(vty, "line vty%s", VTY_NEWLINE);
 
 	/* login */
-	if (no_password_check)
+	if (password_check)
 		vty_out(vty, " no login%s", VTY_NEWLINE);
 
 	vty_out(vty, "!%s", VTY_NEWLINE);
-- 
1.7.8.6





More information about the OpenBSC mailing list