From patchwork Fri May 25 08:17:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 920294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40sfP66MQBz9s1b for ; Fri, 25 May 2018 18:22:02 +1000 (AEST) Received: from localhost ([::1]:42394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7z5-0004Lz-HI for incoming@patchwork.ozlabs.org; Fri, 25 May 2018 04:21:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7vd-0001lH-KJ for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7vX-0008F5-O0 for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:25 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60651) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fM7vX-0008EJ-DY for qemu-devel@nongnu.org; Fri, 25 May 2018 04:18:19 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.183]) with ESMTPSA (Nemesis) id 0LrbAL-1gMNfI0Oy5-013NuC; Fri, 25 May 2018 10:18:09 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Fri, 25 May 2018 10:17:42 +0200 Message-Id: <20180525081754.29506-2-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180525081754.29506-1-laurent@vivier.eu> References: <20180525081754.29506-1-laurent@vivier.eu> X-Provags-ID: V03:K1:EU/HSOMjfadeVO+auwVzyo+R7ssl3LHVKei2xQIyQ6+lAf+WkeK KWTXeJyMeTbqkHjsphJvpqpZneeOggqzuYw2oSd722nth6BlksAlQqF0m/5LmTXDDpQvg/h zfF3VRdzlgybut6hRgtE1uE71vKFe1gSIsYnDo/B+qpWp4ZxqRWAEXCPaGQqUqmALY1DqQV ZetVrhW6cNilo+1JZnNQQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:jWBonskw4Ao=:O5qpbhZPTFsSGci1P2Kw0M Mqw7krdroS7zlJWLBR7Zs4TfvN+iz5U0H3k20nSQOZ9t6C/UyoJES8CRiEDut4dyS9iwVbOzm irqojWUp0VfpnZAstVa97EfcBZOmx6Rl/iTh/A8Cn1ouJ8d4rumKKCxOn8Jy8u/azvzA2qax0 vG7t9D/f4eT+T2jLeqpmQdJsAxVNiysoaGBSaZ1awwbZvEZgbjNYvgazOtz0gjciZeClbvf9f c8zht28m/jxPlIqIQEw5OJrvfUf+2tbfJmEaf4e/bhQkQCxv9RsCDLhokuerp7fRbkBaHAHFB Tnlcm+qXyveZB7pbHv4IL2+QMBBBHfNoRpQ1u8QcTdbylwAi5piwWXPZYo5S7YJGUWkPbgGEZ BpKwARRReSVoiytEDSlrHwEl1K7HYjNmW+LycBf3+Ns9VHjbBgazfkdvU2k6oPZqOr5TUShhY q7QCgAJGk9dwL/10MbKnkCTJKwj7nJUQW97EE1+mW5oRClUX7tc4PUVNc32uasR5/h6FRxphn O6RR/2u+ZIcrI8KPRpjikipfwP9p5ornb46AlB/Jn/Iltqt1EtMgOjCVwd//DR3ydAEELAkhw AMZrio0FccNLsrNNVDI5bXN+3uBZxxyso9kMuq4+djtqX7kwNAcTieTEXZgjC0kNdvgXvB5t2 i3IMkI7OCLVaBi1tdeGbztlC6VGDhSgRbFQ/oz0ePYb4VIofC1nFfXn7ekx6ZUZmsOi8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 01/13] linux-user: Assert on bad type in thunk_type_align() and thunk_type_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In thunk_type_align() and thunk_type_size() we currently return -1 if the value at the type_ptr isn't one of the TYPE_* values we understand. However, this should never happen, and if it does then the calling code will go confusingly wrong because none of the callsites try to handle an error return. Switch to an assertion instead, so that if this does somehow happen we'll have a nice clear backtrace of what happened rather than a weird crash or misbehaviour. This also silences various Coverity complaints about not handling the negative return value (CID 1005735, 1005736, 1005738, 1390582). Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Message-Id: <20180514174616.19601-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- include/exec/user/thunk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index 8f55b233b3..8d3af5a3be 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -135,7 +135,7 @@ static inline int thunk_type_size(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->size[is_host]; default: - return -1; + g_assert_not_reached(); } } @@ -185,7 +185,7 @@ static inline int thunk_type_align(const argtype *type_ptr, int is_host) se = struct_entries + type_ptr[1]; return se->align[is_host]; default: - return -1; + g_assert_not_reached(); } }