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]
Date:	Tue, 17 Nov 2015 07:24:22 -0800
From:	Joshua Clayton <stillcompiling@...il.com>
To:	Mark Brown <broonie@...nel.org>
Cc:	Jonathan Corbet <corbet@....net>,
	Adrian Remonda <adrianremonda@...il.com>,
	linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-spi@...r.kernel.org,
	Joshua Clayton <stillcompiling@...il.com>
Subject: [PATCH 2/8] Documentation/spi/spidev_test.c: clean up input_tx

Put input from string into its own function.

Signed-off-by: Joshua Clayton <stillcompiling@...il.com>
---
 Documentation/spi/spidev_test.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c
index dfe8f47..1ed9110 100644
--- a/Documentation/spi/spidev_test.c
+++ b/Documentation/spi/spidev_test.c
@@ -249,12 +249,20 @@ static void parse_opts(int argc, char *argv[])
 	}
 }
 
+static void transfer_escaped_string(int fd, char *str)
+{
+	size_t size = strlen(str + 1);
+	uint8_t *tx = malloc(size);
+
+	size = unescape((char *)tx, str, size);
+	transfer(fd, tx, size);
+	free(tx);
+}
+
 int main(int argc, char *argv[])
 {
 	int ret = 0;
 	int fd;
-	uint8_t *tx;
-	int size;
 
 	parse_opts(argc, argv);
 
@@ -299,15 +307,10 @@ int main(int argc, char *argv[])
 	printf("bits per word: %d\n", bits);
 	printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000);
 
-	if (input_tx) {
-		size = strlen(input_tx+1);
-		tx = malloc(size);
-		size = unescape((char *)tx, input_tx, size);
-		transfer(fd, tx, size);
-		free(tx);
-	} else {
+	if (input_tx)
+		transfer_escaped_string(fd, input_tx);
+	else
 		transfer(fd, default_tx, sizeof(default_tx));
-	}
 
 	close(fd);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ