All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cec-follower/cec-compliance: fix bug in string conversion
@ 2016-08-19  8:56 Johan Fjeldtvedt
  0 siblings, 0 replies; only message in thread
From: Johan Fjeldtvedt @ 2016-08-19  8:56 UTC (permalink / raw)
  To: linux-media; +Cc: Johan Fjeldtvedt

In all_dev_types2s: don't try to erase the last two characters in the
string if it is empty.

This was fixed in cec-ctl, so the same fix is applied to cec-compliance
and cec-follower.

Signed-off-by: Johan Fjeldtvedt <jaffe1@gmail.com>
---
 utils/cec-compliance/cec-compliance.cpp | 4 +++-
 utils/cec-follower/cec-follower.cpp     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp
index c40d4b1..519c572 100644
--- a/utils/cec-compliance/cec-compliance.cpp
+++ b/utils/cec-compliance/cec-compliance.cpp
@@ -358,7 +358,9 @@ std::string all_dev_types2s(unsigned types)
 		s += "Audio System, ";
 	if (types & CEC_OP_ALL_DEVTYPE_SWITCH)
 		s += "Switch, ";
-	return s.erase(s.length() - 2, 2);
+	if (s.length())
+		return s.erase(s.length() - 2, 2);
+	return s;
 }
 
 std::string rc_src_prof2s(unsigned prof)
diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp
index abb06a8..7850ecd 100644
--- a/utils/cec-follower/cec-follower.cpp
+++ b/utils/cec-follower/cec-follower.cpp
@@ -305,7 +305,9 @@ std::string all_dev_types2s(unsigned types)
 		s += "Audio System, ";
 	if (types & CEC_OP_ALL_DEVTYPE_SWITCH)
 		s += "Switch, ";
-	return s.erase(s.length() - 2, 2);
+	if (s.length())
+		return s.erase(s.length() - 2, 2);
+	return s;
 }
 
 std::string rc_src_prof2s(unsigned prof)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-19  8:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-19  8:56 [PATCH] cec-follower/cec-compliance: fix bug in string conversion Johan Fjeldtvedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.