From patchwork Thu Mar 30 14:36:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Seiderer X-Patchwork-Id: 668743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6691BC761A6 for ; Thu, 30 Mar 2023 14:36:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbjC3Ogo (ORCPT ); Thu, 30 Mar 2023 10:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbjC3Ogn (ORCPT ); Thu, 30 Mar 2023 10:36:43 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD1D5BA0 for ; Thu, 30 Mar 2023 07:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1680186995; i=ps.report@gmx.net; bh=2P0Lesg+bviUAuKIQ64qnjkT3y/8RPBLOWMVVl+n8do=; h=X-UI-Sender-Class:From:To:Subject:Date; b=JDDP1OH3Njb9W5rBWsvTxgHzUYeCv1HHFV8ajwdPK8o+WZnc4HnzMD1FuRy4uRggf D6vNbmvo0e/lvR69AYxv2MxHuAo3xwgjlQ0NRgXRGHdVwXoE8JJzxjHhhMa1OFBUZq 7APnqGHkppcWFyQ3hGNg70agj+U3TSX4Zxqvmf837H/X5KhOtAxJQcqQdnQiAo9R+n qwCY0go7YNvVope1Qs7wg/JIPjocmpxG2RA496WXy53bagX428rO29Yp0uO05KxUYc /YKVbQHOXVqOkPPo55duGHWuWbTKXBf4LVIsrMT2+ukN8fG7CTsALjvmJOC5cHmroP mN9aQ085xssCQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from localhost.fritz.box ([62.216.208.135]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1ML9uK-1q06jJ2gqI-00IGAJ for ; Thu, 30 Mar 2023 16:36:35 +0200 From: Peter Seiderer To: linux-media@vger.kernel.org Subject: [PATCH v4l-utils v1] v4l2-tracer: fix trace path name creation Date: Thu, 30 Mar 2023 16:36:35 +0200 Message-Id: <20230330143635.17991-1-ps.report@gmx.net> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:qliWxEy0dZQ/HtVpw/cv6drgktvQM5SQYdZa/fMbpjn0E2We9pF 3wuE3Z+N9ghk5bCCfv8hRfU6MuEUgzw2Eb33efgy+DYRcLrDS6XydlX9m3p90crDzHaR6Lx rq3f1M/De7QuA0YqOOhnU2cyYeY7uw2LBKYqn3Kf1G89I63PUBbM/gLjvf+zYwkeLccTfNw guuH4jDDroyMBa3juoTFA== UI-OutboundReport: notjunk:1;M01:P0:9hW9hsizV1s=;DibXIlbJKXJOB9bkdkVLulCoyNE 5UdmUempXg+KJpx0v8yWf3v0Iwhnvv/p99nkj00/0RPr2DamymZMBrpJh11gJa0Y5yttfSTOc 3hFNdIh/zIUyjB5EarYQgarYlKTkBRR/kpFuVn86Cye/ihB4Y5BqRaCawqLyt1jzFseivpr2I anVkRZKNUhfSheHx9ZIp13wlWOVowW6ftRiqbSxh0mKU1dfxp/cnkKmGTg3nTdSe3xa9o3sfG saBQ4E6+/VqT9o4wXm2cpoMpG4WBdfO2fYfv3vuqsU1mA+hbbieOjRiCZ1gVTYc/Us8Z1Mp+B e5LUxr3YJvLC5yiaQMhQglBS76Jh7P60LhUyYocMEYxfs/AJlyy3OqmKJwgPcZQwaoerwqak3 A+0TaqgNH/mKq9MjhUhvxtwtfwjmSpDZKDLcZ0MDPkvO8jc9syU/EvoLEW9OZBHnhfeHNraw5 pjNFxnKGCYAfhk9SBEncRMfzR4g3kCBpkfonb0fKQcvW5HGJLNs16kciwK1PIxwS1E1/vs2Bs kiWq2Ak4PEvPPAfPhQLXHjZg36OzyIyqJxVozZwBbDPitYtP/Mm0O8OnkmJdEbYUwmb978zGx p5AszsNK4FCB4JEzNmkjAY5+DKPrNt8nH4Knqu062ED0pJoKJ0q+5wcoOVMbb/pzSV1t5AlgZ pQ3SDIDK3qIXH3T5lHKqiTkfzoWo5sV9nv59q07meY68Cg3VZn/TnX8DQzeLYmDHE7ebW7xnD vyMiYZQeipSxDy2c3fYAJg0Id/sCv+z8u78aZRtavrD7u6+2VyTCGEsDRvgAOJ+B4mD8E9OI8 h/UcW6y3bkpn/69G+IvC6lgQwa6ortgXaUnRDYUjaiyLdH/HxqjEzH+2uOd72Tk4n4/RlSHUp XlKRVi+dbwg7dAKDZ6Kc373wLy9vNYpU4jfeJgggKy/KcrUOAMU0o3ss+Cm5Y3t5I8ZhJ3lu7 9p8/Mw== Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- 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";