{"id":409,"url":"https://patchwork.libcamera.org/api/patches/409/?format=json","web_url":"https://patchwork.libcamera.org/patch/409/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190126163257.10417-1-laurent.pinchart@ideasonboard.com>","date":"2019-01-26T16:32:57","name":"[libcamera-devel] libcamera: signal: Don't use reinterpret_cast<>() to perform downcasts","commit_ref":"eae59ca2cdc68236136685c52da17f6c37515d59","pull_url":null,"state":"accepted","archived":false,"hash":"56cbff5e5f8ec21d0817dcddccb757e9f6a267c7","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/409/mbox/","series":[{"id":143,"url":"https://patchwork.libcamera.org/api/series/143/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=143","date":"2019-01-26T16:32:57","name":"[libcamera-devel] libcamera: signal: Don't use reinterpret_cast<>() to perform downcasts","version":1,"mbox":"https://patchwork.libcamera.org/series/143/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/409/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/409/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E499160B2D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Jan 2019 17:33:09 +0100 (CET)","from pendragon.ideasonboard.com (85-76-41-125-nat.elisa-mobile.fi\n\t[85.76.41.125])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D0D3823A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Jan 2019 17:33:06 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548520389;\n\tbh=fGItqsHmpvreEQpZHix76CE5jCPyi5AvDPd4zEuZ+TI=;\n\th=From:To:Subject:Date:From;\n\tb=KXfD4Q8Af/7BZc+6KkyFwqCoKQnZEzUxbCacz/HvhmDn7N/nIkwNv1EobUoUtArxJ\n\t+9hCwo1bLzz6jkTXDTR0rV97WozLB2CMjBYBhujskzJEE+1cOAhV6VlAp9mfoOtyJ9\n\tdlxMVOud0LrawIRxQU8AVB9XiwaFEzK7vaCoGDQs=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] libcamera: signal: Don't use\n\treinterpret_cast<>() to perform downcasts","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Sat, 26 Jan 2019 16:33:10 -0000"},"content":"Use static_cast<>() instead of reinterpret_cast<>() to perform\ndowncasts, as reinterpret_cast<>() isn't meant (and guaranteed to be\nsafe) for that purpose.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/signal.h | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)","diff":"diff --git a/include/libcamera/signal.h b/include/libcamera/signal.h\nindex 0b437a486c08..c375b0a878af 100644\n--- a/include/libcamera/signal.h\n+++ b/include/libcamera/signal.h\n@@ -37,7 +37,7 @@ public:\n \tSlotMember(T *obj, void(T::*func)(Args...))\n \t\t: SlotBase<Args...>(obj), func_(func) { }\n \n-\tvoid invoke(Args... args) { (reinterpret_cast<T *>(this->obj_)->*func_)(args...); }\n+\tvoid invoke(Args... args) { (static_cast<T *>(this->obj_)->*func_)(args...); }\n \n private:\n \tfriend class Signal<Args...>;\n@@ -111,7 +111,7 @@ public:\n \t\t\t * match, so we can safely cast to SlotMember<T, Args>.\n \t\t\t */\n \t\t\tif (slot->obj_ == object &&\n-\t\t\t    reinterpret_cast<SlotMember<T, Args...> *>(slot)->func_ == func) {\n+\t\t\t    static_cast<SlotMember<T, Args...> *>(slot)->func_ == func) {\n \t\t\t\titer = slots_.erase(iter);\n \t\t\t\tdelete slot;\n \t\t\t} else {\n@@ -125,7 +125,7 @@ public:\n \t\tfor (auto iter = slots_.begin(); iter != slots_.end(); ) {\n \t\t\tSlotBase<Args...> *slot = *iter;\n \t\t\tif (slot->obj_ == nullptr &&\n-\t\t\t    reinterpret_cast<SlotStatic<Args...> *>(slot)->func_ == func) {\n+\t\t\t    static_cast<SlotStatic<Args...> *>(slot)->func_ == func) {\n \t\t\t\titer = slots_.erase(iter);\n \t\t\t\tdelete slot;\n \t\t\t} else {\n","prefixes":["libcamera-devel"]}