This is an automatic generated email to let you know that the following patch 
were queued at the 
http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:

Subject: v4l2-info.cpp: fix bufferflags2s: could end with ', '
Author:  Hans Verkuil <hverkuil-ci...@xs4all.nl>
Date:    Wed Mar 13 14:45:05 2019 +0100

If after clearing the timestamp-related flags the value was
0, then the string would end with ", ".

That is ugly, so rework the code.

Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 utils/common/v4l2-info.cpp | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

---

http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=f71fde5156ec8d08f863b3c3d21f9634d042966a
diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp
index c49e23ccd218..212c1a0fee29 100644
--- a/utils/common/v4l2-info.cpp
+++ b/utils/common/v4l2-info.cpp
@@ -686,33 +686,38 @@ static const flag_def buffer_flags_def[] = {
 
 std::string bufferflags2s(__u32 flags)
 {
-       std::string s;
+       const unsigned ts_mask = V4L2_BUF_FLAG_TIMESTAMP_MASK | 
V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+       std::string s = flags2s(flags & ~ts_mask, buffer_flags_def);
+
+       if (s.length())
+               s += ", ";
 
        switch (flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) {
        case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
-               s = "ts-unknown, ";
-               flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+               s += "ts-unknown";
                break;
        case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
-               s = "ts-monotonic, ";
-               flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+               s += "ts-monotonic";
                break;
        case V4L2_BUF_FLAG_TIMESTAMP_COPY:
-               s = "ts-copy, ";
-               flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+               s += "ts-copy";
+               break;
+       default:
+               s += "ts-invalid";
                break;
        }
        switch (flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
        case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
-               s += "ts-src-eof, ";
-               flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+               s += ", ts-src-eof";
                break;
        case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
-               s += "ts-src-soe, ";
-               flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+               s += ", ts-src-soe";
+               break;
+       default:
+               s += ", ts-src-invalid";
                break;
        }
-       return s + flags2s(flags, buffer_flags_def);
+       return s;
 }
 
 static const flag_def vbi_def[] = {

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to