From e16521d3a16778fdacb62f97611a3b03baa65edc Mon Sep 17 00:00:00 2001
From: Tomek CEDRO <cederom@tlen.pl>
Date: Tue, 21 Jun 2011 00:37:00 +0200
Subject: INTERFACE/BITBANG: Fixed strnstr issue, command is now available only
 after 'init' as it should be, replaced hardcode with define.

---
 src/interface/bitbang.c | 12 ++++++------
 src/interface/bitbang.h |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/interface/bitbang.c b/src/interface/bitbang.c
index 443e9aea..63c9ca1e 100644
--- a/src/interface/bitbang.c
+++ b/src/interface/bitbang.c
@@ -55,7 +55,7 @@ COMMAND_HANDLER(handle_bitbang_command)
 	LOG_DEBUG("%s", __func__);
 
 	if (!jtag_interface){
-		LOG_ERROR("You need to setup interface first!");
+		LOG_ERROR("You need to select interface first!");
 		return ERROR_FAIL;
 	}
 
@@ -77,17 +77,17 @@ COMMAND_HANDLER(handle_bitbang_command)
 	static oocd_interface_signal_t *sig;
 	static unsigned int pn;
 	static int retval;
-	static char *mark, *signame, *sigval, pcmd[45];
+	static char *mark, *signame, *sigval, pcmd[OOCD_BITBANG_PARAM_CMD_MAX_LEN];
 
 	// Iterate through list of command parameters
 	for (pn=0;pn<CMD_ARGC;pn++){
 		// Make a local copy of parameter command to work on
-		if (!strncpy(pcmd, CMD_ARGV[pn], 45)){
+		if (!strncpy(pcmd, CMD_ARGV[pn], OOCD_BITBANG_PARAM_CMD_MAX_LEN)){
 			LOG_ERROR("Cannot copy parameter: %s", CMD_ARGV[pn]);
 			return ERROR_FAIL;
 		}
 		// Look for '=' mark to see if read or write will happen
-		mark=strnstr(pcmd, "=", 45);
+		mark=strstr(pcmd, "=");
 		if (!mark){
 			// If no '=' was found then we read the signal value
 			// Check if specified signal exists
@@ -138,8 +138,8 @@ static const struct command_registration bitbang_commands[] = {
 	{
 		.name = "bitbang",
 		.handler = handle_bitbang_command,
-		.mode = COMMAND_ANY,
-		.help =  "Perform bit-bang operations on interface signals (mask!).",
+		.mode = COMMAND_EXEC,
+		.help =  "Perform bit-bang operations on interface signal (mask!).",
 		.usage = "'signal_name' to read, 'signal_name'='port_hex_value' to write.",
 	},
 	COMMAND_REGISTRATION_DONE
diff --git a/src/interface/bitbang.h b/src/interface/bitbang.h
index 8d15d49c..fa7d6d60 100644
--- a/src/interface/bitbang.h
+++ b/src/interface/bitbang.h
@@ -22,6 +22,7 @@
 /** @file Simple framework to work with interface signals.
  */
 
+#define OOCD_BITBANG_PARAM_CMD_MAX_LEN 45
 int bitbang_register_commands(struct command_context *ctx);
 
 #endif
-- 
cgit v1.2.3