lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180725005133.107823-3-rkir@google.com>
Date:   Tue, 24 Jul 2018 17:51:33 -0700
From:   rkir@...gle.com
To:     gregkh@...uxfoundation.org
Cc:     linux-kernel@...r.kernel.org, Roman Kiryanov <rkir@...gle.com>
Subject: [PATCH v2 3/3] tty: Replace goldfish_tty_line_count with a #define

From: Roman Kiryanov <rkir@...gle.com>

The driver never mutates this variable - no benefits of
keeping it mutable.

Signed-off-by: Roman Kiryanov <rkir@...gle.com>
---
Changes in v2:
 - Replaced "const u32" with "#define".

 drivers/tty/goldfish.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 173383f2a4c1..eb88db4f243c 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -49,10 +49,11 @@ struct goldfish_tty {
 
 static DEFINE_MUTEX(goldfish_tty_lock);
 static struct tty_driver *goldfish_tty_driver;
-static u32 goldfish_tty_line_count = 8;
 static u32 goldfish_tty_current_line_count;
 static struct goldfish_tty *goldfish_ttys;
 
+#define GOLDFISH_TTY_LINE_COUNT 8
+
 static void do_rw_io(struct goldfish_tty *qtty,
 		     unsigned long address,
 		     unsigned int count,
@@ -225,7 +226,7 @@ static struct tty_driver *goldfish_tty_console_device(struct console *c,
 
 static int goldfish_tty_console_setup(struct console *co, char *options)
 {
-	if ((unsigned int)co->index >= goldfish_tty_line_count)
+	if ((unsigned int)co->index >= GOLDFISH_TTY_LINE_COUNT)
 		return -ENODEV;
 	if (!goldfish_ttys[co->index].base)
 		return -ENODEV;
@@ -251,14 +252,14 @@ static int goldfish_tty_create_driver(void)
 	int ret;
 	struct tty_driver *tty;
 
-	goldfish_ttys = kcalloc(goldfish_tty_line_count,
+	goldfish_ttys = kcalloc(GOLDFISH_TTY_LINE_COUNT,
 				sizeof(*goldfish_ttys),
 				GFP_KERNEL);
 	if (goldfish_ttys == NULL) {
 		ret = -ENOMEM;
 		goto err_alloc_goldfish_ttys_failed;
 	}
-	tty = alloc_tty_driver(goldfish_tty_line_count);
+	tty = alloc_tty_driver(GOLDFISH_TTY_LINE_COUNT);
 	if (tty == NULL) {
 		ret = -ENOMEM;
 		goto err_alloc_tty_driver_failed;
@@ -333,7 +334,7 @@ static int goldfish_tty_probe(struct platform_device *pdev)
 	else
 		line = pdev->id;
 
-	if (line >= goldfish_tty_line_count) {
+	if (line >= GOLDFISH_TTY_LINE_COUNT) {
 		pr_err("goldfish_tty: Reached maximum tty number of %d.\n",
 		       goldfish_tty_current_line_count);
 		ret = -ENOMEM;
-- 
2.18.0.233.g985f88cf7e-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ