public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Peter Seiderer <ps.report@gmx.net>
Cc: linux-media@vger.kernel.org, hverkuil@xs4all.nl
Subject: Re: [PATCH v4l-utils v1] v4l2-tracer: fix trace path name creation
Date: Thu, 30 Mar 2023 23:23:24 -0700	[thread overview]
Message-ID: <ZCZ8XAdoUQCYQcLA@xps> (raw)
In-Reply-To: <20230330143635.17991-1-ps.report@gmx.net>

On Thu, Mar 30, 2023 at 04:36:35PM +0200, Peter Seiderer wrote:
> 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";
> -
Thanks for this patch, I checked and the file names are still working as
expected for traced, retraced and cleaned files, so looks good to me.

>  	}
>  	setenv("TRACE_ID", trace_id.c_str(), 0);
>  	std::string trace_filename = trace_id + ".json";
> -- 
> 2.40.0
> 

      reply	other threads:[~2023-03-31  6:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCZ8XAdoUQCYQcLA@xps \
    --to=deborah.brouwer@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=ps.report@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox