From d03dfac6b9c07812c0b7b21858b247088d5605aa Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Fri, 17 Jan 2014 13:43:34 +0000 Subject: [PATCH] scpi: Strip trailing newlines in sr_scpi_get_string(). --- hardware/common/scpi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index 591b9770..0a1e52e9 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -312,6 +312,10 @@ SR_PRIV int sr_scpi_get_string(struct sr_scpi_dev_inst *scpi, g_string_append_len(response, buf, len); } + /* Get rid of trailing linefeed if present */ + if (response->len >= 1 && response->str[response->len - 1] == '\n') + g_string_truncate(response, response->len - 1); + *scpi_response = response->str; g_string_free(response, FALSE);