public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4l-utils v1] v4l2-tracer: fix trace path name creation
@ 2023-03-30 14:36 Peter Seiderer
  2023-03-31  6:23 ` Deborah Brouwer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Seiderer @ 2023-03-30 14:36 UTC (permalink / raw)
  To: linux-media

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@gmx.net>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-31  6:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-30 14:36 [PATCH v4l-utils v1] v4l2-tracer: fix trace path name creation Peter Seiderer
2023-03-31  6:23 ` Deborah Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox