[PATCH v4l-utils v1] v4l2-tracer: fix trace path name creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fix trace path name creation for poor man's development boards
(e.g. Raspberry Pi) without RTC (starting at unix epoche aka time 0)
by forcing initial trace_id creation with 6 valid digits.

Fixes:

  terminate called after throwing an instance of 'std::out_of_range'
    what():  basic_string::substr: __pos (which is 5) > this->size() (which is 3)
  Aborted

Signed-off-by: Peter Seiderer <ps.report@xxxxxxx>
---
 utils/v4l2-tracer/v4l2-tracer.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/utils/v4l2-tracer/v4l2-tracer.cpp b/utils/v4l2-tracer/v4l2-tracer.cpp
index cb873d83..1a9a7d75 100644
--- a/utils/v4l2-tracer/v4l2-tracer.cpp
+++ b/utils/v4l2-tracer/v4l2-tracer.cpp
@@ -241,11 +241,9 @@ int tracer(int argc, char *argv[], bool retrace)
 		trace_id = json_file_name.substr(0, json_file_name.find(".json"));
 		trace_id += "_retrace";
 	} else {
-		const int timestamp_start_pos = 5;
-		trace_id = std::to_string(time(nullptr));
-		// trace_id = trace_id.substr(timestamp_start_pos, std::string::npos) + "_trace";
+		const int timestamp_start_pos = 1;
+		trace_id = std::to_string(100000 + time(nullptr) % 100000);
 		trace_id = trace_id.substr(timestamp_start_pos) + "_trace";
-
 	}
 	setenv("TRACE_ID", trace_id.c_str(), 0);
 	std::string trace_filename = trace_id + ".json";
-- 
2.40.0


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux