From patchwork Thu Oct 22 08:17:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 10197 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9C7A8C3D3C for ; Thu, 22 Oct 2020 08:17:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 52AEA6145E; Thu, 22 Oct 2020 10:17:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tC3kiCcg"; dkim-atps=neutral Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 13A6A610FD for ; Thu, 22 Oct 2020 10:17:52 +0200 (CEST) Received: by mail-lj1-x22e.google.com with SMTP id c21so955551ljn.13 for ; Thu, 22 Oct 2020 01:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CNofFG72K/VFMDGmKHy1QkddTDq69y/CgSjwZQOhlRk=; b=tC3kiCcg/LncF/r6Qqi0qkAzcf6P3qJKAe8oBL2FR7pEtBJkDSTs/pxsQBNAtqRXR7 6gVl1rIhONxoh9RbPu78z6IroTEHre00E0MG+M7dZmodyfYKgR5Xbmj8zKVJ3cVYTmWl 1wMxu7xgRfylMMuZHYtTW+jpISUriVK1GYQgIpAGDAAr2jeadBXYOQDQjI4Y/4Xoc7Xf Qv7eFyVEKIGbeM4msx5KMV9QZ9BPA6/2BQFJ8JSZEU1NaIQTA2Lpvvgro6UVIjCFnZ89 wGBkD43y5uHymynjB3OwTJBMslIblsGpWwVdgNsdzi05VrD0A0CnK3MfZcaHEl58HThF da7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CNofFG72K/VFMDGmKHy1QkddTDq69y/CgSjwZQOhlRk=; b=aB+L57dclcv5LO4d0DEl+ZU+eHcRgWsindmCuixL80qj92rQY0UBtNVvgykDt4zYc2 OeTRxWEDmveDSk1Ne2gCn6fujNHxD8C3FbSZbqUErInd76UK5jFwsoRQscF8bHxaGKuM DpskYJ6O0ZjwE6DkvdufuaK9xlKZbvHWf5Bq+6sNryPUqjcZvu2APMYzWnE7G6I+iWHd CnNPUN8HtOmQTvFU/Uou9QaLF0LAAjgk8TlAHVqnlR+BXxBqSbz3ljxXuDNP3I9LUXEn fj7S6od4kgHuV7vW7XAAxXtaK6xIGyc40mD+qV8Ta+tSZ0BIsyaeL5iNhcUX6lbmDKcm WvYg== X-Gm-Message-State: AOAM531yh4G8FHCpYptk2rsFODcirThHpBX0f0iUa5zSOu5ND31JUJwq 8DislIRtYH3ujLHSn1GvfrOIB9izqn3M3g== X-Google-Smtp-Source: ABdhPJzT23WNeF0PKYOHEu0tEKyoMrkXnFYyuVEOMalqrIksoVfaxjc67bwArALU/lvzW7WhGucRXg== X-Received: by 2002:a05:651c:291:: with SMTP id b17mr571919ljo.177.1603354671298; Thu, 22 Oct 2020 01:17:51 -0700 (PDT) Received: from deskari.lan (91-152-83-50.elisa-laajakaista.fi. [91.152.83.50]) by smtp.gmail.com with ESMTPSA id l3sm187007lji.36.2020.10.22.01.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:17:50 -0700 (PDT) From: Tomi Valkeinen To: libcamera-devel@lists.libcamera.org Date: Thu, 22 Oct 2020 11:17:31 +0300 Message-Id: <20201022081731.36217-4-tomi.valkeinen@iki.fi> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201022081731.36217-1-tomi.valkeinen@iki.fi> References: <20201022081731.36217-1-tomi.valkeinen@iki.fi> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] HACK: suppress clang-tidy warnings X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" These are quick hacks to silence clang-tidy warnings. The purpose of this patch is just to highlight the warnings on the mailing list, and also, if you want to try to fix some of the warnings, it may be nice to have all the rest suppressed. Afaics, the thread->moveObject(this) warning is a false positive. Probably some of the others are too. Note that I used assert() there in a few places, just after ASSERT(). The reason being, ASSERT() just prints an error, while assert() aborts, so clang-tidy takes the assert() seriously. Not for merging. Signed-off-by: Tomi Valkeinen --- src/ipa/raspberrypi/controller/histogram.cpp | 2 +- src/libcamera/object.cpp | 3 ++- src/libcamera/pipeline/ipu3/ipu3.cpp | 1 + src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 ++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 2 ++ src/libcamera/v4l2_device.cpp | 1 - src/libcamera/v4l2_pixelformat.cpp | 2 +- 7 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ipa/raspberrypi/controller/histogram.cpp b/src/ipa/raspberrypi/controller/histogram.cpp index 9916b3ed..ac3f5c48 100644 --- a/src/ipa/raspberrypi/controller/histogram.cpp +++ b/src/ipa/raspberrypi/controller/histogram.cpp @@ -51,7 +51,7 @@ double Histogram::InterQuantileMean(double q_lo, double q_hi) const double p_lo = Quantile(q_lo); double p_hi = Quantile(q_hi, (int)p_lo); double sum_bin_freq = 0, cumul_freq = 0; - for (double p_next = floor(p_lo) + 1.0; p_next <= ceil(p_hi); + for (double p_next = floor(p_lo) + 1.0; p_next <= ceil(p_hi); // NOLINT: Variable 'p_next' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter] p_lo = p_next, p_next += 1.0) { int bin = floor(p_lo); double freq = (cumulative_[bin + 1] - cumulative_[bin]) * diff --git a/src/libcamera/object.cpp b/src/libcamera/object.cpp index cd83c684..1b1775e6 100644 --- a/src/libcamera/object.cpp +++ b/src/libcamera/object.cpp @@ -257,7 +257,8 @@ void Object::moveToThread(Thread *thread) notifyThreadMove(); - thread->moveObject(this); + // clang-tidy thinks that the thread can be deleted via DeferredDelete handling in notifyThreadMove() + thread->moveObject(this); // NOLINT: warning: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete] } void Object::notifyThreadMove() diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index af47739d..eac27153 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -508,6 +508,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * be at least one active stream in the configuration request). */ if (!vfCfg) { + assert(mainCfg); ret = imgu->configureViewfinder(*mainCfg, &outputFormat); if (ret) return ret; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index aa8d9340..4544d606 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1290,6 +1290,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) /* The buffer must belong to one of our streams. */ ASSERT(stream); + assert(stream); LOG(RPI, Debug) << "Stream " << stream->name() << " buffer dequeue" << ", buffer id " << index @@ -1358,6 +1359,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) /* The buffer must belong to one of our ISP output streams. */ ASSERT(stream); + assert(stream); LOG(RPI, Debug) << "Stream " << stream->name() << " buffer complete" << ", buffer id " << index diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index c74a2e9b..be55c32f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -379,6 +379,8 @@ protected: if (!info) LOG(RkISP1, Fatal) << "Frame not known"; + assert(info); + /* * \todo: If parameters are not filled a better method to handle * the situation than queuing a buffer with unknown content diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 31d4dad0..f747ba79 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -243,7 +243,6 @@ ControlList V4L2Device::getControls(const std::vector &ids) LOG(V4L2, Error) << "Unable to read control " << errorIdx << ": " << strerror(-ret); count = errorIdx - 1; - ret = errorIdx; } updateControls(&ctrls, v4l2Ctrls, count); diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 03ab085c..354136b7 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -163,7 +163,7 @@ std::string V4L2PixelFormat::toString() const } if (fourcc_ & (1 << 31)) - strcat(ss, "-BE"); + memcpy(ss + 4, "-BE", 3); return ss; }