You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/02/07 13:10:51 UTC
[incubator-nuttx] 02/07: Remove the unnecessary '\0' terminator
from telnet driver
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch pr215
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 8d5b33235fdd7b8b792b7423aab42ce7dc04968e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Feb 5 16:24:54 2020 +0800
Remove the unnecessary '\0' terminator from telnet driver
Change-Id: If648641651a0355f5c445dd2b65e14d08cddb8c1
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/net/telnet.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index 92e6b05..e44feb7 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -645,7 +645,6 @@ static bool telnet_putchar(FAR struct telnet_dev_s *priv, uint8_t ch,
/* Now add the carriage return */
priv->td_txbuffer[index++] = ISO_cr;
- priv->td_txbuffer[index++] = '\0';
/* End of line */
@@ -669,17 +668,16 @@ static bool telnet_putchar(FAR struct telnet_dev_s *priv, uint8_t ch,
static void telnet_sendopt(FAR struct telnet_dev_s *priv, uint8_t option,
uint8_t value)
{
- uint8_t optbuf[4];
+ uint8_t optbuf[3];
int ret;
optbuf[0] = TELNET_IAC;
optbuf[1] = option;
optbuf[2] = value;
- optbuf[3] = 0;
- telnet_dumpbuffer("Send optbuf", optbuf, 4);
+ telnet_dumpbuffer("Send optbuf", optbuf, 3);
- ret = psock_send(&priv->td_psock, optbuf, 4, 0);
+ ret = psock_send(&priv->td_psock, optbuf, 3, 0);
if (ret < 0)
{
nerr("ERROR: Failed to send TELNET_IAC: %d\n", ret);
@@ -968,10 +966,10 @@ static ssize_t telnet_write(FAR struct file *filep, FAR const char *buffer,
eol = telnet_putchar(priv, ch, &ncopied);
/* Was that the end of a line? Or is the buffer too full to hold the
- * next largest character sequence ("\r\n\0")?
+ * next largest character sequence ("\r\n")?
*/
- if (eol || ncopied > CONFIG_TELNET_TXBUFFER_SIZE - 3)
+ if (eol || ncopied > CONFIG_TELNET_TXBUFFER_SIZE - 2)
{
/* Yes... send the data now */
@@ -1003,9 +1001,8 @@ static ssize_t telnet_write(FAR struct file *filep, FAR const char *buffer,
/* Notice that we don't actually return the number of bytes sent, but
* rather, the number of bytes that the caller asked us to send. We may
- * have sent more bytes (because of CR-LF expansion and because of NULL
- * termination). But it confuses some logic if you report that you sent
- * more than you were requested to.
+ * have sent more bytes (because of CR-LF expansion). But it confuses
+ * some logic if you report that you sent more than you were requested to.
*/
return len;