From patchwork Sat Jan 26 16:32:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 409 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E499160B2D for ; Sat, 26 Jan 2019 17:33:09 +0100 (CET) Received: from pendragon.ideasonboard.com (85-76-41-125-nat.elisa-mobile.fi [85.76.41.125]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D0D3823A for ; Sat, 26 Jan 2019 17:33:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1548520389; bh=fGItqsHmpvreEQpZHix76CE5jCPyi5AvDPd4zEuZ+TI=; h=From:To:Subject:Date:From; b=KXfD4Q8Af/7BZc+6KkyFwqCoKQnZEzUxbCacz/HvhmDn7N/nIkwNv1EobUoUtArxJ +9hCwo1bLzz6jkTXDTR0rV97WozLB2CMjBYBhujskzJEE+1cOAhV6VlAp9mfoOtyJ9 dlxMVOud0LrawIRxQU8AVB9XiwaFEzK7vaCoGDQs= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 26 Jan 2019 18:32:57 +0200 Message-Id: <20190126163257.10417-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: signal: Don't use reinterpret_cast<>() to perform downcasts X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2019 16:33:10 -0000 Use static_cast<>() instead of reinterpret_cast<>() to perform downcasts, as reinterpret_cast<>() isn't meant (and guaranteed to be safe) for that purpose. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/signal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h index 0b437a486c08..c375b0a878af 100644 --- a/include/libcamera/signal.h +++ b/include/libcamera/signal.h @@ -37,7 +37,7 @@ public: SlotMember(T *obj, void(T::*func)(Args...)) : SlotBase(obj), func_(func) { } - void invoke(Args... args) { (reinterpret_cast(this->obj_)->*func_)(args...); } + void invoke(Args... args) { (static_cast(this->obj_)->*func_)(args...); } private: friend class Signal; @@ -111,7 +111,7 @@ public: * match, so we can safely cast to SlotMember. */ if (slot->obj_ == object && - reinterpret_cast *>(slot)->func_ == func) { + static_cast *>(slot)->func_ == func) { iter = slots_.erase(iter); delete slot; } else { @@ -125,7 +125,7 @@ public: for (auto iter = slots_.begin(); iter != slots_.end(); ) { SlotBase *slot = *iter; if (slot->obj_ == nullptr && - reinterpret_cast *>(slot)->func_ == func) { + static_cast *>(slot)->func_ == func) { iter = slots_.erase(iter); delete slot; } else {