From patchwork Sun Jun 30 22:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13717444 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9CB62AF12 for ; Sun, 30 Jun 2024 22:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787485; cv=none; b=rb+5HqaPl7eUyiLCdY7jyzfdJEkthLKh4cdODWo0SbVPzUVa0kagMW9oMNFvGK8clxVDo3HFHrGcCZAitaKXxWANAB8NzWurW3kf3xmV7Sjkx58TEnBdYUKoqDvD8UnT/JFFHLfQ7juFcYWb3Vq+XYcXrCFx9bdtqaxGfEv49p0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787485; c=relaxed/simple; bh=lfHT8mkeHCthULH79wu7AxRl2cOWwcrSwoMoN+g9azw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=n63kjpXFdBIy01cJGyxYjfh8ucrNZb0uho3EuZtczDwS8G2GKtiBrNaLqlHs8IzGexwvywy7Q7CJO5uWd2Z+1+O1YbeEq+RRNOBty4wGtlkYNikhvhEDN8L+IzOexqNGM7BtGb2j8w+YQgXscE4aiWCuhi41hCkSz/5x621N+Dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g3iUIxZS; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g3iUIxZS" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70675977d0eso1332280b3a.0 for ; Sun, 30 Jun 2024 15:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719787483; x=1720392283; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=iwgqgGKvF6BwBfoGeYc9Bu8MKd3Q+XbcN6EtYPz+/6o=; b=g3iUIxZSWB/88N0X1BQGPSsbCTdIYmqMYlyHtDlUvfOvmjLZ28aW3W3gusSxAUn8yZ EI3L3RP6V70Qot3qor++r+CIC62Oihms4XB86F/yGBoh4imtIdgqdn+EJwgJHiILKvqm rZfrMSOqU4AmHu3cV7ZtG4cowBX6zYVnerWQ1F0pFYy7YcM1BEAcNkWzGS69hufHmKl6 V+2+7jrKh3Gwm0no0gZhWlJbbARsyZellPkW8/b0YeXqpIJwjwGQlhml3k9m02Daa2WQ cJqYuLqgJrSVIFciCZR3dy/RykKAlEjKFejatJ7nNp3dIBaABvzo26E/5A6sj6DghZD0 b40A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719787483; x=1720392283; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=iwgqgGKvF6BwBfoGeYc9Bu8MKd3Q+XbcN6EtYPz+/6o=; b=c2O8kid3ftmxhfmgJsgjGN34PsgyVxf3oxeKgsjVNhQp6HG95kkfKqvy168VxhP5yF cuUxFPB4HwYUQrVDoJmptMj+N1YFkHOLkewqbcdy74hX9hCeUxiP4sQofZawnhjX/SEL vsm2I2VXz4UkvUEYHO+SoIA9rmw6zTUxYnuVJDJCjttb+s+wNXF45bgRhXGVh7tKWODB r25QeeAw+Lt3dFBGycEnSlIJzOW6AbZEKCnkMemOEmANQxpSHEOdq4BF1n5E4ULC2cXA Hm4GOCri+ittvSA/260UGNomGihgrzxRKOMBJgcVfHLXKrepFjHC2pjqhrcd+WqRePwk iKcw== X-Gm-Message-State: AOJu0Yyx8hYsDKSVnwMx+pyYrG1IQlxO3RlnE/8dZE/sf6SQcVRHLORE hkN/Vtl6tRs6gqFhejLH4jV82E+lkl8tO09GPOrIoyTS6Kwm1C5actAtiQ== X-Google-Smtp-Source: AGHT+IHJK1zJUq1J16aoeo0YuAmm0tppK5KuM9R3yEynCqGMxYRYpVaE36Tq0394nb2NV3fB5tv+VQ== X-Received: by 2002:a05:6a21:32a0:b0:1be:c4b9:c222 with SMTP id adf61e73a8af0-1bef611dc8fmr3070028637.11.1719787482666; Sun, 30 Jun 2024 15:44:42 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac15396casm51018995ad.175.2024.06.30.15.44.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 15:44:42 -0700 (PDT) From: Rosen Penev To: linux-media@vger.kernel.org Subject: [PATCH 1/4] v4l-utils: fix potential crashing with 32-bit musl Date: Sun, 30 Jun 2024 15:44:37 -0700 Message-ID: <20240630224440.5912-1-rosenp@gmail.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Under musl, if a format string has an integer followed by %s, a mismatch between types can cause the second half of the integer to be interpreted by %s. Eg: printf("%d %s", 64bittype, string); will crash, especially on 32-bit big endian. The reason these are cast to uint64_t is because time_t and suseconds_t are 64-bit under musl, even on 32-bit platforms. uint64_t helps avoid any truncation issues that may or may not arise. Signed-off-by: Rosen Penev --- utils/cec-follower/cec-follower.cpp | 3 ++- utils/libv4l2util/v4l2_driver.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp index a7481aea..9b29e3c6 100644 --- a/utils/cec-follower/cec-follower.cpp +++ b/utils/cec-follower/cec-follower.cpp @@ -3,6 +3,7 @@ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. */ +#include #include #include #include @@ -354,7 +355,7 @@ void print_timers(struct node *node) printf("source: %s, ", source.c_str()); if (t.recording_seq) printf("rec-seq: 0x%x, ", t.recording_seq); - printf("needs: %ld %s\n", t.duration, "MB."); /* 1MB per second. */ + printf("needs: %" PRIu64 " %s\n", (uint64_t)t.duration, "MB."); /* 1MB per second. */ } printf("Total media space available for recording: "); if (node->state.media_space_available >= 0) diff --git a/utils/libv4l2util/v4l2_driver.c b/utils/libv4l2util/v4l2_driver.c index 6b6366fa..5cd63fac 100644 --- a/utils/libv4l2util/v4l2_driver.c +++ b/utils/libv4l2util/v4l2_driver.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -174,13 +175,13 @@ static void prt_buf_info(char *name,struct v4l2_buffer *p) { struct v4l2_timecode *tc=&p->timecode; - printf ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, " + printf ("%s: %02" PRIu64 ":%02d:%02d.%08" PRIu64 " index=%d, type=%s, " "bytesused=%d, flags=0x%08x, " "field=%s, sequence=%d, memory=%s, offset=0x%08x, length=%d\n", - name, (p->timestamp.tv_sec/3600), + name, (uint64_t)(p->timestamp.tv_sec/3600), (int)(p->timestamp.tv_sec/60)%60, (int)(p->timestamp.tv_sec%60), - p->timestamp.tv_usec, + (uint64_t)p->timestamp.tv_usec, p->index, prt_names(p->type,v4l2_type_names), p->bytesused,p->flags, From patchwork Sun Jun 30 22:44:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13717445 Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF6A357CBB for ; Sun, 30 Jun 2024 22:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787486; cv=none; b=MIh319GzO+mV3GRwoTLpi9ez18gvPzYQF/tBKin0Vp9Bt8LHP2hWFVEtNNxzdoWRJZ2Ia3VtCJKEAZfxqXA2sA1Zjxkl/++rUqWBveSIlxj55a5Q1gvDsWIqD90RC9cFMQhbClkEt0yloi/uP0z1t+0NGehgT97dQFpOzelStCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787486; c=relaxed/simple; bh=fOIhJz+0yod2SuxSAgHdmqPoeVWNlgLlZDHJ9qgMFzg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XIJ6BEMhnjshhz56IDibeTaPyTWhf1oGdfRc5SanHy6FBiAEgCir1hzjcAaDaFp8wBT72brvGg4O9swMootWdviOy+br/OZ8gJTweeIzSOknw7JZ+gln7wtdFbJG5aiKZ1s7BjeeL1GMIrSCANdG45IAFVccknqjFCHCcsAvvTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Hfi+3QHt; arc=none smtp.client-ip=209.85.216.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hfi+3QHt" Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-2c7ecfc9e22so1302577a91.0 for ; Sun, 30 Jun 2024 15:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719787484; x=1720392284; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=WPV/17eP89KjnNG6iXD4b3yUiVesxwTGG7KbdEadf2w=; b=Hfi+3QHtxs6g1G85/TG/eJ5oejLuVRyARTLg2aDFLTtE1srlvaca6TQ+8rMxFrSafM kmiBC3uWMmjOiuJJZ13dvZVdijnjCCGKxatrK4en61rLjRzeORZNPyn6OHxPLg+HdSol WHrjx6NJHcwdLdC6ftsWz8LnCdLq/WJMsgXiW3Mbv0MLoUqGv2u+qDD+48ouXI4GLRs8 yRsVTqk3rmjsU+lQYZY9MKyJPnsYSfOS0BBij3LzmBcEosuWUOYwGR8qVekYz4DWy1RC Ys4Vi6H7sMQkwR3J4NbV8ofWFKQwkkavkOAVKpROYl5VuWqNFynFUbyVtqvMzPpVGvL4 K1Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719787484; x=1720392284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WPV/17eP89KjnNG6iXD4b3yUiVesxwTGG7KbdEadf2w=; b=hsNip5WcTfJVnmtt0qcKJ6rkL2d+0JNbIuIkcMYO0Pe08Npn7UEsNysVnmR0wsI2y0 SJreCt8sMvbe9aelgJgmHxR9i+rLmFIhMKPIwi0hS7lJ4dkC+wslNFWJu94hGc0D9q94 i0eR9eTjFLvtmwCSd6XMUcDq6LVa0igEJdrIxq9Yu9LMmAOpMxKIGqS1qAd4MN4HoQBR X3TG7Gu2cl2Le7xfLmKkR/St5hcNUWQoCLMz1trZ/BFRkBMoEZ8VHt+X2MIjwhPdk3/3 y3GLSOwnjQo4rp4le13Ybm5FUlQiTSH+oMcQztVdH5ZQfG3sVhBJ+Lug+Tepo9K5l4cN Zk8g== X-Gm-Message-State: AOJu0YzvX+lSvk+mysLiOvmQ4he97iUwySetHDy9SAkHIe+N2UwnspOs clNfI5f8RNV9TNTaq9qROOcEHGA9c+5dI1ywiNKxNfdwHvDOcCzXSINoYQ== X-Google-Smtp-Source: AGHT+IH0Z/DKKwzGb4pih6pIXa69IQYiG1nI22fgYPkMlqabaGPR+3nFY5ddpBmd33czN0G+En95BA== X-Received: by 2002:a17:903:2446:b0:1fa:13fc:33ea with SMTP id d9443c01a7336-1fadbc8bca0mr20476445ad.16.1719787483531; Sun, 30 Jun 2024 15:44:43 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac15396casm51018995ad.175.2024.06.30.15.44.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 15:44:43 -0700 (PDT) From: Rosen Penev To: linux-media@vger.kernel.org Subject: [PATCH 2/4] v4l-utils: use 64-bit off_t format Date: Sun, 30 Jun 2024 15:44:38 -0700 Message-ID: <20240630224440.5912-2-rosenp@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240630224440.5912-1-rosenp@gmail.com> References: <20240630224440.5912-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 musl uses 64-bit off_t by default on all platforms. Cast and fix format to work everywhere. Signed-off-by: Rosen Penev --- utils/v4l2-tracer/retrace.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp index 60d64d8b..010936c0 100644 --- a/utils/v4l2-tracer/retrace.cpp +++ b/utils/v4l2-tracer/retrace.cpp @@ -72,7 +72,7 @@ void retrace_mmap(json_object *mmap_obj, bool is_mmap64) (long) buf_address_retrace_pointer); if (is_verbose() || (errno != 0)) { - fprintf(stderr, "fd: %d, offset: %ld, ", fd_retrace, off); + fprintf(stderr, "fd: %d, offset: %lld, ", fd_retrace, (long long)off); if (is_mmap64) perror("mmap64"); else From patchwork Sun Jun 30 22:44:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13717446 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9357B6F31E for ; Sun, 30 Jun 2024 22:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787487; cv=none; b=CIxVdh0THXwYywotfvZwOekxi9hu7sgLFg4p1JwhbYDz37GOUbup+AE8bJUAgnxsQrmDnPlnmLh5lExds6Qjj7cj9Q1XHcuAR3JCcQkFqT3Mno6uOTnoKejBde6GzEGCXS0TIF+rHB+QCWdALhoCcs2hCO2/neX1I3qdA5eQmzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787487; c=relaxed/simple; bh=vfBWnrW6H7ZSKS4wodTVH3QflgQUnL6FMfsZ4JmuubU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZGQlby17IUqka/wixMQn/GLrDg/Iyn/rhZHBnvH8SG53MLCWWmYxK8TZTjL05ILuxoupjUCGmnWgXu36iWJOvuNHdJOJCBCU/90BvNjSixPMIyZ6zaTYzQ9X1Wt9EQEaKHjMjxSvnlCtiD0U9YYUbAZpx+3g/qmvYXJb9GVtpbc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SsEtZdVs; arc=none smtp.client-ip=209.85.166.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SsEtZdVs" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-376208fbe7bso11158895ab.3 for ; Sun, 30 Jun 2024 15:44:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719787484; x=1720392284; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/7/7nS13zJ9L6aYUdFSlRFp1hp8QZJWcCCalIj9iJiE=; b=SsEtZdVsLJgBZY4CfaxxXiPM6CGWwm8FHF0RCQ7wZkS9p7hIdoj16AWTm1HX4YJdhH rWsWO6MTIiah5ONai9FxSOFWO+XWeJfWJx6sAhpeBR/CK4biLjoKUxcet8XSP4V+qV/a S8JWrWxBeVLuhDxSYj+SU4FFHWRxcIDP5aclrJYifubN6Q60qyvChyDPJiNfSHzjV/KU JBoIH5g+WujHqsksKvgzwDQJKFAgr0jsmPkf8lDcatCVXeclMzj8n9SmbfVFJRz4iz57 nbxydNUvPumlcE+ZcDHWcVIA+k2a/bnj+TaVFtkmugjLgtfQMEvt/BabdFo5nNVCWODh i/uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719787484; x=1720392284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/7/7nS13zJ9L6aYUdFSlRFp1hp8QZJWcCCalIj9iJiE=; b=IffvfhKlkVNo8vykKEMFVmlT8W49Gg/x09qg3w9sLKMi9RzuhPY69r6LAix/2c7048 JmwULlXOGOmUE2O3rvtjcYruFTa5cKPl/HJYsq7Z3r4i6jUxvkGQuCIFoo+SBUKXs7mx MC68J75VS7b6OjsWp3FNQyALwtbsT+/iqE2uzYZDwyPExVT0HBIc7/EWw7rtEYpCqCMv nvKV946UKm3KC70LmsLQrP1fnONd9czMdNjuMJd1a5XVYDhXU5s+PdWaGPQ+H+iFnfrI z/YXi6T2DjEOvp2mHUsb2o1xvT+g37ZT+ViAosfMrJsR8w8sWeVBRHEsaltSu/9cKEBe TTZw== X-Gm-Message-State: AOJu0YwxzT/qcwVwvqPxDBCSsrEB2/AZVsp8HDopYV+ri1Igzy6xNa+e yNVR7IRaSUv2/7y4sufypJDvZp5oqHHIxcsErHFgh2iE/HoXhQbW4KsMfw== X-Google-Smtp-Source: AGHT+IGzBwK42+87pPBylKqQIAUVRn/s1F5lKlHemvzS1nPkzGvLqIMvlHQqJ6TjPekxAXkoz3M4SA== X-Received: by 2002:a05:6e02:1fe5:b0:375:a15e:d28b with SMTP id e9e14a558f8ab-37cd1793c0fmr51734055ab.16.1719787484552; Sun, 30 Jun 2024 15:44:44 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac15396casm51018995ad.175.2024.06.30.15.44.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 15:44:44 -0700 (PDT) From: Rosen Penev To: linux-media@vger.kernel.org Subject: [PATCH 3/4] v4l-utils: use 64-bit formats for time Date: Sun, 30 Jun 2024 15:44:39 -0700 Message-ID: <20240630224440.5912-3-rosenp@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240630224440.5912-1-rosenp@gmail.com> References: <20240630224440.5912-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 musl since version 1.2.0 uses 64-bit time_t and suseconds_t on all platforms, even 32-bit. Cast to avoid warnings and potentially future proof for when glibc and others gain support. Signed-off-by: Rosen Penev --- utils/cec-compliance/cec-compliance.cpp | 3 ++- utils/cec-compliance/cec-test-adapter.cpp | 5 +++-- utils/cec-ctl/cec-ctl.cpp | 19 ++++++++++--------- utils/cec-follower/cec-processing.cpp | 3 ++- utils/keytable/keytable.c | 1 + 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/utils/cec-compliance/cec-compliance.cpp b/utils/cec-compliance/cec-compliance.cpp index 8075e1d6..df633a33 100644 --- a/utils/cec-compliance/cec-compliance.cpp +++ b/utils/cec-compliance/cec-compliance.cpp @@ -3,6 +3,7 @@ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. */ +#include #include #include @@ -279,7 +280,7 @@ static std::string ts2s(__u64 ts) t = res.tv_sec; s = ctime(&t); s = s.substr(0, s.length() - 6); - sprintf(buf, "%03lu", res.tv_usec / 1000); + sprintf(buf, "%03" PRIu64, (uint64_t)res.tv_usec / 1000); return s + "." + buf; } diff --git a/utils/cec-compliance/cec-test-adapter.cpp b/utils/cec-compliance/cec-test-adapter.cpp index 08c856af..7a80d17b 100644 --- a/utils/cec-compliance/cec-test-adapter.cpp +++ b/utils/cec-compliance/cec-test-adapter.cpp @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -1276,9 +1277,9 @@ static int testLostMsgs(struct node *node) printf("\t\tReceived messages: %d of which %d were CEC_MSG_CEC_VERSION\n", pending_rx_msgs, pending_rx_cec_version_msgs); if (pending_quick_msgs < pending_msgs) - printf("\t\tReceived %d messages immediately, and %d over %ld seconds\n", + printf("\t\tReceived %d messages immediately, and %d over %" PRIu64 " seconds\n", pending_quick_msgs, pending_msgs - pending_quick_msgs, - time(nullptr) - start); + (uint64_t)time(nullptr) - start); } print_sfts(sft[1][1], "SFTs for repeating messages (>= 7)"); print_sfts(sft[1][0], "SFTs for repeating remote messages (>= 7)"); diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp index 8848a49d..fb38320d 100644 --- a/utils/cec-ctl/cec-ctl.cpp +++ b/utils/cec-ctl/cec-ctl.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -414,7 +415,7 @@ std::string ts2s(__u64 ts) strftime(buf, sizeof(buf), "%a %b %e %T.000000", &tm); } secs = last_secs + t - last_t; - sprintf(buf + 14, "%02u:%02u.%06lu", secs / 60, secs % 60, res.tv_usec); + sprintf(buf + 14, "%02u:%02u.%06d", secs / 60, secs % 60, (int)res.tv_usec); return buf; } @@ -942,10 +943,10 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto } fprintf(fstore, "# cec-ctl --store-pin\n"); fprintf(fstore, "# version %d\n", CEC_CTL_VERSION); - fprintf(fstore, "# start_monotonic %lu.%09lu\n", - start_monotonic.tv_sec, start_monotonic.tv_nsec); - fprintf(fstore, "# start_timeofday %lu.%06lu\n", - start_timeofday.tv_sec, start_timeofday.tv_usec); + fprintf(fstore, "# start_monotonic %" PRIu64 ".%09" PRIu64 "\n", + (uint64_t)start_monotonic.tv_sec, (uint64_t)start_monotonic.tv_nsec); + fprintf(fstore, "# start_timeofday %" PRIu64 ".%06" PRIu64 "\n", + (uint64_t)start_timeofday.tv_sec, (uint64_t)start_timeofday.tv_usec); fprintf(fstore, "# log_addr_mask 0x%04x\n", node.log_addr_mask); fprintf(fstore, "# phys_addr %x.%x.%x.%x\n", cec_phys_addr_exp(node.phys_addr)); @@ -984,10 +985,10 @@ static void monitor(const struct node &node, __u32 monitor_time, const char *sto */ clock_gettime(CLOCK_MONOTONIC, &start_monotonic); gettimeofday(&start_timeofday, nullptr); - fprintf(fstore, "# start_monotonic %lu.%09lu\n", - start_monotonic.tv_sec, start_monotonic.tv_nsec); - fprintf(fstore, "# start_timeofday %lu.%06lu\n", - start_timeofday.tv_sec, start_timeofday.tv_usec); + fprintf(fstore, "# start_monotonic %" PRIu64 ".%09" PRIu64 "\n", + (uint64_t)start_monotonic.tv_sec, (uint64_t)start_monotonic.tv_nsec); + fprintf(fstore, "# start_timeofday %" PRIu64 ".%06" PRIu64 "\n", + (uint64_t)start_timeofday.tv_sec, (uint64_t)start_timeofday.tv_usec); fflush(fstore); start_minute = now; } diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp index 14ee211b..20c6165c 100644 --- a/utils/cec-follower/cec-processing.cpp +++ b/utils/cec-follower/cec-processing.cpp @@ -4,6 +4,7 @@ */ #include +#include #include #include @@ -72,7 +73,7 @@ static std::string ts2s(__u64 ts, bool wallclock) t = res.tv_sec; s = ctime(&t); s = s.substr(0, s.length() - 6); - sprintf(buf, "%03lu", res.tv_usec / 1000); + sprintf(buf, "%03" PRIu64, (uint64_t)res.tv_usec / 1000); return s + "." + buf; } diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index b6474d5c..538f4ef3 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -212,6 +212,7 @@ static enum sysfs_protocols parse_sysfs_protocol(const char *name, bool all_allo return SYSFS_INVALID; } +__attribute__((format(printf, 3, 0))) static void write_sysfs_protocols(enum sysfs_protocols protocols, FILE *fp, const char *fmt) { const struct protocol_map_entry *pme; From patchwork Sun Jun 30 22:44:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 13717447 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 852F478C84 for ; Sun, 30 Jun 2024 22:44:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787489; cv=none; b=mtk+/AQMu49aQbmNqOnbVMRtBDVRlH7tk8ba2pWgNPR14uDtlVbBbWN2Few3Taq3y6TIZzZKg73rBCkdEM7R+5RHgwtrGrsPFx6GVlE6rUaIn699xkO3wa+G5iC1hGJS9M7qlaBIhdszpfAFDf1OISfnWS/c2C3Hw+xTcvu3tZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719787489; c=relaxed/simple; bh=2xrYzj7s8C5imxL7vRhnBlI1iwVC7I2IZgQKTRlPlKg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UlK1LM3fs4jgijUi2jVrugE5LPjIwlJWGW9PGOG7TEztEoMYRLGYss2OffURIp4FZwgJGsKDmhH5dRZmEaFPpm0i3G9AUoxbrO+mbx3FKRvQvWGxMav3LS2bqSRz3vX0aDwMhlrKU6sxTxB72aLaONgseaKeaS+265mcpdg6jRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EGvXJMDf; arc=none smtp.client-ip=209.85.166.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EGvXJMDf" Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-36dd56cf5f5so10424175ab.3 for ; Sun, 30 Jun 2024 15:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719787485; x=1720392285; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5pESUJ1u4mWewX4e2gGYV/uIFdWStLAz8jAqS6+xF00=; b=EGvXJMDfHViWAJf6O0ma4yJxaseQSpxsGPz9Yt47EIfOLAmiXKGwPrCVsF9dTAS1Cd 5K+ez9Lfs0X0ErwVVDTlp59frM9cXbbDYttmhC4RARJOvOey9/EEG/Px2b2kf617XYO1 YlU4yLXR7cBrspqYzoTNhXFrIQNFo5eSMZMU78bK+fnRXWkTUNaFL6XeD6E9ZdTEGhoB /iyUFLOGrMDlafynvIzbVgJmKQ6jNhrmiijWSHtzWDW7wbt+yFYK1E5119CJY93q8bI4 YoRENaTuxUEQ4mpHOgEjIh9GqPTJcFqTvySA7Q0IcPJUFP5si80VPPLe/1gMWoObfa6l sUWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719787485; x=1720392285; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5pESUJ1u4mWewX4e2gGYV/uIFdWStLAz8jAqS6+xF00=; b=wo/1GDkON2CpjN0gqLczZbbmJZE+W3PlZFAe3SsmgJeDKtUOLxDQ17YPW+yWpXHZ4/ 1LV3/cCjyKezqjYCA5wWoS1BKKyLKunsyvCwdEftKnkslsi+vAntPi5FCRUPgp18VmBy E+BizDtN8AuQFn+2pphHWlJjqNTYB3ophQsQ+rWJOmoFvcAbrvf9yq1cqY9i5CHu53iJ EPpCQzqEiNPvrmZWFLXLBGkRGYqF2G4SnLgRV0kz3qbROGyNUfKZx1A8hGy8KQFbUkWe RHs9VlsaXV/Fozc/YC7gLEacpi3zHSNpk8wIRhMDfv9NQvh+loWJZ7QsSY9sE7JcfyBV v0EA== X-Gm-Message-State: AOJu0Yxz3nEJyUm/I6XTqrIu/6QnSiH8YFLensdKza90qIqhjwGf6sQK DzhgU+RPsCuQ8eWO/tXe+cL3ZPNoBMb0sWdnj4GlvsHOXagVtWxkbR0vyw== X-Google-Smtp-Source: AGHT+IEQShyLO6G0z0X9mc6mCINiuvrfkr+BPzt5IJNS2C1SE+Sfhm8D95TBj6tbMe5NqyX+ADoStg== X-Received: by 2002:a05:6e02:12ed:b0:376:4544:8282 with SMTP id e9e14a558f8ab-37cd31b7522mr51675725ab.28.1719787485311; Sun, 30 Jun 2024 15:44:45 -0700 (PDT) Received: from ryzen.lan ([2601:644:8200:dab8::a86]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac15396casm51018995ad.175.2024.06.30.15.44.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 15:44:44 -0700 (PDT) From: Rosen Penev To: linux-media@vger.kernel.org Subject: [PATCH 4/4] v4l-utils: fix formats under ppc/mips64 Date: Sun, 30 Jun 2024 15:44:40 -0700 Message-ID: <20240630224440.5912-4-rosenp@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240630224440.5912-1-rosenp@gmail.com> References: <20240630224440.5912-1-rosenp@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Unlike libc, kernel headers use long long for 64-bit types. The exception is ppc64 and mips64, unless __SANE_USERSPACE_TYPES__ is defined. Define in compiler.h and include before kernel headers are included so that wrong __u64 and __s64 definitions to not get used. Fixes -Wformat warnings about llu being used instead of lu. Signed-off-by: Rosen Penev --- contrib/xc3028-firmware/firmware-tool.c | 2 ++ include/linux/compiler.h | 1 + utils/cec-compliance/cec-compliance.h | 2 ++ utils/cec-ctl/cec-ctl.cpp | 2 ++ utils/cec-ctl/cec-ctl.h | 2 ++ utils/cec-ctl/cec-pin.cpp | 2 ++ utils/cec-follower/cec-processing.cpp | 2 ++ utils/common/v4l2-info.h | 2 ++ utils/cx18-ctl/cx18-ctl.c | 2 ++ utils/ivtv-ctl/ivtv-ctl.c | 2 ++ utils/keytable/keytable.c | 2 ++ utils/media-ctl/media-ctl.c | 2 ++ utils/v4l2-compliance/v4l2-compliance.h | 2 ++ utils/v4l2-ctl/v4l2-ctl-common.cpp | 2 ++ utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 2 ++ utils/v4l2-ctl/v4l2-ctl.cpp | 2 ++ utils/v4l2-ctl/v4l2-ctl.h | 2 ++ utils/v4l2-dbg/v4l2-dbg.cpp | 2 ++ 18 files changed, 35 insertions(+) diff --git a/contrib/xc3028-firmware/firmware-tool.c b/contrib/xc3028-firmware/firmware-tool.c index 5dd205e0..6bcb3237 100644 --- a/contrib/xc3028-firmware/firmware-tool.c +++ b/contrib/xc3028-firmware/firmware-tool.c @@ -29,6 +29,8 @@ #include #include +#include "linux/compiler.h" + #include #include diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 379629be..5a6326f8 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -1,6 +1,7 @@ #ifndef __linux_compiler_h #define __linux_compiler_h +#define __SANE_USERSPACE_TYPES__ #define __user #endif diff --git a/utils/cec-compliance/cec-compliance.h b/utils/cec-compliance/cec-compliance.h index aae72842..d5bd1d0a 100644 --- a/utils/cec-compliance/cec-compliance.h +++ b/utils/cec-compliance/cec-compliance.h @@ -8,6 +8,8 @@ #ifndef _CEC_COMPLIANCE_H_ #define _CEC_COMPLIANCE_H_ +#include "linux/compiler.h" + #include #include "cec-htng-funcs.h" diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp index fb38320d..a2ffcb2b 100644 --- a/utils/cec-ctl/cec-ctl.cpp +++ b/utils/cec-ctl/cec-ctl.cpp @@ -21,6 +21,8 @@ #include #include +#include "linux/compiler.h" + #include #include "cec-htng-funcs.h" #include "cec-log.h" diff --git a/utils/cec-ctl/cec-ctl.h b/utils/cec-ctl/cec-ctl.h index 2c82bedc..e0692c31 100644 --- a/utils/cec-ctl/cec-ctl.h +++ b/utils/cec-ctl/cec-ctl.h @@ -6,6 +6,8 @@ #ifndef _CEC_CTL_H_ #define _CEC_CTL_H_ +#include "linux/compiler.h" + #include // cec-ctl.cpp diff --git a/utils/cec-ctl/cec-pin.cpp b/utils/cec-ctl/cec-pin.cpp index f3500555..0cdc19f7 100644 --- a/utils/cec-ctl/cec-pin.cpp +++ b/utils/cec-ctl/cec-pin.cpp @@ -3,6 +3,8 @@ * Copyright 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved. */ +#include "linux/compiler.h" + #include #include diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp index 20c6165c..cc38f143 100644 --- a/utils/cec-follower/cec-processing.cpp +++ b/utils/cec-follower/cec-processing.cpp @@ -3,6 +3,8 @@ * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. */ +#include "linux/compiler.h" + #include #include #include diff --git a/utils/common/v4l2-info.h b/utils/common/v4l2-info.h index ac227971..eeb7bc6b 100644 --- a/utils/common/v4l2-info.h +++ b/utils/common/v4l2-info.h @@ -8,6 +8,8 @@ #include +#include "linux/compiler.h" + #include #include diff --git a/utils/cx18-ctl/cx18-ctl.c b/utils/cx18-ctl/cx18-ctl.c index 8586f72d..7c13b1a3 100644 --- a/utils/cx18-ctl/cx18-ctl.c +++ b/utils/cx18-ctl/cx18-ctl.c @@ -34,6 +34,8 @@ #include #include +#include "linux/compiler.h" + #include #include diff --git a/utils/ivtv-ctl/ivtv-ctl.c b/utils/ivtv-ctl/ivtv-ctl.c index b42b3489..bf36f40b 100644 --- a/utils/ivtv-ctl/ivtv-ctl.c +++ b/utils/ivtv-ctl/ivtv-ctl.c @@ -34,6 +34,8 @@ #include #include +#include "linux/compiler.h" + #include #include diff --git a/utils/keytable/keytable.c b/utils/keytable/keytable.c index 538f4ef3..ba7c7c4d 100644 --- a/utils/keytable/keytable.c +++ b/utils/keytable/keytable.c @@ -12,6 +12,8 @@ GNU General Public License for more details. */ +#include "linux/compiler.h" + #include #include #include diff --git a/utils/media-ctl/media-ctl.c b/utils/media-ctl/media-ctl.c index 33df0880..f91c1cfa 100644 --- a/utils/media-ctl/media-ctl.c +++ b/utils/media-ctl/media-ctl.c @@ -34,6 +34,8 @@ #include #include +#include "linux/compiler.h" + #include #include #include diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h index 3517bd07..2c2b2158 100644 --- a/utils/v4l2-compliance/v4l2-compliance.h +++ b/utils/v4l2-compliance/v4l2-compliance.h @@ -26,6 +26,8 @@ #include #include +#include "linux/compiler.h" + #include #include #include diff --git a/utils/v4l2-ctl/v4l2-ctl-common.cpp b/utils/v4l2-ctl/v4l2-ctl-common.cpp index 1f9cd0fb..ea120eb8 100644 --- a/utils/v4l2-ctl/v4l2-ctl-common.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp @@ -9,6 +9,8 @@ #include #include +#include "linux/compiler.h" + #include #include "v4l2-ctl.h" diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index 13bc057d..7af62ec8 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -3,6 +3,8 @@ #include #include +#include "linux/compiler.h" + #include #include "compiler.h" diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index a64fa514..d8a6c617 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -27,6 +27,8 @@ #include #include +#include "linux/compiler.h" + #include #include "v4l2-ctl.h" diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index a1911e80..fd1bd24a 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -1,6 +1,8 @@ #ifndef _V4L2_CTL_H #define _V4L2_CTL_H +#include "linux/compiler.h" + #include #include #include diff --git a/utils/v4l2-dbg/v4l2-dbg.cpp b/utils/v4l2-dbg/v4l2-dbg.cpp index bd08b4cf..1b0d278a 100644 --- a/utils/v4l2-dbg/v4l2-dbg.cpp +++ b/utils/v4l2-dbg/v4l2-dbg.cpp @@ -31,6 +31,8 @@ #include #endif +#include "linux/compiler.h" + #include #include