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: 136795 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3281310lji; Fri, 25 May 2018 01:21:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ0G3YnpFdwr9NS2Zjeq5opX46r2NPOOjm5JZrHzNAwBVNsF6robBaEElPQS4qjkO9jC2Ne X-Received: by 2002:a0c:9487:: with SMTP id j7-v6mr1187987qvj.104.1527236508909; Fri, 25 May 2018 01:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236508; cv=none; d=google.com; s=arc-20160816; b=efdk1dpD1c7YLQci7+qvE6hRI0fGXjcxSlnT07YyLeraaP8GaiR/QmNggaa+pxvBJS J85AAPTUdpJHn7QFlEY4MThBOQMu8fRAG4+5+AGlLJ+EcBjBSFMVfPMpNvyzqrk2/xkq HzRjDJoD82LAKbB110kU/vbCt0vLDcXeDBh5dgT2hCkworw/dG69fajSuMypunCi0Z/7 AKjA0DWIVj712O0GE+Jo3zC1lG5EZPsirUpvvM+UPbVjyHxtXPvhqX1Nyy3H1M0khl7S S3XDRjq6Ju+pe8gDIE/aehdKwF06H3dw1LuFJ5JxE6YFGuEEenoadjMVe3mE0yUjhJ7J w8mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=yu9WIVOLSsL4EV8n6Jk908gGJIYIXj8mO3fjOA99Am0=; b=fkBLo0MRCNPMl2PyJdJudy778M6z1TWkNVcgsPizGV/c/tEjtd1KXwNckW0aIJs8vr p2vFtbc2FvKAk2SeOXfstAxhBemUloqoVCSaxCl2BiiSzfto9lc9dRCTV/UaBqvkislA zh4K/HTia5yT+/ymspt/j0Ucfef/3O2lDBBB6mg2/yZZZBB66AVr2A0YDIXW59vHuyQR rLeXvha+JF4PyXjFkC4Oy1u5tbsykBK162y4BZZHXWe+sHH5DB3xjXGYkiWP38K3h6+U RsKZyhz0fqFH8J5fFIqGNk5CDEVfohIEI+4gYT4Q0p+teO5rXLVAlsYbDQF+Wf+VsUM0 YiqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y186-v6si4685179qkc.405.2018.05.25.01.21.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 25 May 2018 01:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:42394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fM7yu-0004Lz-Cy for patch@linaro.org; Fri, 25 May 2018 04:21:48 -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+patch=linaro.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(-) -- 2.14.3 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(); } }